on master help sign in
Remove crazy stuff (Stream / JavaScript => Json)
8a87749Evan Czaplicki
src/AST/Type.hs+3−3
@@ -47,7 +47,7 @@ type CanonicalType =
47
47
48data PortType var
48data PortType var
49 = Normal (Type var)
49 = Normal (Type var)
50− | Stream { root :: Type var, arg :: Type var }
50+ | Signal { root :: Type var, arg :: Type var }
51 deriving (Show)
51 deriving (Show)
52
52
53
53
@@ -55,7 +55,7 @@ portType :: PortType var -> Type var
55portType portType =
55portType portType =
56 case portType of
56 case portType of
57 Normal tipe -> tipe
57 Normal tipe -> tipe
58− Stream tipe _ -> tipe
58+ Signal tipe _ -> tipe
59
59
60
60
61fieldMap :: [(String,a)] -> Map.Map String [a]
61fieldMap :: [(String,a)] -> Map.Map String [a]
@@ -149,7 +149,7 @@ instance (Pretty var, Var.ToString var) => Pretty (PortType var) where
149 Normal tipe ->
149 Normal tipe ->
150 pretty tipe
150 pretty tipe
151
151
152− Stream tipe _ ->
152+ Signal tipe _ ->
153 pretty tipe
153 pretty tipe
154
154
155
155
src/AST/Variable.hs+6−6
@@ -49,9 +49,9 @@ is home name var =
49 var == Canonical (Module home) name
49 var == Canonical (Module home) name
50
50
51
51
52−isJavaScript :: Canonical -> Bool
52+isJson :: Canonical -> Bool
53−isJavaScript =
53+isJson =
54− is ["JavaScript", "Encode"] "Value"
54+ is ["Json", "Encode"] "Value"
55
55
56
56
57isMaybe :: Canonical -> Bool
57isMaybe :: Canonical -> Bool
@@ -68,9 +68,9 @@ isTask =
68 is ["Task"] "Task"
68 is ["Task"] "Task"
69
69
70
70
71−isStream :: Canonical -> Bool
71+isSignal :: Canonical -> Bool
72−isStream =
72+isSignal =
73− is ["SignalTypes"] "Stream"
73+ is ["Signal"] "Signal"
74
74
75
75
76isList :: Canonical -> Bool
76isList :: Canonical -> Bool
src/Generate/JavaScript.hs+4−4
@@ -212,16 +212,16 @@ expression (A region expr) =
212 Inbound (Type.Normal tipe) ->
212 Inbound (Type.Normal tipe) ->
213 return (Port.inbound name tipe)
213 return (Port.inbound name tipe)
214
214
215− Inbound (Type.Stream _ tipe) ->
215+ Inbound (Type.Signal _ tipe) ->
216− return (Port.inboundStream name tipe)
216+ return (Port.inboundSignal name tipe)
217
217
218 Outbound (Type.Normal tipe) expr ->
218 Outbound (Type.Normal tipe) expr ->
219 do expr' <- expression expr
219 do expr' <- expression expr
220 return (Port.outbound name tipe expr')
220 return (Port.outbound name tipe expr')
221
221
222− Outbound (Type.Stream _ tipe) expr ->
222+ Outbound (Type.Signal _ tipe) expr ->
223 do expr' <- expression expr
223 do expr' <- expression expr
224− return (Port.outboundStream name tipe expr')
224+ return (Port.outboundSignal name tipe expr')
225
225
226
226
227definition :: Canonical.Def -> State Int [Statement ()]
227definition :: Canonical.Def -> State Int [Statement ()]
src/Generate/JavaScript/Port.hs+10−10
@@ -1,6 +1,6 @@
1module Generate.JavaScript.Port
1module Generate.JavaScript.Port
2− ( inbound, inboundStream
2+ ( inbound, inboundSignal
3− , outbound, outboundStream
3+ , outbound, outboundSignal
4 ) where
4 ) where
5
5
6import qualified Data.List as List
6import qualified Data.List as List
@@ -82,9 +82,9 @@ inbound name tipe =
82 ]
82 ]
83
83
84
84
85−inboundStream :: String -> CanonicalType -> Expression ()
85+inboundSignal :: String -> CanonicalType -> Expression ()
86−inboundStream name tipe =
86+inboundSignal name tipe =
87− _Port "inboundStream" `call`
87+ _Port "inboundSignal" `call`
88 [ string name
88 [ string name
89 , string (show (pretty tipe))
89 , string (show (pretty tipe))
90 , toTypeFunction tipe
90 , toTypeFunction tipe
@@ -117,7 +117,7 @@ toType tipe x =
117 from checks = check x checks x
117 from checks = check x checks x
118
118
119 Type name
119 Type name
120− | Var.isJavaScript name ->
120+ | Var.isJson name ->
121 x
121 x
122
122
123 | Var.isTuple name ->
123 | Var.isTuple name ->
@@ -183,9 +183,9 @@ outbound name tipe expr =
183 _Port "outbound" `call` [ string name, fromTypeFunction tipe, expr ]
183 _Port "outbound" `call` [ string name, fromTypeFunction tipe, expr ]
184
184
185
185
186−outboundStream :: String -> CanonicalType -> Expression () -> Expression ()
186+outboundSignal :: String -> CanonicalType -> Expression () -> Expression ()
187−outboundStream name tipe expr =
187+outboundSignal name tipe expr =
188− _Port "outboundStream" `call` [ string name, fromTypeFunction tipe, expr ]
188+ _Port "outboundSignal" `call` [ string name, fromTypeFunction tipe, expr ]
189
189
190
190
191fromTypeFunction :: CanonicalType -> Expression ()
191fromTypeFunction :: CanonicalType -> Expression ()
@@ -223,7 +223,7 @@ fromType tipe x =
223 x
223 x
224
224
225 Type name
225 Type name
226− | Var.isJavaScript name -> x
226+ | Var.isJson name -> x
227 | Var.isTuple name -> ArrayLit () []
227 | Var.isTuple name -> ArrayLit () []
228 | otherwise -> error "bad type got to an output"
228 | otherwise -> error "bad type got to an output"
229
229
src/Transform/AddDefaultImports.hs−1
@@ -17,7 +17,6 @@ defaultImports =
17 , ["Maybe"] ==> exposing [Var.Union "Maybe" Var.openListing]
17 , ["Maybe"] ==> exposing [Var.Union "Maybe" Var.openListing]
18 , ["Result"] ==> exposing [Var.Union "Result" Var.openListing]
18 , ["Result"] ==> exposing [Var.Union "Result" Var.openListing]
19 , ["Signal"] ==> exposing [Var.Alias "Signal"]
19 , ["Signal"] ==> exposing [Var.Alias "Signal"]
20− , ["Stream"] ==> exposing [Var.Alias "Stream"]
21 ]
20 ]
22
21
23
22
src/Transform/Canonicalize.hs+2−2
@@ -315,8 +315,8 @@ expression env (A.A ann validExpr) =
315 Type.Normal t ->
315 Type.Normal t ->
316 Type.Normal <$> tipe' env t
316 Type.Normal <$> tipe' env t
317
317
318− Type.Stream root arg ->
318+ Type.Signal root arg ->
319− Type.Stream <$> tipe' env root <*> tipe' env arg
319+ Type.Signal <$> tipe' env root <*> tipe' env arg
320 in
320 in
321 Port name <$>
321 Port name <$>
322 case impl of
322 case impl of
src/Transform/Canonicalize/Port.hs+5−5
@@ -39,16 +39,16 @@ checkHelp name maybeExpr rootType tipe =
39 T.Aliased _ args t ->
39 T.Aliased _ args t ->
40 checkHelp name maybeExpr rootType (T.dealias args t)
40 checkHelp name maybeExpr rootType (T.dealias args t)
41
41
42− T.App (T.Type stream) [arg]
42+ T.App (T.Type signal) [arg]
43− | Var.isStream stream ->
43+ | Var.isSignal signal ->
44 case maybeExpr of
44 case maybeExpr of
45 Nothing ->
45 Nothing ->
46 do validForeignType name In arg arg
46 do validForeignType name In arg arg
47− return (D.Inbound name (T.Stream rootType arg))
47+ return (D.Inbound name (T.Signal rootType arg))
48
48
49 Just expr ->
49 Just expr ->
50 do validForeignType name Out arg arg
50 do validForeignType name Out arg arg
51− return (D.Outbound name expr (T.Stream rootType arg))
51+ return (D.Outbound name expr (T.Signal rootType arg))
52
52
53 _ ->
53 _ ->
54 case maybeExpr of
54 case maybeExpr of
@@ -84,7 +84,7 @@ validForeignType name portKind rootType tipe =
84 valid (T.dealias args t)
84 valid (T.dealias args t)
85
85
86 T.Type v ->
86 T.Type v ->
87− case any ($ v) [ Var.isJavaScript, Var.isPrimitive, Var.isTuple ] of
87+ case any ($ v) [ Var.isJson, Var.isPrimitive, Var.isTuple ] of
88 True -> return ()
88 True -> return ()
89 False -> err "It contains an unsupported type"
89 False -> err "It contains an unsupported type"
90
90