Permalink
Browse files

+ Pattern matching compiler main module

  • Loading branch information...
1 parent c3cf268 commit dcc051d3f4d694eb4290cb50c0d129e4158f57d1 @Averethel committed Feb 10, 2013
Showing with 26 additions and 0 deletions.
  1. +26 −0 PatternMatching.hs
View
26 PatternMatching.hs
@@ -0,0 +1,26 @@
+{-# LANGUAGE
+ FlexibleContexts
+ #-}
+
+module PatternMatching (compilePatternMatching) where
+ import PatternMatching.Counters
+ import PatternMatching.NameWildcards
+ import PatternMatching.NumbersToIfs
+ import PatternMatching.ToCases
+ import PatternMatching.ToHandles
+ import PatternMatching.SimplifyHandles
+
+ import Control.Monad.State
+
+ import Syntax
+
+ matcherCompiler :: MonadState Counter m => Expr -> m Expr
+ matcherCompiler e = do
+ e1 <- nameWildcards e
+ e2 <- numbersToIfs e1
+ e3 <- functionsToHandles e2
+ e4 <- handlesToCases e3
+ return $ simplifyHandles e4
+
+ compilePatternMatching :: Expr -> Expr
+ compilePatternMatching e = fst $ runState (matcherCompiler e) emptyState

0 comments on commit dcc051d

Please sign in to comment.