Change module prefixes for some values
This commit is contained in:
parent
c881bd8ef2
commit
b87e45a27d
1 changed files with 14 additions and 19 deletions
|
@ -5,22 +5,17 @@ import Control.Applicative ((<$>))
|
|||
|
||||
import qualified Data.Map as Map
|
||||
|
||||
import qualified Type.Type as T
|
||||
import qualified Type.Constrain.Expression as TcExpr
|
||||
import qualified Type.Environment as Env
|
||||
|
||||
import SourceSyntax.Declaration
|
||||
import qualified SourceSyntax.Location as SL
|
||||
import qualified SourceSyntax.Literal as SL
|
||||
import qualified SourceSyntax.Pattern as SP
|
||||
import qualified SourceSyntax.Expression as SE
|
||||
import qualified SourceSyntax.Type as ST
|
||||
import qualified SourceSyntax.Everything as Src
|
||||
import qualified SourceSyntax.Type as Type
|
||||
|
||||
|
||||
toExpr :: [Declaration t v] -> [SE.Def t v]
|
||||
toExpr :: [Declaration t v] -> [Src.Def t v]
|
||||
toExpr = concatMap toDefs
|
||||
|
||||
toDefs :: Declaration t v -> [SE.Def t v]
|
||||
toDefs :: Declaration t v -> [Src.Def t v]
|
||||
toDefs decl =
|
||||
case decl of
|
||||
Definition def -> [def]
|
||||
|
@ -29,24 +24,24 @@ toDefs decl =
|
|||
where
|
||||
toDefs (ctor, tipes) =
|
||||
let vars = take (length tipes) $ map (\n -> "_" ++ show n) [0..]
|
||||
loc = SL.none
|
||||
body = loc . SE.Data name $ map (loc . SE.Var) vars
|
||||
in [ SE.TypeAnnotation ctor $
|
||||
foldr ST.Lambda (ST.Data name $ map ST.Var tvars) tipes
|
||||
, SE.Def (SP.PVar ctor) $
|
||||
foldr (\p e -> loc $ SE.Lambda p e) body (map SP.PVar vars)
|
||||
loc = Src.none
|
||||
body = loc . Src.Data name $ map (loc . Src.Var) vars
|
||||
in [ Src.TypeAnnotation ctor $
|
||||
foldr Type.Lambda (Type.Data name $ map Type.Var tvars) tipes
|
||||
, Src.Def (Src.PVar ctor) $
|
||||
foldr (\p e -> loc $ Src.Lambda p e) body (map Src.PVar vars)
|
||||
]
|
||||
|
||||
-- Type aliases must be added to an extended equality dictionary,
|
||||
-- but they do not require any basic constraints.
|
||||
TypeAlias _ _ _ -> []
|
||||
|
||||
ImportEvent _ expr@(SL.L a b _) name tipe ->
|
||||
[ SE.TypeAnnotation name tipe
|
||||
, SE.Def (SP.PVar name) (SL.L a b $ SE.App (SL.L a b $ SE.Var "constant") expr) ]
|
||||
ImportEvent _ expr@(Src.L a b _) name tipe ->
|
||||
[ Src.TypeAnnotation name tipe
|
||||
, Src.Def (Src.PVar name) (Src.L a b $ Src.App (Src.L a b $ Src.Var "constant") expr) ]
|
||||
|
||||
ExportEvent _ name tipe ->
|
||||
[ SE.TypeAnnotation name tipe ]
|
||||
[ Src.TypeAnnotation name tipe ]
|
||||
|
||||
-- no constraints are needed for fixity declarations
|
||||
Fixity _ _ _ -> []
|
||||
|
|
Loading…
Reference in a new issue