[GHC] #16249: no runtime error for -fdefer-type-errors with TypeError constraint
GHC
ghc-devs at haskell.org
Thu Jan 31 13:51:12 UTC 2019
#16249: no runtime error for -fdefer-type-errors with TypeError constraint
-------------------------------------+-------------------------------------
Reporter: guibou | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.6.3
Resolution: | Keywords:
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 simonpj):
Hmm. The trouble here is that, at runtime the `TypeError` dictionary is
not actually used. I think we get something like this
{{{
data Foo t = MkFoo (t -> t)
foo :: Foo t -> t -> t
foo (MkFoo f) = f
$dfFooString :: TypeError (Text "String does not work") -> Foo String
-- Arises from the instance
$dfFooString d = MkFoo id
derr:: TypeError (Text "String does not work")
derr = error "String does not work"
x :: String
-- Haskell source code:
-- x = foo "hello"
x = foo ($dfFooString derr) "hello"
}}}
Evaluating `f` does not evaluate `derr`, hence the no-error run.
I suppose someone could think about evaluating calls to `TypeError` more
eagerly. But I'd be inclined to think that an easier path is to say
{{{
instance (TypeError (Text "String does not work")) => Foo String where
foo = error "String does not work"
}}}
I'm sure there is more than could be done to make `TypeError` better.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/16249#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list