on master help sign in
Rename `Foreign` to `Port` across the codebase
commit72da9da9af5659ab16ce8433e1bb91792069d509 authorEvan Czaplicki <info@elm-lang.org> dateMon 11 Apr 2016, 18:04 (11 years ago) parent116f789
23 files changed+141−143
src/AST/Declaration.hs+1−1 src/AST/Effects.hs+10−10 src/AST/Expression/General.hs+2−2 src/AST/Expression/Optimized.hs+2−2 src/AST/Module.hs+1−1 src/Canonicalize.hs+4−4 src/Canonicalize/Body.hs+11−11 src/Canonicalize/Effects.hs+20−20 src/Canonicalize/Setup.hs+3−3 src/Canonicalize/Sort.hs+2−2 src/Generate/JavaScript.hs+1−1 src/Generate/JavaScript/Expression.hs+2−2 src/Nitpick/PatternMatches.hs+2−2 src/Nitpick/TopLevelTypes.hs+1−1 src/Optimize.hs+4−4 src/Optimize/Inline.hs+4−4 src/Parse/Declaration.hs+1−1 src/Parse/Module.hs+1−1 src/Reporting/Error/Canonicalize.hs+13−15 src/Reporting/Error/Syntax.hs+12−12 src/Type/Constrain/Effects.hs+1−1 src/Type/Constrain/Expression.hs+2−2 src/Validate.hs+41−41
src/AST/Declaration.hs+1−1
@@ -28,7 +28,7 @@ data Raw
2828 | Union (Union Type.Raw)
2929 | Alias (Alias Type.Raw)
3030 | Fixity Infix
31− | Foreign String Type.Raw
31+ | Port String Type.Raw
3232
3333
3434
src/AST/Effects.hs+10−10
@@ -10,18 +10,18 @@ import qualified Reporting.Region as R
1010-- EFFECTS
1111
1212
13−data Effects pkg foreigns
13+data Effects pkg ports
1414 = None
1515 | Manager pkg Info
16− | Foreign foreigns
16+ | Port ports
1717
1818
1919type Raw =
20− Effects () [A.Commented ForeignRaw]
20+ Effects () [A.Commented PortRaw]
2121
2222
2323type Canonical =
24− Effects Pkg.Name [A.Commented ForeignCanonical]
24+ Effects Pkg.Name [A.Commented PortCanonical]
2525
2626
2727
@@ -48,15 +48,15 @@ data ManagerType
4848-- FOREIGN EFFECTS
4949
5050
51−data ForeignRaw =
52− ForeignRaw
51+data PortRaw =
52+ PortRaw
5353 { _rawName :: String
5454 , _rawType :: Type.Raw
5555 }
5656
5757
58−data ForeignCanonical =
59− ForeignCanonical
58+data PortCanonical =
59+ PortCanonical
6060 { _name :: String
6161 , _kind :: Kind
6262 , _type :: Type.Canonical
@@ -64,5 +64,5 @@ data ForeignCanonical =
6464
6565
6666data Kind
67− = Cmd Type.Canonical
68− | Sub Type.Canonical
67+ = Outgoing Type.Canonical
68+ | Incoming Type.Canonical
src/AST/Expression/General.hs+2−2
@@ -57,8 +57,8 @@ data Expr' ann def var typ
5757 -- for type checking and code gen only
5858 | Cmd ModuleName.Canonical
5959 | Sub ModuleName.Canonical
60− | ForeignCmd String typ
61− | ForeignSub String typ
60+ | OutgoingPort String typ
61+ | IncomingPort String typ
6262 | Program (Main typ) (Expr ann def var typ)
6363 | SaveEnv ModuleName.Canonical Effects.Canonical
6464 | GLShader String String Literal.GLShaderTipe
src/AST/Expression/Optimized.hs+2−2
@@ -54,8 +54,8 @@ data Expr
5454 | Record [(String, Expr)]
5555 | Cmd ModuleName.Canonical
5656 | Sub ModuleName.Canonical
57− | ForeignCmd String Type.Canonical
58− | ForeignSub String Type.Canonical
57+ | OutgoingPort String Type.Canonical
58+ | IncomingPort String Type.Canonical
5959 | Program (Expr.Main Type.Canonical) Expr
6060 | GLShader String String Literal.GLShaderTipe
6161 | Crash ModuleName.Canonical R.Region (Maybe Expr)
src/AST/Module.hs+1−1
@@ -78,7 +78,7 @@ data SourceInfo =
7878data SourceTag
7979 = Normal
8080 | Effect R.Region
81− | Foreign R.Region
81+ | Port R.Region
8282
8383
8484type SourceSettings =
src/Canonicalize.hs+4−4
@@ -440,11 +440,11 @@ canonicalizeExpr env (A.A region validExpr) =
440440 Sub moduleName ->
441441 Result.ok (Sub moduleName)
442442
443− ForeignCmd name tipe ->
444− ForeignCmd name <$> Canon.tipe env tipe
443+ OutgoingPort name tipe ->
444+ OutgoingPort name <$> Canon.tipe env tipe
445445
446− ForeignSub name tipe ->
447− ForeignSub name <$> Canon.tipe env tipe
446+ IncomingPort name tipe ->
447+ IncomingPort name <$> Canon.tipe env tipe
448448
449449 Program _ _ ->
450450 error "DANGER - Program AST nodes should not be in canonicalization."
src/Canonicalize/Body.hs+11−11
@@ -120,8 +120,8 @@ effectsToDefs moduleName effects =
120120 Effects.None ->
121121 []
122122
123− Effects.Foreign foreigns ->
124− map foreignToDef foreigns
123+ Effects.Port ports ->
124+ map portToDef ports
125125
126126 Effects.Manager _ info ->
127127 let
@@ -154,17 +154,17 @@ effectsToDefs moduleName effects =
154154 ]
155155
156156
157−foreignToDef :: A.Commented Effects.ForeignCanonical -> Canonical.Def
158−foreignToDef (A.A (region, _) (Effects.ForeignCanonical name kind tipe)) =
159− definition name (A.A region (toForeignExpr name kind)) region tipe
157+portToDef :: A.Commented Effects.PortCanonical -> Canonical.Def
158+portToDef (A.A (region, _) (Effects.PortCanonical name kind tipe)) =
159+ definition name (A.A region (toPortExpr name kind)) region tipe
160160
161161
162−toForeignExpr :: String -> Effects.Kind -> Canonical.Expr'
163−toForeignExpr name kind =
162+toPortExpr :: String -> Effects.Kind -> Canonical.Expr'
163+toPortExpr name kind =
164164 case kind of
165− Effects.Cmd tipe ->
166− E.ForeignCmd name tipe
165+ Effects.Outgoing tipe ->
166+ E.OutgoingPort name tipe
167167
168− Effects.Sub tipe ->
169− E.ForeignSub name tipe
168+ Effects.Incoming tipe ->
169+ E.IncomingPort name tipe
170170
src/Canonicalize/Effects.hs+20−20
@@ -1,4 +1,4 @@
1−module Canonicalize.Effects (canonicalize, toValues, checkForeignType) where
1+module Canonicalize.Effects (canonicalize, toValues, checkPortType) where
22
33import qualified Data.Foldable as F
44import qualified Data.Traversable as T
@@ -28,8 +28,8 @@ toValues effects =
2828 Effects.Manager _ _ ->
2929 []
3030
31− Effects.Foreign foreigns ->
32− map (Var.Value . Effects._rawName . A.drop) foreigns
31+ Effects.Port ports ->
32+ map (Var.Value . Effects._rawName . A.drop) ports
3333
3434
3535
@@ -45,18 +45,18 @@ canonicalize env effects =
4545 Effects.Manager _ info ->
4646 Result.ok (Effects.Manager (Env.getPackage env) info)
4747
48− Effects.Foreign rawForeigns ->
49− Effects.Foreign <$> T.traverse (canonicalizeRawForeign env) rawForeigns
48+ Effects.Port rawPorts ->
49+ Effects.Port <$> T.traverse (canonicalizeRawPort env) rawPorts
5050
5151
52−canonicalizeRawForeign
52+canonicalizeRawPort
5353 :: Env.Environment
54− -> A.Commented Effects.ForeignRaw
55− -> Result (A.Commented Effects.ForeignCanonical)
56−canonicalizeRawForeign env (A.A ann (Effects.ForeignRaw name rawType)) =
54+ -> A.Commented Effects.PortRaw
55+ -> Result (A.Commented Effects.PortCanonical)
56+canonicalizeRawPort env (A.A ann (Effects.PortRaw name rawType)) =
5757 do tipe <- Canonicalize.tipe env rawType
5858 kind <- figureOutKind (fst ann) name tipe
59− Result.ok (A.A ann (Effects.ForeignCanonical name kind tipe))
59+ Result.ok (A.A ann (Effects.PortCanonical name kind tipe))
6060
6161
6262figureOutKind :: R.Region -> String -> T.Canonical -> Result Effects.Kind
@@ -64,36 +64,36 @@ figureOutKind region name rootType =
6464 case T.deepDealias rootType of
6565 T.Lambda outgoingType (T.App (T.Type effect) [T.Var _])
6666 | effect == Var.cmd ->
67− pure (Effects.Cmd outgoingType)
68− <* checkForeignType (makeError region name "command") outgoingType
67+ pure (Effects.Outgoing outgoingType)
68+ <* checkPortType (makeError region name) outgoingType
6969
7070 T.Lambda (T.Lambda incomingType (T.Var msg1)) (T.App (T.Type effect) [T.Var msg2])
7171 | effect == Var.sub && msg1 == msg2 ->
72− pure (Effects.Sub incomingType)
73− <* checkForeignType (makeError region name "subscription") incomingType
72+ pure (Effects.Incoming incomingType)
73+ <* checkPortType (makeError region name) incomingType
7474
7575 _ ->
7676 Result.throw region (error "TODO - bad overall type")
7777
7878
79−makeError :: R.Region -> String -> String -> T.Canonical -> Maybe String -> A.Located Error.Error
80−makeError region name kind tipe maybeMessage =
81− A.A region (Error.foreign name kind tipe maybeMessage)
79+makeError :: R.Region -> String -> T.Canonical -> Maybe String -> A.Located Error.Error
80+makeError region name tipe maybeMessage =
81+ A.A region (Error.port name tipe maybeMessage)
8282
8383
8484
8585-- CHECK INCOMING AND OUTGOING TYPES
8686
8787
88−checkForeignType
88+checkPortType
8989 :: (Monoid i)
9090 => (T.Canonical -> Maybe String -> A.Located e)
9191 -> T.Canonical
9292 -> Result.Result i w e ()
93−checkForeignType makeError tipe =
93+checkPortType makeError tipe =
9494 let
9595 check =
96− checkForeignType makeError
96+ checkPortType makeError
9797
9898 throw maybeMsg =
9999 Result.throwMany [makeError tipe maybeMsg]
src/Canonicalize/Setup.hs+3−3
@@ -368,12 +368,12 @@ effectsToPatches moduleName effects =
368368 Effects.None ->
369369 []
370370
371− Effects.Foreign foreigns ->
371+ Effects.Port ports ->
372372 let
373− toPatch (A.A _ (Effects.ForeignRaw name _)) =
373+ toPatch (A.A _ (Effects.PortRaw name _)) =
374374 Env.Value name (Var.topLevel moduleName name)
375375 in
376− map toPatch foreigns
376+ map toPatch ports
377377
378378 Effects.Manager _ info ->
379379 map (\name -> Env.Value name (Var.topLevel moduleName name)) $
src/Canonicalize/Sort.hs+2−2
@@ -102,10 +102,10 @@ reorder (A.A ann expression) =
102102 Sub _ ->
103103 return expression
104104
105− ForeignCmd _ _ ->
105+ OutgoingPort _ _ ->
106106 return expression
107107
108− ForeignSub _ _ ->
108+ IncomingPort _ _ ->
109109 return expression
110110
111111 Program _ _ ->
src/Generate/JavaScript.hs+1−1
@@ -42,7 +42,7 @@ generateEffectManager moduleName effects =
4242 Effects.None ->
4343 []
4444
45− Effects.Foreign _ ->
45+ Effects.Port _ ->
4646 []
4747
4848 Effects.Manager pkgName (Effects.Info _ _ _ _ managerType) ->
src/Generate/JavaScript/Expression.hs+2−2
@@ -209,10 +209,10 @@ generateCode expr =
209209 Sub moduleName ->
210210 jsExpr $ BuiltIn.effect moduleName
211211
212− ForeignCmd name tipe ->
212+ OutgoingPort name tipe ->
213213 jsExpr $ BuiltIn.outgoingPort name (Foreign.encode tipe)
214214
215− ForeignSub name tipe ->
215+ IncomingPort name tipe ->
216216 do jsDecoder <- generateJsExpr (Foreign.decode tipe)
217217 jsExpr $ BuiltIn.incomingPort name jsDecoder
218218
src/Nitpick/PatternMatches.hs+2−2
@@ -187,10 +187,10 @@ checkExpression tagDict (A.A region expression) =
187187 E.Sub _ ->
188188 Result.ok ()
189189
190− E.ForeignCmd _ _ ->
190+ E.OutgoingPort _ _ ->
191191 Result.ok ()
192192
193− E.ForeignSub _ _ ->
193+ E.IncomingPort _ _ ->
194194 Result.ok ()
195195
196196 E.Program _ _ ->
src/Nitpick/TopLevelTypes.hs+1−1
@@ -95,7 +95,7 @@ checkMain typeEnv (Can.Def facts pattern@(A.A region _) body maybeType) =
9595
9696 | name == program ->
9797 return (Expr.Flags arg)
98− <* Effects.checkForeignType makeError arg
98+ <* Effects.checkPortType makeError arg
9999
100100 _ ->
101101 Result.throw region (Error.BadMain mainType)
src/Optimize.hs+4−4
@@ -288,11 +288,11 @@ optimizeExpr context annExpr@(A.A region expression) =
288288 Expr.Sub moduleName ->
289289 pure (Opt.Sub moduleName)
290290
291− Expr.ForeignCmd name tipe ->
292− pure (Opt.ForeignCmd name tipe)
291+ Expr.OutgoingPort name tipe ->
292+ pure (Opt.OutgoingPort name tipe)
293293
294− Expr.ForeignSub name tipe ->
295− pure (Opt.ForeignSub name tipe)
294+ Expr.IncomingPort name tipe ->
295+ pure (Opt.IncomingPort name tipe)
296296
297297 Expr.Program kind expr ->
298298 Opt.Program kind <$> justConvert expr
src/Optimize/Inline.hs+4−4
@@ -175,10 +175,10 @@ count expression =
175175 Sub _ ->
176176 Map.empty
177177
178− ForeignCmd _ _ ->
178+ OutgoingPort _ _ ->
179179 Map.empty
180180
181− ForeignSub _ _ ->
181+ IncomingPort _ _ ->
182182 Map.empty
183183
184184 Program _ expr ->
@@ -289,10 +289,10 @@ replace substitutions expression =
289289 Sub _ ->
290290 expression
291291
292− ForeignCmd _ _ ->
292+ OutgoingPort _ _ ->
293293 expression
294294
295− ForeignSub _ _ ->
295+ IncomingPort _ _ ->
296296 expression
297297
298298 Program kind expr ->
src/Parse/Declaration.hs+1−1
@@ -95,5 +95,5 @@ portDecl =
9595 name <- Help.lowVar
9696 padded hasType
9797 tipe <- Type.expr
98− return $ Decl.Foreign name tipe
98+ return $ Decl.Port name tipe
9999
src/Parse/Module.hs+1−1
@@ -100,7 +100,7 @@ parseTag =
100100 whitespace
101101 reserved "module"
102102 end <- getMyPosition
103− return (Module.Foreign (R.Region start end))
103+ return (Module.Port (R.Region start end))
104104 ]
105105
106106
src/Reporting/Error/Canonicalize.hs+13−15
@@ -22,7 +22,7 @@ data Error
2222 | Import ModuleName.Raw ImportError
2323 | Export String [String]
2424 | DuplicateExport String
25− | Foreign ForeignError
25+ | Port PortError
2626
2727
2828
@@ -100,18 +100,17 @@ alias name expected actual =
100100-- PORTS
101101
102102
103−data ForeignError =
104− ForeignError
105− { foreignName :: String
106− , foreignKind :: String
107− , foreignType :: Type.Canonical
108− , foreignMessage :: Maybe String
103+data PortError =
104+ PortError
105+ { portName :: String
106+ , portType :: Type.Canonical
107+ , portMessage :: Maybe String
109108 }
110109
111110
112−foreign :: String -> String -> Type.Canonical -> Maybe String -> Error
113−foreign name kind tipe maybeMessage =
114− Foreign (ForeignError name kind tipe maybeMessage)
111+port :: String -> Type.Canonical -> Maybe String -> Error
112+port name tipe maybeMessage =
113+ Port (PortError name tipe maybeMessage)
115114
116115
117116
@@ -222,16 +221,15 @@ toReport localizer err =
222221 ("You are trying to export `" ++ name ++ "` multiple times!")
223222 "Remove duplicates until there is only one listed."
224223
225− Foreign (ForeignError name kind tipe maybeMessage) ->
224+ Port (PortError name tipe maybeMessage) ->
226225 let
227226 context =
228227 maybe "" (" the following " ++ ) maybeMessage
229228 in
230229 Report.report
231− "FOREIGN ERROR"
230+ "PORT ERROR"
232231 Nothing
233− ("Only certain types can flow in and out of Elm. The `"
234− ++ name ++ "` " ++ kind ++ " is trying to communicate an unsupported type."
232+ ("Port `" ++ name ++ "` is trying to communicate an unsupported type."
235233 )
236234 ( Help.stack
237235 [ text ("The specific unsupported type is" ++ context ++ ":")
@@ -287,7 +285,7 @@ extractSuggestions err =
287285 DuplicateExport _ ->
288286 Nothing
289287
290− Foreign _ ->
288+ Port _ ->
291289 Nothing
292290
293291
src/Reporting/Error/Syntax.hs+12−12
@@ -19,12 +19,12 @@ data Error
1919 | CommentOnNothing
2020
2121 | SettingsOnNormalModule
22− | SettingsOnForeignModule
22+ | SettingsOnPortModule
2323 | DuplicateSettingOnEffectModule String
2424 | BadSettingOnEffectModule String
2525 | NoSettingsOnEffectModule
2626 | MissingManagerOnEffectModule String
27− | UnexpectedForeign String
27+ | UnexpectedPort String
2828
2929 | InfixDuplicate String
3030 | TypeWithoutDefinition String
@@ -96,14 +96,14 @@ toReport _localizer err =
9696 \ the right direction!"
9797 )
9898
99− SettingsOnForeignModule ->
99+ SettingsOnPortModule ->
100100 Report.report
101101 "BAD MODULE DECLARATION"
102102 Nothing
103− "A foreign effect module can expose values, but not have settings like this."
103+ "A port module can expose values, but not have settings like this."
104104 ( Help.reflowParagraph $
105− "If you want a foreign effect module, just remove this stuff. If you want\
106− \ to create an `effect module` instead, just change `foreign effect module`\
105+ "If you want a port module, just remove this stuff. If you want to create\
106+ \ a custom effect module instead (which is rare) just change `port module`\
107107 \ to `effect module` and you should be headed in the right direction!"
108108 )
109109
@@ -150,15 +150,15 @@ toReport _localizer err =
150150 \ <TODO> (please forgive me if I forgot to fill this in!)"
151151 )
152152
153− UnexpectedForeign name ->
153+ UnexpectedPort name ->
154154 Report.report
155− "BAD FOREIGN"
155+ "BAD PORT"
156156 Nothing
157− ("You are declaring foreign effect " ++ Help.functionName name ++ " in a normal module.")
157+ ("You are declaring port " ++ Help.functionName name ++ " in a normal module.")
158158 ( Help.reflowParagraph $
159− "All foreign effects must be defined in a `foreign effect module`. You should\
160− \ probably have just one of these for your project. This way all of your foreign\
161− \ interactions stay relatively organized."
159+ "All ports must be defined in a `port module`. You should probably have just\
160+ \ one of these for your project. This way all of your foreign interactions\
161+ \ stay relatively organized."
162162 )
163163
164164 InfixDuplicate opName ->
src/Type/Constrain/Effects.hs+1−1
@@ -24,7 +24,7 @@ constrain env moduleName effects =
2424 Effects.None ->
2525 return CSaveEnv
2626
27− Effects.Foreign _ ->
27+ Effects.Port _ ->
2828 return CSaveEnv
2929
3030 Effects.Manager _ info ->
src/Type/Constrain/Expression.hs+2−2
@@ -43,10 +43,10 @@ constrain env annotatedExpr@(A.A region expression) tipe =
4343 E.Sub _ ->
4444 return CTrue
4545
46− E.ForeignCmd _ _ ->
46+ E.OutgoingPort _ _ ->
4747 return CTrue
4848
49− E.ForeignSub _ _ ->
49+ E.IncomingPort _ _ ->
5050 return CTrue
5151
5252 E.Program _ _ ->
src/Validate.hs+41−41
@@ -45,9 +45,9 @@ module' (Module.Module name path info) =
4545 (Module.Source tag settings docs exports imports decls) =
4646 info
4747 in
48− do (ValidStuff foreigns structure) <- validateDecls decls
48+ do (ValidStuff ports structure) <- validateDecls decls
4949
50− validEffects <- validateEffects tag settings foreigns (D._defs structure)
50+ validEffects <- validateEffects tag settings ports (D._defs structure)
5151
5252 return $ Module.Module name path $
5353 Module.Valid docs exports (addDefaults pkgName imports) structure validEffects
@@ -77,19 +77,19 @@ addDefaults pkgName imports =
7777validateEffects
7878 :: Module.SourceTag
7979 -> Module.SourceSettings
80− -> [A.Commented Effects.ForeignRaw]
80+ -> [A.Commented Effects.PortRaw]
8181 -> [A.Commented Valid.Def]
8282 -> Result wrn Effects.Raw
83−validateEffects tag settings@(A.A _ pairs) foreigns validDefs =
83+validateEffects tag settings@(A.A _ pairs) ports validDefs =
8484 case tag of
8585 Module.Normal ->
8686 do noSettings Error.SettingsOnNormalModule settings
87− noForeigns foreigns
87+ noPorts ports
8888 return Effects.None
8989
90− Module.Foreign _ ->
91− do noSettings Error.SettingsOnForeignModule settings
92− return (Effects.Foreign foreigns)
90+ Module.Port _ ->
91+ do noSettings Error.SettingsOnPortModule settings
92+ return (Effects.Port ports)
9393
9494 Module.Effect tagRegion ->
9595 let
@@ -99,7 +99,7 @@ validateEffects tag settings@(A.A _ pairs) foreigns validDefs =
9999 settingsDict =
100100 foldr collectSettings Map.empty pairs
101101 in
102− do noForeigns foreigns
102+ do noPorts ports
103103 managerType <- toManagerType tagRegion settingsDict
104104 (r0, r1, r2) <- checkManager tagRegion managerType validDefs
105105 return (Effects.Manager () (Effects.Info tagRegion r0 r1 r2 managerType))
@@ -115,18 +115,18 @@ noSettings errorMsg (A.A region settings) =
115115 Result.throw region errorMsg
116116
117117
118−noForeigns :: [A.Commented Effects.ForeignRaw] -> Result wrn ()
119−noForeigns foreigns =
120− case foreigns of
118+noPorts :: [A.Commented Effects.PortRaw] -> Result wrn ()
119+noPorts ports =
120+ case ports of
121121 [] ->
122122 Result.ok ()
123123
124124 _ : _ ->
125125 let
126− toError (A.A (region, _) (Effects.ForeignRaw name _)) =
127− A.A region (Error.UnexpectedForeign name)
126+ toError (A.A (region, _) (Effects.PortRaw name _)) =
127+ A.A region (Error.UnexpectedPort name)
128128 in
129− Result.throwMany (map toError foreigns)
129+ Result.throwMany (map toError ports)
130130
131131
132132toManagerType
@@ -302,7 +302,7 @@ validateDecls sourceDecls =
302302
303303data ValidStuff =
304304 ValidStuff
305− { _foreigns :: [A.Commented Effects.ForeignRaw]
305+ { _ports :: [A.Commented Effects.PortRaw]
306306 , _structure :: D.Valid
307307 }
308308
@@ -314,48 +314,48 @@ validateRawDecls commentedDecls =
314314
315315vrdHelp
316316 :: [A.Commented D.Raw]
317− -> [A.Commented Effects.ForeignRaw]
317+ -> [A.Commented Effects.PortRaw]
318318 -> D.Valid
319319 -> Result wrn ValidStuff
320−vrdHelp commentedDecls foreigns structure =
320+vrdHelp commentedDecls ports structure =
321321 case commentedDecls of
322322 [] ->
323− Result.ok (ValidStuff foreigns structure)
323+ Result.ok (ValidStuff ports structure)
324324
325325 A.A ann decl : rest ->
326326 case decl of
327327 D.Union (D.Type name tvars ctors) ->
328− vrdHelp rest foreigns (D.addUnion (A.A ann (D.Type name tvars ctors)) structure)
328+ vrdHelp rest ports (D.addUnion (A.A ann (D.Type name tvars ctors)) structure)
329329
330330 D.Alias (D.Type name tvars alias) ->
331− vrdHelp rest foreigns (D.addAlias (A.A ann (D.Type name tvars alias)) structure)
331+ vrdHelp rest ports (D.addAlias (A.A ann (D.Type name tvars alias)) structure)
332332
333333 D.Fixity fixity ->
334− vrdHelp rest foreigns (D.addInfix fixity structure)
334+ vrdHelp rest ports (D.addInfix fixity structure)
335335
336336 D.Def (A.A region def) ->
337− vrdDefHelp rest (A.A (region, snd ann) def) foreigns structure
337+ vrdDefHelp rest (A.A (region, snd ann) def) ports structure
338338
339− D.Foreign name tipe ->
340− vrdHelp rest (A.A ann (Effects.ForeignRaw name tipe) : foreigns) structure
339+ D.Port name tipe ->
340+ vrdHelp rest (A.A ann (Effects.PortRaw name tipe) : ports) structure
341341
342342
343343vrdDefHelp
344344 :: [A.Commented D.Raw]
345345 -> A.Commented Source.Def'
346− -> [A.Commented Effects.ForeignRaw]
346+ -> [A.Commented Effects.PortRaw]
347347 -> D.Valid
348348 -> Result wrn ValidStuff
349−vrdDefHelp remainingDecls (A.A ann def) foreigns structure =
349+vrdDefHelp remainingDecls (A.A ann def) ports structure =
350350 let
351− addDef validDef (ValidStuff finalForeigns struct) =
352− ValidStuff finalForeigns (D.addDef (A.A ann validDef) struct)
351+ addDef validDef (ValidStuff finalPorts struct) =
352+ ValidStuff finalPorts (D.addDef (A.A ann validDef) struct)
353353 in
354354 case def of
355355 Source.Definition pat expr ->
356356 addDef
357357 <$> validateDef pat expr Nothing
358− <*> vrdHelp remainingDecls foreigns structure
358+ <*> vrdHelp remainingDecls ports structure
359359
360360 Source.Annotation name tipe ->
361361 case remainingDecls of
@@ -363,10 +363,10 @@ vrdDefHelp remainingDecls (A.A ann def) foreigns structure =
363363 | Pattern.isVar name pat ->
364364 addDef
365365 <$> validateDef pat expr (Just tipe)
366− <*> vrdHelp rest foreigns structure
366+ <*> vrdHelp rest ports structure
367367
368368 _ ->
369− vrdHelp remainingDecls foreigns structure
369+ vrdHelp remainingDecls ports structure
370370 <* Result.throw (fst ann) (Error.TypeWithoutDefinition name)
371371
372372
@@ -523,11 +523,11 @@ expression (A.A ann sourceExpression) =
523523 Sub moduleName ->
524524 return (Sub moduleName)
525525
526− ForeignCmd name tipe ->
527− return (ForeignCmd name tipe)
526+ OutgoingPort name tipe ->
527+ return (OutgoingPort name tipe)
528528
529− ForeignSub name tipe ->
530− return (ForeignSub name tipe)
529+ IncomingPort name tipe ->
530+ return (IncomingPort name tipe)
531531
532532 Program _ _ ->
533533 error "DANGER - Program AST nodes should not be in validation phase."
@@ -564,17 +564,17 @@ validatePattern pattern =
564564
565565
566566checkDuplicates :: ValidStuff -> Result wrn ()
567−checkDuplicates (ValidStuff foreigns (D.Decls defs unions aliases _)) =
567+checkDuplicates (ValidStuff ports (D.Decls defs unions aliases _)) =
568568 let
569569 -- SIMPLE NAMES
570570
571571 defValues =
572572 concatMap (Pattern.boundVars . Valid.getPattern . A.drop) defs
573573
574− foreignValues =
575− map fromForeign foreigns
574+ portValues =
575+ map fromPort ports
576576
577− fromForeign (A.A (region, _) (Effects.ForeignRaw name _)) =
577+ fromPort (A.A (region, _) (Effects.PortRaw name _)) =
578578 A.A region name
579579
580580 -- TYPE NAMES
@@ -597,7 +597,7 @@ checkDuplicates (ValidStuff foreigns (D.Decls defs unions aliases _)) =
597597 []
598598 in
599599 F.sequenceA_
600− [ detectDuplicates Error.DuplicateValueDeclaration (foreignValues ++ defValues)
600+ [ detectDuplicates Error.DuplicateValueDeclaration (portValues ++ defValues)
601601 , detectDuplicates Error.DuplicateValueDeclaration (concat typeValues)
602602 , detectDuplicates Error.DuplicateTypeDeclaration types
603603 ]