[Haskell-cafe] Re: Re: Haskell Propeganda
Ben Franksen
ben.franksen at online.de
Mon Aug 25 15:22:53 EDT 2008
Don Stewart wrote:
> ashley:
>> Thomas Davie wrote:
>> >I'd be interested to see your other examples -- because that error is
>> >not happening in Haskell! You can't argue that Haskell doesn't give you
>> >no segfaults, because you can embed a C segfault within Haskell.
>>
>> This segfaults on my x86_64 Linux box:
>>
>> module Main where
>> import Data.Typeable
>> import Data.IORef
>> data T = T
>> instance Typeable T where
>> typeOf _ = typeOf (undefined :: IORef ())
>> main :: IO ()
>> main = writeIORef (maybe undefined id (cast T)) ()
>>
>> You'll note nothing marked "Foreign" or "unsafe", and only the base
>> library used. Does the segfault "happen in Haskell" or not?
>
> You just wrote unsafeCoere# a different way:
>
> typeOf T = typeOf (undefined :: IORef ())
>
> Manual Typeable deriving should probably be disabled :-)
But then we need stand-alone deriving clause, otherwise you are lost if
someone didn't derive Typeable in her library. We need stand-alone deriving
anyway.
Cheers
Ben
More information about the Haskell-Cafe
mailing list