[Haskell-cafe] Endian conversion

Joel Reymont joelr1 at gmail.com
Thu Oct 6 15:42:34 EDT 2005


Solution by TheHunter on #haskell:

be = $(lift $ (1::CChar) /= (unsafePerformIO
                             $ with (1::CInt)
                             $ peekByteOff `flip` 0) ) :: Bool

     Thanks, Joel

On Oct 6, 2005, at 9:13 PM, Joel Reymont wrote:

> Why doesn't this compile?
>
> be = $( (1::CChar) /= (unsafePerformIO
>                       $ with (1::CInt)
>                       $ peekByteOff `flip` 0) ) :: Bool
>
> Endian.hs:10:8:
>     Couldn't match `Language.Haskell.TH.Lib.ExpQ' against `Bool'
>       Expected type: Language.Haskell.TH.Lib.ExpQ
>       Inferred type: Bool
>     In the expression:
>         (1 :: CChar)
>         /= (unsafePerformIO $ ((with (1 :: CInt)) $ (peekByteOff  
> `flip` 0)))
>     In the expression:
>           $[splice]((1 :: CChar)
>                     /= (unsafePerformIO $ ((with (1 :: CInt)) $  
> (peekByteOff `flip` 0)))) ::
>             Bool

--
http://wagerlabs.com/idealab







More information about the Haskell-Cafe mailing list