diprism / perpl

The PERPL Compiler
MIT License
10 stars 5 forks source link

Nested recursive datatype error #134

Closed colin-mcd closed 1 year ago

colin-mcd commented 1 year ago

Nested recursive datatypes like the following cause errors during monomorphization:

data List a = Nil | Cons a (List a);
data Matrix a = Mx (List (List a));
let _ = Mx (Cons (Cons () Nil) Nil) in ();

Specifically, the error gets raised by the Map.! in this line: https://github.com/diprism/perpl/blob/73f88eef5d18ff63fda7d9be9f118db33868437e/src/Transform/Monomorphize.hs#L108

From early investigation, it looks like there is some lack of substitution going on in arguments of nested polymorphic datatypes.