pure icon indicating copy to clipboard operation
pure copied to clipboard

Type signature support

Open myreen opened this issue 2 years ago • 2 comments

Type inferencer ignores type signatures. Example:

foo :: String -> Int -> UndefinedType -> [Bool]
foo i = ()

main = Ret (foo 1)

myreen avatar Jan 21 '23 12:01 myreen

The parser discards type signatures, as the cexp datatype does not support them. But inference runs on cexp and so cannot see type signatures. We will need to consider how to support type signatures through the frontend effectively, aside from upgrading inference to handle them. We could simply add type signatures to cexp, or consider something more involved.

hrutvik avatar Jan 21 '23 14:01 hrutvik

As discussed in a meeting, we have decided to keep the cexp datatype as-is and instead pass top-level signatures to inference alongside user-defined datatype/exception declaration information. Inference will need to be upgraded to use signatures correctly. Note that local type signatures can't be supported in this way.

This works well in the short-term, but as we support more features it will be cumbersome to continue passing extra information which does not fit into cexp to inference. We will need to re-think the design and usage of the AST and cexp datatypes.

hrutvik avatar Jan 24 '23 10:01 hrutvik