[GHC] #13833: Instances with GHC.TypeLits.Nat/Symbol should be possible without FlexibleInstances.

GHC ghc-devs at haskell.org
Fri Jun 16 07:32:58 UTC 2017


#13833: Instances with GHC.TypeLits.Nat/Symbol should be possible without
FlexibleInstances.
-------------------------------------+-------------------------------------
           Reporter:  Hjulle         |             Owner:  (none)
               Type:  bug            |            Status:  new
           Priority:  low            |         Milestone:
          Component:  Compiler       |           Version:  8.0.2
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 Yes I know, `0` and `"B"` are not technically type constructors, but it's
 as close as you can get for the kinds Nat and Symbol.

 Test cases:
 {{{#!hs
 {-# LANGUAGE DataKinds, KindSignatures #-}

 import GHC.TypeLits (Nat, Symbol)

 class A (n::Nat)
 instance A 0

 class B (s::Symbol)
 instance B "B"

 }}}
 Result:
 {{{
 A.hs:6:10: error:
     • Illegal instance declaration for ‘A 0’
         (All instance types must be of the form (T a1 ... an)
          where a1 ... an are *distinct type variables*,
          and each type variable appears at most once in the instance head.
          Use FlexibleInstances if you want to disable this.)
     • In the instance declaration for ‘A 0’

 A.hs:9:10: error:
     • Illegal instance declaration for ‘B "B"’
         (All instance types must be of the form (T a1 ... an)
          where a1 ... an are *distinct type variables*,
          and each type variable appears at most once in the instance head.
          Use FlexibleInstances if you want to disable this.)
     • In the instance declaration for ‘B "B"’

 }}}

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


More information about the ghc-tickets mailing list