
machine: Sun Sparc, with SunOS 5.10 ghc version --- 6.8.2 [ solaris-binaries downloaded from ghc site ] The Question: I compiled the code: putStr "Hello World!\n" ghc -o hello -L../lib hello.hs where ../lib contains the libgmp.so The resulting binary code size is 3.9 Mbytes I had the impression that it should be of the order of 500 Kbytes. How can I reach that number ? Thanks HP

Hello HP, Tuesday, May 6, 2008, 11:00:59 PM, you wrote:
The resulting binary code size is 3.9 Mbytes I had the impression that it should be of the order of 500 Kbytes. How can I reach that number ?
strip executable. you can just add -optl-s to ghc cmdline -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com

hi Bulat, thanks for the speedy reply! I tried the following two ways and got the same result: (1) in the shell, strip hello (2) ghc -optl-s -o hello -L../lib hello.hs They both result in a binary size of ~2.5MBytes, which is about 5 times what I expected (500kbytes). Have I had the 'incorrect impression' of 500kbytes ? Thanks hp On Tue, 6 May 2008, Bulat Ziganshin wrote:
Hello HP,
Tuesday, May 6, 2008, 11:00:59 PM, you wrote:
The resulting binary code size is 3.9 Mbytes I had the impression that it should be of the order of 500 Kbytes. How can I reach that number ?
strip executable. you can just add -optl-s to ghc cmdline
-- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com

Hello HP, Tuesday, May 6, 2008, 11:26:10 PM, you wrote: my haskell-fu ends here :) on win32 platform, hello is about 600k, afair
hi Bulat, thanks for the speedy reply!
I tried the following two ways and got the same result:
(1) in the shell, strip hello (2) ghc -optl-s -o hello -L../lib hello.hs
They both result in a binary size of ~2.5MBytes, which is about 5 times what I expected (500kbytes).
Have I had the 'incorrect impression' of 500kbytes ?
Thanks hp
On Tue, 6 May 2008, Bulat Ziganshin wrote:
Hello HP,
Tuesday, May 6, 2008, 11:00:59 PM, you wrote:
The resulting binary code size is 3.9 Mbytes I had the impression that it should be of the order of 500 Kbytes. How can I reach that number ?
strip executable. you can just add -optl-s to ghc cmdline
-- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com
-- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com

I convinced myself that the ~500kbytes for the 'hello' code is 'correct' in version 6.6.1. [ The exact size on the platform mentioned below is 422k. ] Looks like version 6.8.2 blows up the binary code size significantly --- 3.9Mbytes vs 0.422Mbytes. Is this a known issue with 6.8.2 ? Is it a specific platform dependent issue --- i.e. does it occur on linux machines ?? --hp On Tue, 6 May 2008, HP Wei wrote:
machine: Sun Sparc, with SunOS 5.10 ghc version --- 6.8.2 [ solaris-binaries downloaded from ghc site ]
The Question:
I compiled the code: putStr "Hello World!\n" ghc -o hello -L../lib hello.hs where ../lib contains the libgmp.so
The resulting binary code size is 3.9 Mbytes I had the impression that it should be of the order of 500 Kbytes. How can I reach that number ?
Thanks HP

I cut and paste the code from http://blog.moertel.com/articles/2004/03/13/concurrent-port-scanner-in-haske... And compiled the resulting portscan.hs with both ghc-6.8.2 and ghc-6.6.1 on a host with Sun-Sparc [SunOS 5.10]. Besides the issue of binary-code-size blow-up with ghc-6.8.2, there is a much more serious problem with codes compiled from both 6.8.2 and 6.6.1. Here is the output of two runs. ------------------------------------------- portscan a_remote_sun_sparc_machine 1 1000 portscan: internal error: getMBlock: mmap: Bad file number (GHC version 6.6.1 for sparc_sun_solaris2) Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug Abort [ note: same result for 6.8.2 ] ---------------------------------------- portscan a_remote_linux_machine 1 1000 22 ssh 111 sunrpc 513 login 514 shell 631 ------------------------------------------ Anyone knows this problem ? --hp

