@@ -32,7 +32,7 @@ incoming tipe =
33inc :: Type -> Expression () -> Expression ()
33inc :: Type -> Expression () -> Expression ()
34inc tipe x =
34inc tipe x =
35− case tipe of
35+ case tipe of
36 Lambda _ _ -> error "functions should not be allowed through input ports"
36 Lambda _ _ -> error "functions should not be allowed through input ports"
37 Var _ -> error "type variables should not be allowed through input ports"
37 Var _ -> error "type variables should not be allowed through input ports"
38 Data ctor []
38 Data ctor []
@@ -58,22 +58,26 @@ inc tipe x =
59 array = DotRef () x (var "map") <| incoming t
59 array = DotRef () x (var "map") <| incoming t
61− Data ctor ts | Help.isTuple ctor -> check x JSArray tuple
62+ | Help.isTuple ctor -> check x JSArray tuple
63− tuple = ObjectLit () $ (PropId () (var "ctor"), string ctor) : values
64+ tuple = ObjectLit () $ (prop "ctor", string ctor) : values
64 values = zipWith convert [0..] ts
65 values = zipWith convert [0..] ts
65− convert n t = ( PropId () $ var ('_':show n)
66+ convert n t = ( prop ('_':show n)
66 , inc t (BracketRef () x (IntLit () n)))
67 , inc t (BracketRef () x (IntLit () n)))
68− Data _ _ -> error "bad ADT got to port generation code"
70+ error "bad ADT got to port generation code"
70− Record _ (Just _) -> error "bad record got to port generation code"
73+ error "bad record got to port generation code"
75+ Record fields Nothing ->
72− Record fields Nothing -> check x (JSObject (map fst fields)) object
76+ check x (JSObject (map fst fields)) object
74− object = ObjectLit () $ (PropId () (var "_"), ObjectLit () []) : keys
78+ object = ObjectLit () $ (prop "_", ObjectLit () []) : keys
75 keys = map convert fields
79 keys = map convert fields
76− convert (f,t) = (PropId () (var f), inc t (DotRef () x (var f)))
80+ convert (f,t) = (prop f, inc t (DotRef () x (var f)))
78outgoing tipe =
82outgoing tipe =
79 case tipe of
83 case tipe of
@@ -114,14 +118,16 @@ out tipe x =
114 | ctor == "_List" ->
118 | ctor == "_List" ->
115 DotRef () (obj "_J.fromList" <| x) (var "map") <| outgoing t
119 DotRef () (obj "_J.fromList" <| x) (var "map") <| outgoing t
117− Data ctor ts | Help.isTuple ctor ->
122+ | Help.isTuple ctor ->
118− ArrayLit () $ zipWith convert [0..] ts
120− convert n t = out t $ DotRef () x $ var ('_':show n)
123+ let convert n t = out t $ DotRef () x $ var ('_':show n)
121−
124+ in ArrayLit () $ zipWith convert [0..] ts
122− Data _ _ -> error "bad ADT got to port generation code"
127+ error "bad ADT got to port generation code"
129+ Record _ (Just _) ->
124− Record _ (Just _) -> error "bad record got to port generation code"
130+ error "bad record got to port generation code"
126 Record fields Nothing ->
132 Record fields Nothing ->
127 ObjectLit () keys
133 ObjectLit () keys