diff --git a/sample-programs/mono-1.crf b/sample-programs/mono-1.crf index e682b7d..9c0a08f 100644 --- a/sample-programs/mono-1.crf +++ b/sample-programs/mono-1.crf @@ -1,5 +1,6 @@ -const x y = x; +const x y = x -f x = (const x 'c'); +f x = (const x 'c') + +main = f 5 -main = f 5; diff --git a/src/Monomorphizer/Monomorphizer.hs b/src/Monomorphizer/Monomorphizer.hs index 50f1bef..c0bd691 100644 --- a/src/Monomorphizer/Monomorphizer.hs +++ b/src/Monomorphizer/Monomorphizer.hs @@ -120,7 +120,7 @@ getMonoFromPoly t = do env <- ask -- Returns the annotated bind name. -- TODO: Redundancy? btype and t should always be the same. morphBind :: M.Type -> T.Bind -> EnvM Ident -morphBind expectedType b@(T.Bind (Ident _, btype) args (exp, expt)) = +morphBind expectedType b@(T.Bind (Ident str, btype) args (exp, expt)) = local (\env -> env { locals = Set.fromList (map fst args), polys = Map.fromList (mapTypes btype expectedType) }) $ do @@ -137,7 +137,7 @@ morphBind expectedType b@(T.Bind (Ident _, btype) args (exp, expt)) = -- Get monomorphic type sof args args' <- mapM convertArg args addOutputBind $ M.Bind (coerce name', expectedType) - args' (exp', expectedType) + args' (exp', expt') return name' convertArg :: (Ident, T.Type) -> EnvM (Ident, M.Type)