@@ -17,14 +17,14 @@ import Model
1717
1818
1919haskellCode :: String -> TypedTerm String String -> String
20- haskellCode name tm = case haskellCode' tm of
20+ haskellCode fnName tm = case haskellCode' tm of
2121 { i, o, code } -> typeDecl <> args <> indent (" \n " <> arr (tuple $ foldMap singleton i) (showNested i) `comp` code `comp` arr (showNested o) (tuple $ foldMap singleton o))
2222 where
23- gens = tm # foldMap \{ decl, bid } -> case decl of
24- Gen ty -> Map .singleton bid ty
23+ gens = tm # foldMap \{ decl, name } -> case decl of
24+ Gen ty -> Map .singleton name ty
2525 otherwise -> Map .empty
26- args = if length gens > 0 then name <> " " <> toLower (intercalate " " $ Map .keys gens) <> " = " else " "
27- typeDecl = name <>
26+ args = if length gens > 0 then fnName <> " " <> toLower (intercalate " " $ Map .keys gens) <> " = " else " "
27+ typeDecl = fnName <>
2828 " \n :: Arrow arr" <>
2929 " \n => " <> intercalate " \n -> " (showTy <$> Map .values gens) <>
3030 " \n -> " <> showTy (getAnn tm) <>
@@ -39,7 +39,7 @@ haskellEmpty = { i: liftF [], o: liftF [], code: "returnA" }
3939haskellCode' :: TypedTerm String String -> HaskellCode
4040haskellCode' = foldFix \(Ann _ f) -> alg f where
4141 alg TUnit = haskellEmpty
42- alg (TBox { bid , decl }) = case decl of
42+ alg (TBox { name , decl }) = case decl of
4343 Perm perm -> perm # foldMapWithIndex (\i p -> [" a" <> show i] /\ [" a" <> show (p - 1 )] ) #
4444 \(i /\ o) -> { i: liftF i, o: liftF o, code: arr (tuple i) (tuple o) }
4545 Spider _ l r -> { i: liftF i, o: liftF o, code: arr (tuple i) out }
@@ -52,7 +52,7 @@ haskellCode' = foldFix \(Ann _ f) -> alg f where
5252 Gen (Ty i o) ->
5353 { i: liftF $ foldMapWithIndex (\j n -> [toLower n <> show j]) i
5454 , o: liftF $ foldMapWithIndex (\j n -> [toLower n <> show j]) o
55- , code: toLower bid }
55+ , code: name }
5656 Cup -> { i: liftF [] , o: liftF [" a0" , " a1" ], code: " cup" }
5757 Cap -> { i: liftF [" a0" , " a1" ], o: liftF [] , code: " cap" }
5858 alg (TC ts) = ts # unsnoc # maybe haskellEmpty (\{ init, last } -> foldr compose last init) # mapCode braced
0 commit comments