[GHC] #10796: Illegal data constructor name: `fromList' ... When splicing a TH expression

GHC ghc-devs at haskell.org
Wed Aug 26 12:41:02 UTC 2015


#10796: Illegal data constructor name: `fromList' ... When splicing a TH expression
-------------------------------------+-------------------------------------
        Reporter:  erisco            |                   Owner:
            Type:  bug               |                  Status:  new
        Priority:  normal            |               Milestone:
       Component:  Template Haskell  |                 Version:  7.8.3
      Resolution:                    |                Keywords:
Operating System:  Windows           |            Architecture:  x86_64
                                     |  (amd64)
 Type of failure:  None/Unknown      |               Test Case:
      Blocked By:                    |                Blocking:
 Related Tickets:                    |  Differential Revisions:
-------------------------------------+-------------------------------------

Comment (by goldfire):

 A little poking through shows me that this is an infelicity in the
 containers library. The splice above calls
 `Language.Haskell.TH.Quote.dataToQa`, which performs lifting (in the sense
 of TH's `lift` operation and `Lift` class) based on a `Data` instance. The
 data involved includes a `Data.Set.Set`. And `Set`'s `Data` instance
 reads, in part

 {{{
 instance (Data a, Ord a) => Data (Set a) where
   toConstr _     = fromListConstr

 fromListConstr :: Constr
 fromListConstr = mkConstr setDataType "fromList" [] Prefix
 }}}

 Note that the "constructor" is named `fromList`. But this is a lie, of
 course. It's done to preserve abstraction, which is a laudable goal, so
 I'm not calling it a bug.

 An easy solution here would be to generalize `dataToQa` to check if it's
 given a data constructor or just a function and react accordingly. It
 really should be getting a constructor, but there seems to be no harm in
 allowing `Data` instances to lie like this and continue gracefully.

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


More information about the ghc-tickets mailing list