@@ -1,6 +1,7 @@
11module AST.Type
2− ( Type(..), RawType, CanonicalType, PortType(..)
3− , portTypeToType, fieldMap, recordOf, listOf, tupleOf
2+ ( Type(..), RawType, CanonicalType
3+ , PortType(..), PortDirection(..)
4+ , fieldMap, recordOf, listOf, tupleOf
45 , deepDealias, dealias
56 , collectLambdas
67 , prettyParens
@@ -37,22 +38,18 @@ type CanonicalType =
3738 Type Var.Canonical
3839
3940
40−data PortType var
41− = Inbound (Type var)
42− | Internal (Type var)
43− | Outbound (Type var)
41+data PortType var = PortType
42+ { direction :: PortDirection var
43+ , tipe :: Type var
44+ }
4445 deriving (Show)
4546
4647
47−portTypeToType :: PortType Var.Canonical -> CanonicalType
48−portTypeToType portType =
49− let makeType name tipe =
50− App (Type (Var.fromModule ["Port"] name)) [tipe]
51− in
52− case portType of
53− Inbound tipe -> makeType "InboundPort" tipe
54− Internal tipe -> makeType "Port" tipe
55− Outbound tipe -> makeType "OutboundPort" tipe
48+data PortDirection var
49+ = Inbound (Type var)
50+ | Internal
51+ | Outbound (Type var)
52+ deriving (Show)
5653
5754
5855fieldMap :: [(String,a)] -> Map.Map String [a]
@@ -139,15 +136,7 @@ replace typeTable t =
139136
140137instance (Pretty var, Var.ToString var) => Pretty (PortType var) where
141138 pretty portType =
142− case portType of
143− Inbound tipe ->
144− P.text "InboundPort" <+> pretty tipe
145−
146− Internal tipe ->
147− P.text "Port" <+> pretty tipe
148−
149− Outbound tipe ->
150− P.text "OutboundPort" <+> pretty tipe
139+ pretty (tipe portType)
151140
152141
153142instance (Var.ToString var, Pretty var) => Pretty (Type var) where