do expression

Ketil Z. Malde ketil@ii.uib.no
05 May 2003 14:28:09 +0200


sashan <sashang@ihug.co.nz> writes:

> When compiled with ghc I get the following error:
> test.hs:8:
>      No instance for (Num String)
>      arising from the pattern `2' at test.hs:8
>      In a case alternative: 2 -> do putStrLn "f2"
>      In the case expression:
> 	case choice of
> 	  1 -> do putStrLn "f1"
> 	  2 -> do putStrLn "f2"
> 	  _ -> do putStrLn ""

> Please can someone explain.

The compiler already did:    No instance for (Num String)
In other words, a String is not a Num(ber), and you are treating it as
one (the variable 'choice' in the case clause).

-kzm
-- 
If I haven't seen further, it is by standing in the footprints of giants