[GHC] #9637: Type level programming needs an error function

GHC ghc-devs at haskell.org
Wed Oct 1 13:20:24 UTC 2014


#9637: Type level programming needs an error function
-------------------------------------+-------------------------------------
              Reporter:  augustss    |            Owner:
                  Type:  feature     |           Status:  new
  request                            |        Milestone:
              Priority:  normal      |          Version:  7.8.3
             Component:  Compiler    |         Keywords:
            Resolution:              |     Architecture:  Unknown/Multiple
      Operating System:              |       Difficulty:  Unknown
  Unknown/Multiple                   |       Blocked By:
       Type of failure:              |  Related Tickets:
  None/Unknown                       |
             Test Case:              |
              Blocking:              |
Differential Revisions:              |
-------------------------------------+-------------------------------------

Comment (by augustss):

 Here's a real example:

 {{{#!hs
 type F_NoDups (t :: FieldSet) :: FieldSet =
     Assert "Type has duplicate labels:\n  " (Not (F_HasDups t)) t

 type family Assert (msg :: Symbol) (a :: Bool) (b :: k) :: k where
      Assert msg True  x = x
      Assert msg False x = Error (msg `ErrorAnd` x)
 }}}

 And here's a sample error message:
 {{{
 RunMu.exe: Cortex: Cortex.Stem.Relation.Test.Typed:21:1: Type error:
 Type has duplicate labels:
   Cortex.Stem.Relation.Types.FS
     ("A" ::: String : "B" ::: Bool : "B" ::: Bool : "C" ::: () :
 Data.TypeLevel.Nil)
 }}}

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


More information about the ghc-tickets mailing list