asm.js x emscripten: The foundation of the next level Web gamesNoritada Shimizu
Game requires high performance to its run times. asm.js brings Web browsers high performance JavaScript processing and allows us to build heavy games on the top of Web browsers. In this talk, we can see 1 )the background of asm.js 2) asm.js details and 3) overview of emscripten, a compiler which emits asm.js formatted JavaScript code from C/C++.
asm.js の詳細と emscripten の簡単な使い方について解説します。
asm.js x emscripten: The foundation of the next level Web gamesNoritada Shimizu
Game requires high performance to its run times. asm.js brings Web browsers high performance JavaScript processing and allows us to build heavy games on the top of Web browsers. In this talk, we can see 1 )the background of asm.js 2) asm.js details and 3) overview of emscripten, a compiler which emits asm.js formatted JavaScript code from C/C++.
asm.js の詳細と emscripten の簡単な使い方について解説します。
5. 例
type alias Guid = String
type alias Player =
{ name: String
, active: Bool
, id: Guid
}
player : Decoder Player
player =
succeed Player
|: ("name" := string)
|: ("active" := bool)
|: ("id" := string)
10. 例
{-# LANGUAGE DeriveGeneric #-}
type Guid = String
data Player =
{ name : String
, active : Bool
, id : Guid
} deriving (Generics, Show)
instance FromJSON Player
instance ToJSON Player
22. 例
extensible というヤバいパッケージを使う
type Player = Record
'[ "name" >: String
, "active" >: Bool
, "id" >: Guide
]
player :: Player
player =
#name @= "hige" <: #active @= True <: #id @= "123" <: emptyRecord
player ^. #name
参照には lens というヤバいパッケージを使う
23. 拡張可能レコードの JSON は??
これです
instance Forall (KeyValue KnownSymbol FromJSON) xs =>
FromJSON (Record xs) where
parseJSON = withObject "Object" $
v -> hgenerateFor
(Proxy :: Proxy (KeyValue KnownSymbol FromJSON)) $
m -> let k = symbolVal (proxyAssocKey m) in
case HM.lookup (fromString k) v of
Just a -> Field . return <$> parseJSON a
Nothing -> fail $ "Missing key: " `mappend` k
(雑に言えば)
拡張可能レコードという一つの型として扱う
24. まとめ
Elm で JSON はつらい?
つ elm-format with Haskell
Elm のレコード型を Haskell で書けない?
つ 拡張可能レコード
実際に ElmとHaskellでサンプル書いた記事 がある
ので詳しくはコレを見て(?)
Haskell 最高じゃん