HP Wei wrote:
I cut and paste the code from http://blog.moertel.com/articles/2004/03/13/concurrent-port-scanner-in-haske...
And compiled the resulting portscan.hs with both ghc-6.8.2 and ghc-6.6.1 on a host with Sun-Sparc [SunOS 5.10].
Besides the issue of binary-code-size blow-up with ghc-6.8.2, there is a much more serious problem with codes compiled from both 6.8.2 and 6.6.1.
Here is the output of two runs.
------------------------------------------- portscan a_remote_sun_sparc_machine 1 1000 portscan: internal error: getMBlock: mmap: Bad file number (GHC version 6.6.1 for sparc_sun_solaris2) Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug Abort
Please report the bug as instructed! Cheers, Simon

hp:
I convinced myself that the ~500kbytes for the 'hello' code is 'correct' in version 6.6.1. [ The exact size on the platform mentioned below is 422k. ]
Looks like version 6.8.2 blows up the binary code size significantly --- 3.9Mbytes vs 0.422Mbytes.
Is this a known issue with 6.8.2 ? Is it a specific platform dependent issue --- i.e. does it occur on linux machines ??
That's platform dependent. It means on ghc 6.8.2 wasn't built with split-objs enabled, so it includes a whole bunch of dead code normally stripped out. Consult whoever built the ghc on your platform, to ensure they know how to build with split objects. -- Don

Don Stewart wrote:
hp:
I convinced myself that the ~500kbytes for the 'hello' code is 'correct' in version 6.6.1. [ The exact size on the platform mentioned below is 422k. ]
Looks like version 6.8.2 blows up the binary code size significantly --- 3.9Mbytes vs 0.422Mbytes.
Is this a known issue with 6.8.2 ? Is it a specific platform dependent issue --- i.e. does it occur on linux machines ??
I can confirm HP's code size. I've no idea what went wrong (or differently): -bash-3.00$ ls -l hello -rwxr-xr-x 1 maeder wimi 3907865 May 23 11:38 hello
That's platform dependent. It means on ghc 6.8.2 wasn't built with split-objs enabled, so it includes a whole bunch of dead code normally stripped out.
Consult whoever built the ghc on your platform, to ensure they know how to build with split objects.
-- Don
Object Splitting was enabled: -bash-3.00$ ll hello -rwxr-xr-x 1 maeder wimi 3907865 May 23 11:38 hello -bash-3.00$ ghc --info [("Project name","The Glorious Glasgow Haskell Compilation System") ,("Project version","6.8.2") ,("Booter version","6.8.1") ,("Stage","2") ,("Interface file version","6") ,("Have interpreter","YES") ,("Object splitting","YES") ,("Have native code generator","NO") ,("Support SMP","YES") ,("Unregisterised","NO") ,("Tables next to code","YES") ,("Win32 DLLs","") ,("RTS ways"," debug thr thr_p thr_debug") ,("Leading underscore","NO") ] Cheers Christian

Christian Maeder wrote:
Don Stewart wrote:
hp:
I convinced myself that the ~500kbytes for the 'hello' code is 'correct' in version 6.6.1. [ The exact size on the platform mentioned below is 422k. ]
Looks like version 6.8.2 blows up the binary code size significantly --- 3.9Mbytes vs 0.422Mbytes.
Is this a known issue with 6.8.2 ? Is it a specific platform dependent issue --- i.e. does it occur on linux machines ??
I can confirm HP's code size. I've no idea what went wrong (or differently):
-bash-3.00$ ls -l hello -rwxr-xr-x 1 maeder wimi 3907865 May 23 11:38 hello
That's platform dependent. It means on ghc 6.8.2 wasn't built with split-objs enabled, so it includes a whole bunch of dead code normally stripped out.
Consult whoever built the ghc on your platform, to ensure they know how to build with split objects.
-- Don
Object Splitting was enabled:
-bash-3.00$ ll hello -rwxr-xr-x 1 maeder wimi 3907865 May 23 11:38 hello
-bash-3.00$ ghc --info [("Project name","The Glorious Glasgow Haskell Compilation System") ,("Project version","6.8.2") ,("Booter version","6.8.1") ,("Stage","2") ,("Interface file version","6") ,("Have interpreter","YES") ,("Object splitting","YES") ,("Have native code generator","NO") ,("Support SMP","YES") ,("Unregisterised","NO") ,("Tables next to code","YES") ,("Win32 DLLs","") ,("RTS ways"," debug thr thr_p thr_debug") ,("Leading underscore","NO") ]
If the libraries were built with -fvia-C, we occasionally get incompabitilities with newer versions of gcc and end up duplicating too much stuff in the split .o files. If this is happening to you, please report a bug. Otherwise, please report a bug giving as much info as possible, and we'll try to figure out what is wrong. Cheers, Simon

