1module Type.Constrain.Declaration where
4import Control.Applicative ((<$>))
6import qualified Data.Map as Map
8import qualified Type.Constrain.Expression as TcExpr
9import qualified Type.Environment as Env
11import SourceSyntax.Declaration
12import qualified SourceSyntax.Everything as Src
13import qualified SourceSyntax.Type as Type
15toExpr :: [Declaration t v] -> [Src.Def t v]
16toExpr = concatMap toDefs
18toDefs :: Declaration t v -> [Src.Def t v]
21 Definition def -> [def]
23 Datatype name tvars constructors -> concatMap toDefs constructors
25 toDefs (ctor, tipes) =
26 let vars = take (length tipes) $ map (:[]) ['a'..'z'] ++ map (\n -> "_" ++ show n) [1..]
28 body = loc . Src.Data ctor $ map (loc . Src.Var) vars
29 in [ Src.TypeAnnotation ctor $
30 foldr Type.Lambda (Type.Data name $ map Type.Var tvars) tipes
31 , Src.Def (Src.PVar ctor) $
32 foldr (\p e -> loc $ Src.Lambda p e) body (map Src.PVar vars)
35 -- Type aliases must be added to an extended equality dictionary,
36 -- but they do not require any basic constraints.
39 ImportEvent _ expr@(Src.L a b _) name tipe ->
40 [ Src.TypeAnnotation name tipe
41 , Src.Def (Src.PVar name) (Src.L a b $ Src.App (Src.L a b $ Src.Var "constant") expr) ]
43 ExportEvent _ name tipe ->
44 [ Src.TypeAnnotation name tipe ]
46 -- no constraints are needed for fixity declarations
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list