more Justfile command and fixed bug in Monomorphizer

This commit is contained in:
sebastianselander 2023-05-08 21:50:34 +02:00
parent 23f4e3365a
commit d3d2c61dc6
3 changed files with 13 additions and 4 deletions

View file

@ -32,4 +32,10 @@ hmdm FILE:
cabal run language -- -d -t hm -m {{FILE}}
bidm FILE:
cabal run language -- -d -t bi -m {{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}}

View file

@ -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"
]

View file

@ -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