Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in generated Haskell code for functions whose name starts with ListX #163

Open
inariksit opened this issue Nov 2, 2023 · 0 comments

Comments

@inariksit
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant