No subject
Sun Oct 23 10:51:38 CEST 2011
byte-code is used insted of object-code.
If what matter here is "to get same result in ghci and compiled code",
invoking ghci with object code compilation option[1] may help. E.g.
start ghci with:
$ ghci -fobject-code
Below is a sample session with your code. I saved it as "UCSN.hs".
$ ls
UCSN.hs
$ ghc-7.4.1 --interactive UCSN.hs
GHCi, version 7.4.1: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
[1 of 1] Compiling UCSN ( UCSN.hs, interpreted )
Ok, modules loaded: UCSN.
ghci> :main
type enter
False
ghci> :q
Leaving GHCi.
Invoking again, with "-fobject-code". Note the absense of "interpreted" mes=
sage:
$ ghc-7.4.1 --interactive -fobject-code UCSN.hs
GHCi, version 7.4.1: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
[1 of 1] Compiling UCSN ( UCSN.hs, UCSN.o )
Ok, modules loaded: UCSN.
ghci> :main
type enter
True
ghci> :q
Leaving GHCi.
Now we have "UCSN.hi" and "UCSN.o".
$ ls
UCSN.hi UCSN.hs UCSN.o
Invoking ghci again, without "-fobject-code".
No "interpreted" message. Showing 'True' with main.
$ ghc-7.4.1 --interactive UCSN.hs
GHCi, version 7.4.1: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Ok, modules loaded: UCSN.
ghci> :main
type enter
True
ghci> :q
Leaving GHCi.
Hope these help.
[1]: http://www.haskell.org/ghc/docs/latest/html/users_guide/options-phases=
.html#options-codegen
Regards,
--
Atsuro
On Thu, Jun 28, 2012 at 6:41 AM, Facundo Dom=EDnguez
<facundominguez at gmail.com> wrote:
> Hi,
> The program below when loaded in ghci prints always False, and when
> compiled with ghc it prints True. I'm using ghc-7.4.1 and I cannot
> quite explain such behavior. Any hints?
>
> Thanks in advance,
> Facundo
>
> {-# LANGUAGE GADTs #-}
> import System.Mem.StableName
> import Unsafe.Coerce
> import GHC.Conc
>
> data D where
> D :: a -> b -> D
>
> main =3D do
> putStr "type enter"
> s <- getLine
> let i =3D fromEnum$ head$ s++"0"
> d =3D D i i
> case d of
> D a b -> do
> let a' =3D a
> sn0 <- pseq a'$ makeStableName a'
> sn1 <- pseq b$ makeStableName b
> print (sn0=3D=3DunsafeCoerce sn1)
>
> _______________________________________________
> Glasgow-haskell-users mailing list
> Glasgow-haskell-users at haskell.org
> http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
More information about the Glasgow-haskell-users
mailing list