From d3d2c61dc6d8aae9fad7c3db2113e54602d815eb Mon Sep 17 00:00:00 2001 From: sebastianselander Date: Mon, 8 May 2023 21:50:34 +0200 Subject: [PATCH] more Justfile command and fixed bug in Monomorphizer --- Justfile | 8 +++++++- src/Main.hs | 4 ++-- src/Monomorphizer/Monomorphizer.hs | 5 ++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Justfile b/Justfile index a7acacd..3b9ac3c 100644 --- a/Justfile +++ b/Justfile @@ -32,4 +32,10 @@ hmdm FILE: cabal run language -- -d -t hm -m {{FILE}} bidm FILE: - cabal run language -- -d -t bi -m {{FILE}} \ No newline at end of file + cabal run language -- -d -t bi -m {{FILE}} + +hmp FILE: + cabal run language -- -t hm -d -p {{FILE}} + +bip FILE: + cabal run language -- -t bi -p {{FILE}} diff --git a/src/Main.hs b/src/Main.hs index e2a39d6..4f31cc7 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -82,7 +82,7 @@ disableGC :: Options -> Options disableGC opts = opts{gc = False} disablePrelude :: Options -> Options -disablePrelude opts = opts{preludeOpt = False} +disablePrelude opts = opts{preludeOpt = True} chooseTypechecker :: String -> Options -> Options chooseTypechecker s options = options{typechecker = tc} @@ -212,6 +212,6 @@ prelude = , " Cons x xs => flipConst (printChar x) (printStr xs)" , "\n" , "data List a where" - , " Cons : a -> List a -> List a" , " Nil : List a" + , " Cons : a -> List a -> List a" ] diff --git a/src/Monomorphizer/Monomorphizer.hs b/src/Monomorphizer/Monomorphizer.hs index c1fab1b..99925cc 100644 --- a/src/Monomorphizer/Monomorphizer.hs +++ b/src/Monomorphizer/Monomorphizer.hs @@ -45,6 +45,8 @@ import qualified LambdaLifterIr as L import Data.Maybe (fromJust, catMaybes) import Data.Tuple.Extra (secondM) +import Debug.Trace (trace) +import Test.QuickCheck.State (State(expected)) {- | EnvM is the monad containing the read-only state as well as the output state containing monomorphized functions and to-be monomorphized @@ -343,7 +345,8 @@ morphPattern p expectedType = case p of return $ Just ((M.PEnum newIdent, expectedType), Set.empty) L.PInj ident pts -> do let newIdent = newName expectedType ident ts' <- mapM (getMonoFromPoly . snd) pts - morphCons (convertConsTypeToDataType expectedType ts') ident newIdent + trace ("Constructor: " ++ show ident ++ "expected: " ++ show expectedType ++ "\nTS': " ++ show ts' ++ "\n\n\n") pure () + morphCons (convertConsTypeToDataType expectedType (reverse ts')) ident newIdent let pts' = zip (map fst pts) ts' psSets <- mapM (uncurry morphPattern) pts' let maybePsSets = sequence psSets