Wired-in type class

Joachim Breitner mail at joachim-breitner.de
Sun Aug 18 22:40:13 CEST 2013


Hi,

Am Sonntag, den 18.08.2013, 21:54 +0200 schrieb Gabor Greif:

> There is also user-supplied Typeable instances which are ignored (with
> a warning?).

at least no Typeabe-specific warning:

Prelude> newtype Age = Age Int
Prelude> instance Typeable Age
Prelude> :m + Data.Typeable
Prelude Data.Typeable> instance Typeable Age

<interactive>:5:10: Warning:
    No explicit method or default declaration for `typeOf'
    In the instance declaration for `Typeable Age'

It seems that GHC does prevent it in Safe mode, though:

       -- Check that if the module is compiled with -XSafe, there are no
       -- hand written instances of old Typeable as then unsafe casts could be
       -- performed. Derived instances are OK.
       ; when (safeLanguageOn dflags) $
             mapM_ (\x -> when (typInstCheck x)
                               (addErrAt (getSrcSpan $ iSpec x) typInstErr))
                   local_infos
(compiler/typecheck/TcInstDcls.lhs)

Greetings,
Joachim


-- 
Joachim “nomeata” Breitner
  mail at joachim-breitner.dehttp://www.joachim-breitner.de/
  Jabber: nomeata at joachim-breitner.de  • GPG-Key: 0x4743206C
  Debian Developer: nomeata at debian.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
URL: <http://www.haskell.org/pipermail/ghc-devs/attachments/20130818/7ecd48ed/attachment.pgp>


More information about the ghc-devs mailing list