Error in generated Haskell code for functions whose name starts with `ListX`
inariksit opened this issue · 0 comments
inariksit commented
Here's my example code (abstract syntax is enough):
abstract Mini = {
cat
CN ;
[CN]{2} ;
fun
dog : CN ;
rabbit : CN ;
ListCN2CN : ListCN -> CN ; -- This fails
myConjCN : ListCN -> CN ; -- This succeeds
}
I have my own custom functions from lists to non-list categories, and if I name them like ListX2Y
(no matter if X and Y are same or different), then the Compos
instance in the generated Haskell code for that function is wrong. Here's the code, generated with
gf -make -f haskell --haskell=gadt Mini.gf
:
instance Compos Tree where
compos r a f t = case t of
-- This is the same as the Haskell convenience constructor GListCN, but has a different type.
-- So the line below is a type error.
GListCN2CN x1 -> r GListCN2CN `a` foldr (a . a (r (:)) . f) (r []) x1
-- This is correct, and how the previous line should be.
GmyConjCN x1 -> r GmyConjCN `a` f x1
-- This is also correct, type signature of GListCN is [GCN] -> GListCN
GListCN x1 -> r GListCN `a` foldr (a . a (r (:)) . f) (r []) x1
_ -> r t
So it seems that the Haskell code generator is just checking for a prefix, not the full name of the function.