[Haskell-beginners] String type hello-o-matic...

Emacs The Viking sean at objitsu.com
Fri Mar 9 16:01:00 CET 2012


 


Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaagh!


Ok, that said, now I can explain my self a little more clearly. 

I am
almost to the point of exasperation on trying to know when and why and
how to convert between String, ByteString, ByteString.Laz, Char8 etc.
For heavens sake how many bloody string types can you need? LOL 

I am
trying to use Data.Digest.Pure.SHA but it takes a ByteString in the
"sha1" function but from the command prompt of ghci I cannot seem to
work out how to do it, I just get the usual daunting messages.  

 sha1
:: ByteString -> Digest SHA1State 

I have a String, but the pack
function wants a [Word8] to create a digest value. 

 pack :: [Word8] ->
ByteString 

IIUC, String is just [Char] and that Char is in fact a
Unicode character and therefore NOT "8 bit" as such which is why the
Char8 variants exist. I understand the difference between lazy and
strict and why one is different from the other. But... it's little
things like the foldr' function NOT being present in one library but
present in the other, presumably a lazy implementation doesn't need a
strict function or something like that. Who knows. I don't! 

I am sure
to "seasoned" haskellers this is all elementary and I would love to
eventually become a seasoned developer of it too but at times like this
I want to scream in utter confusion as to how many different string
types there are and the sometimes almost unnotcable differences between
them. And trying to convert between them to actually get on and write
useful working code. 

When do I use strict? When do I use lazy? When do
I use the Char8 variant? And so the questions continue with barely any
"beginner" level answers to be found. I'd write them myself but I don't
know the answers yet! 

Speaking as a non-academic, non-mathemetician,
but as a developer with 25+ years of using lots of languages inclusing
Erlang, LISP and Scala, sometimes Haskell is very very hard to
perservere with because everybody just seems to love using words and
phrases like "mono-morphism", "monadic transformers" etc. just to show
off how well they understand Haskell. That's fine for those in the club
but those on the outside looking in would also like to be able to "get
in" as well and be able to write serious looking blog posts about how
damned funky haskell is. 

And it is... but not if you can't understand
it! is there some kind of Free Masonry involved ;) 

Thanks again,


Sean... now where's my RWH book again... 

  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20120309/0b47c1d7/attachment.htm>


More information about the Beginners mailing list