Permalink
Browse files

Typed compiler pipeline!

  • Loading branch information...
1 parent 0bb0eee commit 2cfeaa35475a9cc7be4bc02b5e3914bb94020757 Sebastiaan Visser committed Dec 20, 2009
@@ -5,15 +5,15 @@
, DeriveFoldable
, DeriveTraversable
#-}
-module Compiler.Raw where
+module Compiler.Expr where
import Compiler.Generics
import Control.Monad.State
import Data.Foldable hiding (elem, mapM_, concatMap, concat, foldr)
import Data.Traversable hiding (mapM)
import Prelude hiding (lookup)
--- Raw value datatype.
+-- Expression datatype.
type Con = String
type Name = String
@@ -10,7 +10,7 @@ module Compiler.FreeVariables
where
import Compiler.Generics
-import Compiler.Raw
+import Compiler.Expr
import Control.Arrow hiding (app)
import Data.List (intercalate)
import Data.Set hiding (map, insert)
@@ -1,7 +1,7 @@
module Compiler.InstantiateLambdas (instantiate, dump) where
import Compiler.Generics
-import Compiler.Raw
+import Compiler.Expr
import Control.Applicative
import Control.Arrow hiding (app)
import Control.Monad.Reader
@@ -3,7 +3,7 @@ module Compiler.LiftClosedApplications (lift) where
import Compiler.FreeVariables (DefinitionsFV, FreeVarA (..))
import Compiler.Generics
import Compiler.LiftDefinitions (DefinitionA (..), DefinitionsA (..), Definition, Definitions)
-import Compiler.Raw
+import Compiler.Expr
import Control.Applicative
import Control.Arrow hiding (app)
import Control.Monad.State hiding (lift)
@@ -10,7 +10,7 @@ module Compiler.LiftDefinitions
where
import Compiler.Generics
-import Compiler.Raw
+import Compiler.Expr
import Control.Arrow hiding (app)
import Data.List (intercalate, nubBy)
@@ -7,7 +7,7 @@ where
import Control.Monad.State
import Control.Applicative
import Compiler.Generics
-import Compiler.Raw
+import Compiler.Expr
import Compiler.FreeVariables
import Control.Arrow hiding (app)
import qualified Data.Set as S
View
@@ -3,17 +3,22 @@ module Compiler.Pipeline where
import Control.Arrow
import Lang.Value (Val)
+import Compiler.Expr
+import Compiler.FreeVariables (DefinitionsFV)
+import Compiler.LiftDefinitions (Definitions)
import qualified Compiler.InstantiateLambdas as Lambdas
import qualified Compiler.FreeVariables as FreeVariables
import qualified Compiler.LiftClosedApplications as ClosedApplications
import qualified Compiler.LiftDefinitions as Definitions
+type a :-> b = Kleisli IO a b
+
compiler :: Val l i -> IO String
compiler = runKleisli
- $ Lambdas.instantiate
- >>> Definitions.lift
- >>> Definitions.eliminiateDoubles
- >>> FreeVariables.annotateDefinitions
- >>> ClosedApplications.lift
- >>> Definitions.dump
+ $ ( Lambdas.instantiate :: Val l i :-> Expr )
+ >>> ( Definitions.lift :: Expr :-> Definitions )
+ >>> ( Definitions.eliminiateDoubles :: Definitions :-> Definitions )
+ >>> ( FreeVariables.annotateDefinitions :: Definitions :-> DefinitionsFV )
+ >>> ( ClosedApplications.lift :: DefinitionsFV :-> Definitions )
+ >>> ( Definitions.dump :: Definitions :-> String )
@@ -4,7 +4,7 @@ First, we will start of with the module header and some imports.
> import Compiler.Generics
> import Control.Arrow hiding (app)
-> import Compiler.Raw
+> import Compiler.Expr
> import qualified Data.Set as S
> import Control.Monad.State

0 comments on commit 2cfeaa3

Please sign in to comment.