[Haskell-cafe] Re: Hugs vs GHC (again) was: Re: Some
ketil+haskell at ii.uib.no
Tue Jan 11 09:00:42 EST 2005
Okay, I've taken a look (there seems to be some differences between
the web page and the tgz from the wiki - fileGet seems to have
disappeared). I still don't grok much of it, so just ignore me if I'm
being overly naive.
Anyway. Let's see, I can now open a stream from a file by doing:
f <- openFileInputStream "filename"
streamGet f now gets me the bytes in that file.
Adding an encoding:
t <- textInputStream f utf8
tsGet t gets me Chars as decoded by the utf8 decoder. Cool.
Couldn't this be generalized more? What about a fundep on the Stream
classes, parametrizing by content? Ideally, I would like to have
'get' return a value of a type appropriate to the stream type.
I must admit I didn't dig too deeply in the gritty details of applying
codecs, but must textInputStream be limited to text-decoding
functions? It would be really nice to be able to specify arbitrary
decoders (e.g. using 't <- Stream.decode f utf8') to do stuff like
t <- decode f zip
p <- decode f (crypt "password")
So it seems to me that this can be generalized to more than Text, but
the implementation is perhaps too text-specific?
BTW and IMHO, perhaps the parameters could be swapped -
i.e. 'map (textInputStream utf8) f1 f2 f3' seems to me to be more
useful than 'map (textInputStream f) utf8 iso8859_1 ucs4' :-)
If I haven't seen further, it is by standing in the footprints of giants
More information about the Haskell-Cafe