Closed shlevy closed 3 years ago
Thanks.
My suggestion would be to generalize Exp
in CF.hs
to
type Exp = Exp' String
data Exp' f
= App f [Exp] -- ^ (Possibly defined) label applied to expressions.
| Var String -- ^ Function parameter.
| LitInt Integer
| LitDouble Double
| LitChar Char
| LitString String
deriving (Eq, Functor)
Then replace, in the C backend, []
by Null
and (:)
by the respective make_ListXXX
, using fmap
. (Btw. there is isNilFun
and isConsFun
to check for these special labels.)
This is likely still not enough, we need to have the list type XXX
. This could be saved in the TypeChecker.hs
, producing a Exp' (String,Cat)
remembering the target type of the App f es
. Spinning this further, the Cat
is only needed for list constructors, so maybe Exp' Label
would be sufficient where
data Label
= OrdinaryLabel String
| NilLabel Cat -- ^ []
| ConsLabel Cat -- ^ (:)
| OneLabel Cat -- ^ (:[])
Makes sense, will try to carve out some time!
I fixed this problem in a way similar as I wrote in the comment. Mainly, we remember the typing information from the type checker, so we
Awesome! Sorry this sat for so long, I only have a little time here and there to work on the project using BNFC at the moment. Hopefully will be able to pick up the rust backend soon!
Yeah, looking forward to the Rust backend!
If you find any more bugs, do not hesitate to report them! (Trying to understand how things work is the best way to discover bugs...)
Part of #363.