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

Code generated for non-regular recursive types does not typecheck #3

Open
frerich opened this issue Jun 4, 2015 · 1 comment
Open
Labels

Comments

@frerich
Copy link
Owner

frerich commented Jun 4, 2015

Using catamorphism 0.5.0.1, the following program fails to compile:

{-# LANGUAGE TemplateHaskell #-}
import Data.Morphism.Cata

data List a = Empty | Cons a (List (List a))

$(makeCata defaultOptions ''List)

main = return ()

The makeCata invocation generates code yielding the error message

treecata.hs:6:3:
    Couldn't match type ‘a1’ with ‘List a1’
      ‘a1’ is a rigid type variable bound by
           the type signature for list :: a -> (a1 -> a -> a) -> List a1 -> a
           at treecata.hs:6:3
    Expected type: List a1
      Actual type: List (List a1)
    Relevant bindings include
      a_a2p8 :: List (List a1) (bound at treecata.hs:6:3)
      a_a2p7 :: a1 (bound at treecata.hs:6:3)
      x_a2p6 :: List a1 (bound at treecata.hs:6:3)
      c_a2p5 :: a1 -> a -> a (bound at treecata.hs:6:3)
      list :: a -> (a1 -> a -> a) -> List a1 -> a
        (bound at treecata.hs:6:3)
    In the third argument of ‘list’, namely ‘a_a2p8’
    In the second argument of ‘c_a2p5’, namely
      ‘list c_a2p4 c_a2p5 a_a2p8’
@frerich frerich added the bug label Jun 4, 2015
@frerich frerich changed the title Code generated for 'data List a = Empty | Cons a List (List a)' doesn't typecheck Code generated for non-regular recursive types does not typecheck Nov 28, 2016
@frerich
Copy link
Owner Author

frerich commented Nov 28, 2016

The answers to my question on StackOverflow suggest that this is actually quite tricky.

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

No branches or pull requests

1 participant