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

GHC ghc-devs at haskell.org
Fri Sep 11 08:42:43 UTC 2015


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

 * differential:   => Phab:D1236


Old description:

> When doing type level programming you often need a way to report errors.
> I suggest a closed type family called Error with special semantics.
> It is kinded like this Error :: Symbol -> k1 -> k2
>
> If this function has to be reduced during constraint solving it will
> simply generate a type error with the given string and printing the type
> as extra information (this kind can be generalized a lot if we want to).
>
> I've found that having this function gives more accurate and earlier
> error messages.

New description:

 When doing type level programming you often need a way to report errors.
 I suggest a closed type family called Error with special semantics.
 It is kinded like this Error :: Symbol -> k1 -> k2

 If this function has to be reduced during constraint solving it will
 simply generate a type error with the given string and printing the type
 as extra information (this kind can be generalized a lot if we want to).

 I've found that having this function gives more accurate and earlier error
 messages.

 Wiki design page: [wiki:CustomTypeErros]

--

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


More information about the ghc-tickets mailing list