@@ -1,13 +1,6 @@
1+{-# OPTIONS_GHC -Wall #-}
12module Type.Constrain.Declaration where
23
3−import Control.Monad
4−import Control.Applicative ((<$>))
5−
6−import qualified Data.Map as Map
7−
8−import qualified Type.Constrain.Expression as TcExpr
9−import qualified Type.Environment as Env
10−
114import SourceSyntax.Declaration
125import qualified SourceSyntax.Expression as Src
136import qualified SourceSyntax.Location as L
@@ -22,15 +15,15 @@ toDefs decl =
2215 case decl of
2316 Definition def -> [def]
2417
25− Datatype name tvars constructors _ -> concatMap toDefs constructors
18+ Datatype name tvars constructors _ -> concatMap toDefs' constructors
2619 where
27− toDefs (ctor, tipes) =
20+ toDefs' (ctor, tipes) =
2821 let vars = take (length tipes) arguments
2922 tbody = Type.Data name $ map Type.Var tvars
3023 body = L.none . Src.Data ctor $ map (L.none . Src.Var) vars
3124 in [ definition ctor (buildFunction body vars) (foldr Type.Lambda tbody tipes) ]
3225
33− TypeAlias name tvars tipe@(Type.Record fields ext) _ ->
26+ TypeAlias name _ tipe@(Type.Record fields ext) _ ->
3427 [ definition name (buildFunction record vars) (foldr Type.Lambda tipe args) ]
3528 where
3629 args = case ext of
@@ -53,7 +46,7 @@ toDefs decl =
5346 Port port ->
5447 case port of
5548 Send name expr tipe -> [ definition name expr tipe ]
56− Recv name expr tipe -> -- [ definition name ]
49+ Recv _ _ _ -> -- [ definition name ]
5750 error "not sure how to generate constraints for recv yet"
5851
5952 -- no constraints are needed for fixity declarations
@@ -61,9 +54,11 @@ toDefs decl =
6154
6255
6356arguments :: [String]
64−arguments = map (:[]) ['a'..'z'] ++ map (\n -> "_" ++ show n) [1..]
57+arguments = map (:[]) ['a'..'z'] ++ map (\n -> "_" ++ show (n :: Int)) [1..]
6558
59+buildFunction :: Src.LExpr -> [String] -> Src.LExpr
6660buildFunction body@(L.L s _) vars =
6761 foldr (\p e -> L.L s (Src.Lambda p e)) body (map P.PVar vars)
6862
63+definition :: String -> Src.LExpr -> Type.Type -> Src.Def
6964definition name expr tipe = Src.Definition (P.PVar name) expr (Just tipe)