[GHC] #10447: DeriveFoldable rejects instances with constraints in last argument of data type

GHC ghc-devs at haskell.org
Mon Jun 1 09:06:38 UTC 2015


#10447: DeriveFoldable rejects instances with constraints in last argument of data
type
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                   Owner:
            Type:  bug               |                  Status:  new
        Priority:  normal            |               Milestone:
       Component:  Compiler          |                 Version:  7.10.1
      Resolution:                    |                Keywords:
Operating System:  Unknown/Multiple  |            Architecture:
 Type of failure:  GHC rejects       |  Unknown/Multiple
  valid program                      |               Test Case:
      Blocked By:                    |                Blocking:
 Related Tickets:  #8678             |  Differential Revisions:
-------------------------------------+-------------------------------------

Comment (by simonpj):

 This is interesting, but I lack the bandwidth to follow it in detail.

 I urge against a design that requires the programmer to predict the
 behaviour of the constraint solver in order to decide what code the
 "deriving" will generate.  I think it's be much better to say that it
 depends on the syntactic form of the declaration.  So for `MkT1` and
 `MkT3` you'd get the first argument included in the fold, but for `MkT2`
 you would not.

 You need to think what to do about cases like this:
 {{{
 data S a where
   MKS :: b -> c -> S (b,c)
 }}}
 Perhaps y'all can work out a design, document it on a wiki page, and even
 implement it.  (I can advise.)

 I'd really love the same page to document the behaviour of deriving for
 `Functor` and `Traversable` too!

 Many thanks

 Simon

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10447#comment:15>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list