[GHC] #12048: Allow CustomTypeErrors in type synonyms (+ evaluate nested type family?)
GHC
ghc-devs at haskell.org
Wed Oct 12 14:00:45 UTC 2016
#12048: Allow CustomTypeErrors in type synonyms (+ evaluate nested type family?)
-------------------------------------+-------------------------------------
Reporter: Iceland_jack | Owner: diatchki
Type: feature request | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.1
Resolution: | Keywords:
| CustomTypeErrors
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by andrewthad):
Just to add information about my current workaround, the example given can
be rewritten to use a type family instead:
{{{#!hs
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
import GHC.TypeLits
import Data.Kind
-- Works just like a type synonym
type family Fail where
Fail = TypeError (Text "It failed")
type family Bad a where
Bad a = TypeError (Text "It messed up on " :<>: Text (Whoami a))
type family
Whoami (ty :: Type) :: Symbol where
Whoami Int = "a number"
Whoami Float = "a number"
Whoami [_] = "a list of things"
Whoami _ = "something else"
expr :: Bad [Bool]
expr = 5
main :: IO ()
main = putStrLn "Hello"
}}}
Everyone on this ticket is probably already aware of this, but I just
wanted to document it for passersby like myself who may be less familiar
with the issue.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12048#comment:6>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list