hashmap withdrawal and poor haskell style

Michal Wallace sabren@manifestation.com
Wed, 3 Apr 2002 07:40:35 -0500 (EST)


On Wed, 3 Apr 2002, D. Tweed wrote:

> >     main = do content <- getContents
> >               let rpt letter = report content letter
> >               loop rpt alphabet

> I'm a bit confused how this can have worked... in Haskell `let' is used in
> the context of a `let ..<1>.. in ..<2>..' where the code ellided in <1>
> binds some names to values which are then used in the expression <2> (as
> in `let x=sqrt 2 in exp x') and so the contents of main isn't (unless I'm
> missing something) syntactically Haskell.  

Beats me, but it was the only (or at least the first) way I
could find to create a function inside a do block... 

> Overall the code looks like a reasonable transliteration into Haskell; as
> you get more competent with Haskell you'll find various higher level
> functions that replace some of your stuff, e.g., stars can be written as
> stars x = take x (repeat '*').

Neat! :)


> Regarding Assoc, try just `import Assoc' without trying to cut down on
> which entities are imported; if it works then you've missed some needed 
> elements from your import specification (the bit in ()'s after the module
> name); if it doesn't then it probably can't find Assoc at all.


In the latest version of hugs, if you try "import Assoc", you get:

runhugs: Error occurred
Reading file "assoc.hs":
Reading file "/usr/share/hugs/lib/exts/Assoc.hs":
Reading file "/usr/share/hugs/lib/exts/EdisonPrelude.hs":
Reading file "/usr/share/hugs/lib/exts/Sequence.hs":
Reading file "/usr/share/hugs/lib/Monad.hs":
Reading file "/usr/share/hugs/lib/exts/Sequence.hs":
Reading file "/usr/share/hugs/lib/exts/ListSeq.hs":
Reading file "/usr/share/hugs/lib/exts/Assoc.hs":
Parsing
ERROR "/usr/share/hugs/lib/exts/Assoc.hs":51 - Haskell 98 does not support multiple parameter classes


At least, *I* get that. :) And the -98 flag is just as bad:


[~/work/haskell]: runhugs -98 assoc.hs
runhugs: Error occurred
Reading file "assoc.hs":
Reading file "/usr/share/hugs/lib/exts/Assoc.hs":
Reading file "/usr/share/hugs/lib/exts/EdisonPrelude.hs":
Reading file "/usr/share/hugs/lib/exts/Sequence.hs":
Reading file "/usr/share/hugs/lib/Monad.hs":
Reading file "/usr/share/hugs/lib/exts/Sequence.hs":
Reading file "/usr/share/hugs/lib/exts/ListSeq.hs":
Reading file "/usr/share/hugs/lib/exts/Assoc.hs":
Reading file "assoc.hs":
ERROR "assoc.hs" - Entity "foldl1" imported from module "Assoc" already defined in module "Prelude"

Which is why I restricted what was being imported. :)


Anyway, thanks for the response! :)

Cheers,

- Michal   http://www.sabren.net/   sabren@manifestation.com 
------------------------------------------------------------
Give your ideas the perfect home: http://www.cornerhost.com/
 cvs - weblogs - php - linux shell - perl/python/cgi - java
------------------------------------------------------------