@@ -1,6 +1,7 @@
1module AST.Type
1module AST.Type
2− ( Type(..), RawType, CanonicalType, PortType(..)
2+ ( Type(..), RawType, CanonicalType
3+ , PortType(..), PortDirection(..)
3− , portTypeToType, fieldMap, recordOf, listOf, tupleOf
4+ , fieldMap, recordOf, listOf, tupleOf
4 , deepDealias, dealias
5 , deepDealias, dealias
5 , collectLambdas
6 , collectLambdas
6 , prettyParens
7 , prettyParens
@@ -37,22 +38,18 @@ type CanonicalType =
37 Type Var.Canonical
38 Type Var.Canonical
40−data PortType var
41+data PortType var = PortType
41− = Inbound (Type var)
42+ { direction :: PortDirection var
42− | Internal (Type var)
43− | Outbound (Type var)
43+ , tipe :: Type var
44 deriving (Show)
45 deriving (Show)
47−portTypeToType :: PortType Var.Canonical -> CanonicalType
48+data PortDirection var
48−portTypeToType portType =
49+ = Inbound (Type var)
49− let makeType name tipe =
50− App (Type (Var.fromModule ["Port"] name)) [tipe]
53− Inbound tipe -> makeType "InboundPort" tipe
54− Internal tipe -> makeType "Port" tipe
50+ | Internal
55− Outbound tipe -> makeType "OutboundPort" tipe
51+ | Outbound (Type var)
58fieldMap :: [(String,a)] -> Map.Map String [a]
55fieldMap :: [(String,a)] -> Map.Map String [a]
@@ -139,15 +136,7 @@ replace typeTable t =
140instance (Pretty var, Var.ToString var) => Pretty (PortType var) where
137instance (Pretty var, Var.ToString var) => Pretty (PortType var) where
141 pretty portType =
138 pretty portType =
142− case portType of
139+ pretty (tipe portType)
144− P.text "InboundPort" <+> pretty tipe
147− P.text "Port" <+> pretty tipe
150− P.text "OutboundPort" <+> pretty tipe
153instance (Var.ToString var, Pretty var) => Pretty (Type var) where
142instance (Var.ToString var, Pretty var) => Pretty (Type var) where