[Haskell] Re: Why is getArgs in the IO monad?

Conal Elliott conal at conal.net
Tue Jan 18 02:46:13 EST 2005


Hi Jim.  If I understand you, you're asking for an operational answer to
your original "why" -- this time bringing in the operational issues of
compile and run times.  I'm suggesting you might better understand the
why of Haskell if you think denotationally (here about the meaning of
the [String] type), rather than operationally.

As a simpler example (type-wise), if "getArgs" were to have type
[String], then "length getArgs" would have type Int.  The meaning of
"length getArgs" would then have to be a value whose type is the meaning
of Haskell's "Int", i.e. either bottom or a 32-bit integer.  I'm
guessing that none of those 2^32+1 values is what you'd mean by "length
getArgs".  On the other hand, the IO monad is a much roomier type.

HTH,

     - Conal

-----Original Message-----
From: haskell-bounces at haskell.org [mailto:haskell-bounces at haskell.org]
On Behalf Of Jim Apple
Sent: Monday, January 17, 2005 10:28 PM
To: haskell at haskell.org
Subject: [Haskell] Re: Why is getArgs in the IO monad?

Conal Elliott wrote:

> If getArgs had type [String], then its denotation must be a (lazy)
list
> of (lazy) sequences of characters (extended by bottom).  For instance,
> the expression (words "hello world") denotes the list
["hello","world"].
> What list would "getArgs" denote?

I don't think I understand your (rhetorical) question.

It seems that, looking out at the world from main, the args passed to 
main and the compilation happen at the same time (before, long long 
ago). What motivation would we have for treating them differently?

Jim

_______________________________________________
Haskell mailing list
Haskell at haskell.org
http://www.haskell.org/mailman/listinfo/haskell



More information about the Haskell mailing list