see http://hackage.haskell.org/trac/ghc/ticket/2312 -split-objs is passed to stage1/ghc-inplace when building the library, yet there's only at most one part for each module. Cheers Christian Simon Marlow wrote:
-bash-3.00$ ghc --info [("Project name","The Glorious Glasgow Haskell Compilation System") ,("Project version","6.8.2") ,("Booter version","6.8.1") ,("Stage","2") ,("Interface file version","6") ,("Have interpreter","YES") ,("Object splitting","YES") ,("Have native code generator","NO") ,("Support SMP","YES") ,("Unregisterised","NO") ,("Tables next to code","YES") ,("Win32 DLLs","") ,("RTS ways"," debug thr thr_p thr_debug") ,("Leading underscore","NO") ]
If the libraries were built with -fvia-C, we occasionally get incompabitilities with newer versions of gcc and end up duplicating too much stuff in the split .o files. If this is happening to you, please report a bug.
Otherwise, please report a bug giving as much info as possible, and we'll try to figure out what is wrong.
Cheers, Simon

Am Mittwoch, 7. Mai 2008 23:04 schrieb HP Wei:
I convinced myself that the ~500kbytes for the 'hello' code is 'correct' in version 6.6.1. [ The exact size on the platform mentioned below is 422k. ]
Looks like version 6.8.2 blows up the binary code size significantly --- 3.9Mbytes vs 0.422Mbytes.
Is this a known issue with 6.8.2 ? Is it a specific platform dependent issue --- i.e. does it occur on linux machines ??
I get 490k for hello without stripping and 274k with stripping on linux. It might be the "-L../lib" option which blows up the binary size. What happens if you just ghc --make hello ? Cheers, Daniel

Suppose p1, p2, p3 are 3 predicates that take an input -- say, a String. They return either (True, result) or False. I want to get an effect like in this expression: case p1 s of (True, r) -> r False -> case p2 s of (True, r) -> r False -> case p3 s of (True, r) -> r False -> none Is this a job for Maybe monad ? How do I do that ? Thanks HP

In the linker ld, there is a -R option to encode lib-search-directories into the object file. Can we not do that in compiling this ghc -o foo --make foo.hs ??? Thanks HP

Hello HP, Wednesday, May 21, 2008, 8:21:01 PM, you wrote:
In the linker ld, there is a -R option
example of passing option to ld: ghc ... -optl-Xlinker -optl--large-address-aware -optl-Xlinker may be optional -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com

Hello HP, Wednesday, May 21, 2008, 8:11:56 PM, you wrote:
Suppose p1, p2, p3 are 3 predicates that take an input -- say, a String. They return either (True, result) or False.
impossible because these are different types :)) if they return Just result or Nothing - yes, use Maybe as monad: combine p1 p2 p3 x= do x1 <- p1 x x2 <- p2 x1 x3 <- p3 x2 return x3 or shortly combine p1 p2 p3 x = p1 x >>= p2 >>= p3 -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com

Am Mittwoch, 21. Mai 2008 18:31 schrieb Bulat Ziganshin:
Hello HP,
Wednesday, May 21, 2008, 8:11:56 PM, you wrote:
Suppose p1, p2, p3 are 3 predicates that take an input -- say, a String. They return either (True, result) or False.
impossible because these are different types :))
if they return Just result or Nothing - yes, use Maybe as monad:
combine p1 p2 p3 x= do x1 <- p1 x x2 <- p2 x1 x3 <- p3 x2 return x3
or shortly
combine p1 p2 p3 x = p1 x >>= p2 >>= p3
Actually, (s)he wanted a sort of catch chain, so import Control.Monad -- for MonadPlus combine p1 p2 p3 x = p1 x `mplus` p2 x `mplus` p3 x or combine ps x = msum $ map ($ x) ps or just case p1 x of Just r -> return r Nothing -> case p2 x of Just r -> return r Nothing -> ...

On 2008 May 21, at 12:31, Bulat Ziganshin wrote:
Wednesday, May 21, 2008, 8:11:56 PM, you wrote:
Suppose p1, p2, p3 are 3 predicates that take an input -- say, a String. They return either (True, result) or False.
if they return Just result or Nothing - yes, use Maybe as monad:
combine p1 p2 p3 x= do x1 <- p1 x x2 <- p2 x1 x3 <- p3 x2 return x3
S/He's not passing on r (the result), but s (the argument). Monad ((-
) r)?
-- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH

On Wed, 21 May 2008, HP Wei wrote:
Suppose p1, p2, p3 are 3 predicates that take an input -- say, a String. They return either (True, result) or False.
I want to get an effect like in this expression:
case p1 s of (True, r) -> r False -> case p2 s of (True, r) -> r False -> case p3 s of (True, r) -> r False -> none
Is this a job for Maybe monad ? How do I do that ?
I think this is a job for the Either monad: data Either a b = Left a | Right b case p1 s of (Left (True, r)) -> r (Right False) -> case p2 s of (Left (True, r)) -> r (Right False) -> case p3 s of (Left (True, r)) -> r (Right False) -> none So you wrap up your (Bool, result) type using Left, and your Bool type using Right. Regards, Chris.
Thanks HP _______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

On further thought, better to use the Maybe afterall. You can use Nothing to signify your False and Just to signify your result. case p1 s of Just result -> result Nothing -> case p2 s of ... That's probably more intuitive to what you were intending. Chris. On Wed, 21 May 2008, C.M.Brown wrote:
On Wed, 21 May 2008, HP Wei wrote:
Suppose p1, p2, p3 are 3 predicates that take an input -- say, a String. They return either (True, result) or False.
I want to get an effect like in this expression:
case p1 s of (True, r) -> r False -> case p2 s of (True, r) -> r False -> case p3 s of (True, r) -> r False -> none
Is this a job for Maybe monad ? How do I do that ?
I think this is a job for the Either monad:
data Either a b = Left a | Right b
case p1 s of (Left (True, r)) -> r (Right False) -> case p2 s of (Left (True, r)) -> r (Right False) -> case p3 s of (Left (True, r)) -> r (Right False) -> none
So you wrap up your (Bool, result) type using Left, and your Bool type using Right.
Regards, Chris.
Thanks HP _______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
_______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Thanks to all who has replied in such a short time.
From your reponses, I looked at the definition of `mplus`
Nothing `mplus` ys = ys xs `mplus` _ = xs It catches the essence of what I am trying to do! Later, if pn grows in number, I can scale up by using some-kind-of-zero with some higher order foldx-like functions. Thanks a lot, --hp On Wed, 21 May 2008, HP Wei wrote:
Suppose p1, p2, p3 are 3 predicates that take an input -- say, a String. They return either (True, result) or False.
I want to get an effect like in this expression:
case p1 s of (True, r) -> r False -> case p2 s of (True, r) -> r False -> case p3 s of (True, r) -> r False -> none
Is this a job for Maybe monad ? How do I do that ?
Thanks HP
participants (9)
-
Brandon S. Allbery KF8NH
-
Bulat Ziganshin
-
C.M.Brown
-
Christian Maeder
-
Daniel Fischer
-
Don Stewart
-
HP Wei
-
Simon Marlow
-
Simon Marlow