Re: [Haskell-cafe] Haskell Quick Reference (1-page PDF)

2008-11-08 Thread Don Stewart
Malcolm.Wallace:
> Some time ago, there was a thread about a "CheatSheet" for Haskell
> beginners.  As I recall, the CheatSheet was more than 12 pages long.
> 
> For a Haskell tutorial I was running at a conference recently, I needed
> a "Quick Reference Guide" that would fit onto a single side of A4.  So I
> knocked one together quickly, and it is attached as a PDF.  I send it to
> this list, with permission for anyone to distribute it more widely as
> they wish, in the hope that it might be useful.
> 

wonderful. recorded on the wiki,

http://haskell.org/haskellwiki/Image:QuickReference.pdf
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Haskell Quick Reference (1-page PDF)

2008-11-06 Thread Joachim Breitner
Hi,

the reference suggests the use of otherwise (instead of _) as the
default pattern in a case expression. While it certainly works, isn’t it
bad style, as it shadows Prelude.otherwise:

$ cat otherwise.lhs ; runhaskell otherwise.lhs 
>demo b arg = case b of
>   True  -> do print "First arg was True"
>   let g | arg ==  "Something" = print "Got 
> something"
> | otherwise   = print "Got 
> anything else"
>   g
>   otherwise -> do print "First arg was not True"
>   let g | arg ==  "Something" = print "Got 
> something"
> | otherwise   = print "Got 
> anything else"
>   g
>
>main = do demo True "Something"
>  demo True "Something else"
>  demo False "Something"
>  demo False "Something else"
"First arg was True"
"Got something"
"First arg was True"
"Got anything else"
"First arg was not True"
"Got something"
"First arg was not True"
otherwise.lhs: otherwise.lhs:(7,36)-(8,86): Non-exhaustive patterns in function 
g

I know that this is a contrieved example (using case on a boolean), but
in other cases you’ll get strange type errors. So while I think I did it
in the past, otherwise should be avoided in case expressions. 

Greetings,
Joachim

-- 
Joachim "nomeata" Breitner
  mail: [EMAIL PROTECTED] | ICQ# 74513189 | GPG-Key: 4743206C
  JID: [EMAIL PROTECTED] | http://www.joachim-breitner.de/
  Debian Developer: [EMAIL PROTECTED]


signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe