Commit f5f1aa32 authored by Kai-Oliver Prott's avatar Kai-Oliver Prott

Simplify generator code

parent ede37194
......@@ -326,8 +326,7 @@ trAFuncDecl (IL.ExternalDecl f ty) = do
a <- getArity f
vis <- getVisibility f
ty' <- trType ty
r' <- trAExternal ty f
return [AFunc f' a vis ty' r']
return [AFunc f' a vis ty' (AExternal ty' (qualName f))]
trAFuncDecl _ = return []
-- Translate a function rule.
......@@ -338,9 +337,6 @@ trARule ty vs e = withFreshEnv $ ARule <$> trType ty
<*> mapM (uncurry newVar) vs
<*> trAExpr e
trAExternal :: IL.Type -> QualIdent -> FlatState (ARule TypeExpr)
trAExternal ty f = flip AExternal (qualName f) <$> trType ty
-- Translate an expression
trAExpr :: IL.Expression -> FlatState (AExpr TypeExpr)
trAExpr (IL.Literal ty l) = ALit <$> trType ty <*> trLiteral l
......@@ -487,7 +483,7 @@ instance Normalize a => Normalize (ARule a) where
normalize (AExternal ty s) = flip AExternal s <$> normalize ty
normalizeTuple :: Normalize b => (a, b) -> NormState (a, b)
normalizeTuple (a, b) = (,) <$> pure a <*> normalize b
normalizeTuple (a, b) = (,) <$> pure a <*> normalize b
instance Normalize a => Normalize (AExpr a) where
normalize (AVar ty v) = flip AVar v <$> normalize ty
......
......@@ -325,8 +325,7 @@ trTFuncDecl (IL.ExternalDecl f ty) = do
a <- getArity f
vis <- getVisibility f
ty' <- trType ty
r' <- trTExternal ty f
return [TFunc f' a vis ty' r']
return [TFunc f' a vis ty' (TExternal ty' (qualName f))]
trTFuncDecl _ = return []
-- Translate a function rule.
......@@ -336,9 +335,6 @@ trTRule :: [(IL.Type, Ident)] -> IL.Expression
trTRule vs e = withFreshEnv $ TRule <$> mapM (uncurry newVar) vs
<*> trTExpr e
trTExternal :: IL.Type -> QualIdent -> FlatState TRule
trTExternal ty f = flip TExternal (qualName f) <$> trType ty
-- Translate an expression
trTExpr :: IL.Expression -> FlatState TExpr
trTExpr (IL.Literal ty l) = TLit <$> trType ty <*> trLiteral l
......@@ -482,8 +478,8 @@ instance Normalize TRule where
normalize (TExternal ty s) = flip TExternal s <$> normalize ty
normalizeVar :: (VarIndex, TypeExpr) -> NormState (VarIndex, TypeExpr)
normalizeVar (v, ty) = (,) <$> pure v <*> normalize ty
normalizeVar (v, ty) = (,) <$> pure v <*> normalize ty
instance Normalize TExpr where
normalize (TVarE ty v) = flip TVarE v <$> normalize ty
normalize (TLit ty l) = flip TLit l <$> normalize ty
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment