[GHC] #7495: generalizing overloaded list syntax to Sized Lists, HLists, HRecords, etc

GHC ghc-devs at haskell.org
Thu Dec 6 07:35:24 UTC 2018


#7495: generalizing overloaded list syntax to Sized Lists, HLists, HRecords, etc
-------------------------------------+-------------------------------------
        Reporter:  nwf               |                Owner:  carter
            Type:  feature request   |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  7.6.1
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:  9883
 Related Tickets:  #9883             |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------
Changes (by int-index):

 * cc: int-index (added)


Comment:

 Lovely design in comment:11. I don't think anything stops us from
 extending it to support pattern matching and ranges by adding more classes
 for these features.

 Another use case that I have in mind is `NonEmpty`. As it stands, using it
 with `OverloadedLists` is unsafe, as `[]` will fail at run-time instead of
 compile-time.

 With the design of comment:11 we could do this:

 {{{#!hs
 instance Cons (NonEmpty a) where
     type Head (NonEmpty a) = a
     type Tail (NonEmpty a) = [a]
     cons = (:|)

 instance TypeError ... => Nil (NonEmpty a)
 }}}

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


More information about the ghc-tickets mailing list