on master help sign in
Remove crazy stuff (Stream / JavaScript => Json)
commit8a877495a3a22f806b6b608b0bb2b41c31000ab2 authorEvan Czaplicki <info@elm-lang.org> dateWed 8 Apr 2015, 14:44 (12 years ago) parent0cb7175
7 files changed+30−31
src/AST/Type.hs+3−3 src/AST/Variable.hs+6−6 src/Generate/JavaScript.hs+4−4 src/Generate/JavaScript/Port.hs+10−10 src/Transform/AddDefaultImports.hs−1 src/Transform/Canonicalize.hs+2−2 src/Transform/Canonicalize/Port.hs+5−5
src/AST/Type.hs+3−3
@@ -47,7 +47,7 @@ type CanonicalType =
4747
4848data PortType var
4949 = Normal (Type var)
50− | Stream { root :: Type var, arg :: Type var }
50+ | Signal { root :: Type var, arg :: Type var }
5151 deriving (Show)
5252
5353
@@ -55,7 +55,7 @@ portType :: PortType var -> Type var
5555portType portType =
5656 case portType of
5757 Normal tipe -> tipe
58− Stream tipe _ -> tipe
58+ Signal tipe _ -> tipe
5959
6060
6161fieldMap :: [(String,a)] -> Map.Map String [a]
@@ -149,7 +149,7 @@ instance (Pretty var, Var.ToString var) => Pretty (PortType var) where
149149 Normal tipe ->
150150 pretty tipe
151151
152− Stream tipe _ ->
152+ Signal tipe _ ->
153153 pretty tipe
154154
155155
src/AST/Variable.hs+6−6
@@ -49,9 +49,9 @@ is home name var =
4949 var == Canonical (Module home) name
5050
5151
52−isJavaScript :: Canonical -> Bool
53−isJavaScript =
54− is ["JavaScript", "Encode"] "Value"
52+isJson :: Canonical -> Bool
53+isJson =
54+ is ["Json", "Encode"] "Value"
5555
5656
5757isMaybe :: Canonical -> Bool
@@ -68,9 +68,9 @@ isTask =
6868 is ["Task"] "Task"
6969
7070
71−isStream :: Canonical -> Bool
72−isStream =
73− is ["SignalTypes"] "Stream"
71+isSignal :: Canonical -> Bool
72+isSignal =
73+ is ["Signal"] "Signal"
7474
7575
7676isList :: Canonical -> Bool
src/Generate/JavaScript.hs+4−4
@@ -212,16 +212,16 @@ expression (A region expr) =
212212 Inbound (Type.Normal tipe) ->
213213 return (Port.inbound name tipe)
214214
215− Inbound (Type.Stream _ tipe) ->
216− return (Port.inboundStream name tipe)
215+ Inbound (Type.Signal _ tipe) ->
216+ return (Port.inboundSignal name tipe)
217217
218218 Outbound (Type.Normal tipe) expr ->
219219 do expr' <- expression expr
220220 return (Port.outbound name tipe expr')
221221
222− Outbound (Type.Stream _ tipe) expr ->
222+ Outbound (Type.Signal _ tipe) expr ->
223223 do expr' <- expression expr
224− return (Port.outboundStream name tipe expr')
224+ return (Port.outboundSignal name tipe expr')
225225
226226
227227definition :: Canonical.Def -> State Int [Statement ()]
src/Generate/JavaScript/Port.hs+10−10
@@ -1,6 +1,6 @@
11module Generate.JavaScript.Port
2− ( inbound, inboundStream
3− , outbound, outboundStream
2+ ( inbound, inboundSignal
3+ , outbound, outboundSignal
44 ) where
55
66import qualified Data.List as List
@@ -82,9 +82,9 @@ inbound name tipe =
8282 ]
8383
8484
85−inboundStream :: String -> CanonicalType -> Expression ()
86−inboundStream name tipe =
87− _Port "inboundStream" `call`
85+inboundSignal :: String -> CanonicalType -> Expression ()
86+inboundSignal name tipe =
87+ _Port "inboundSignal" `call`
8888 [ string name
8989 , string (show (pretty tipe))
9090 , toTypeFunction tipe
@@ -117,7 +117,7 @@ toType tipe x =
117117 from checks = check x checks x
118118
119119 Type name
120− | Var.isJavaScript name ->
120+ | Var.isJson name ->
121121 x
122122
123123 | Var.isTuple name ->
@@ -183,9 +183,9 @@ outbound name tipe expr =
183183 _Port "outbound" `call` [ string name, fromTypeFunction tipe, expr ]
184184
185185
186−outboundStream :: String -> CanonicalType -> Expression () -> Expression ()
187−outboundStream name tipe expr =
188− _Port "outboundStream" `call` [ string name, fromTypeFunction tipe, expr ]
186+outboundSignal :: String -> CanonicalType -> Expression () -> Expression ()
187+outboundSignal name tipe expr =
188+ _Port "outboundSignal" `call` [ string name, fromTypeFunction tipe, expr ]
189189
190190
191191fromTypeFunction :: CanonicalType -> Expression ()
@@ -223,7 +223,7 @@ fromType tipe x =
223223 x
224224
225225 Type name
226− | Var.isJavaScript name -> x
226+ | Var.isJson name -> x
227227 | Var.isTuple name -> ArrayLit () []
228228 | otherwise -> error "bad type got to an output"
229229
src/Transform/AddDefaultImports.hs−1
@@ -17,7 +17,6 @@ defaultImports =
1717 , ["Maybe"] ==> exposing [Var.Union "Maybe" Var.openListing]
1818 , ["Result"] ==> exposing [Var.Union "Result" Var.openListing]
1919 , ["Signal"] ==> exposing [Var.Alias "Signal"]
20− , ["Stream"] ==> exposing [Var.Alias "Stream"]
2120 ]
2221
2322
src/Transform/Canonicalize.hs+2−2
@@ -315,8 +315,8 @@ expression env (A.A ann validExpr) =
315315 Type.Normal t ->
316316 Type.Normal <$> tipe' env t
317317
318− Type.Stream root arg ->
319− Type.Stream <$> tipe' env root <*> tipe' env arg
318+ Type.Signal root arg ->
319+ Type.Signal <$> tipe' env root <*> tipe' env arg
320320 in
321321 Port name <$>
322322 case impl of
src/Transform/Canonicalize/Port.hs+5−5
@@ -39,16 +39,16 @@ checkHelp name maybeExpr rootType tipe =
3939 T.Aliased _ args t ->
4040 checkHelp name maybeExpr rootType (T.dealias args t)
4141
42− T.App (T.Type stream) [arg]
43− | Var.isStream stream ->
42+ T.App (T.Type signal) [arg]
43+ | Var.isSignal signal ->
4444 case maybeExpr of
4545 Nothing ->
4646 do validForeignType name In arg arg
47− return (D.Inbound name (T.Stream rootType arg))
47+ return (D.Inbound name (T.Signal rootType arg))
4848
4949 Just expr ->
5050 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))
5252
5353 _ ->
5454 case maybeExpr of
@@ -84,7 +84,7 @@ validForeignType name portKind rootType tipe =
8484 valid (T.dealias args t)
8585
8686 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
8888 True -> return ()
8989 False -> err "It contains an unsupported type"
9090