[Haskell-cafe] bizarre syntax error

Brandon S. Allbery KF8NH allbery at ece.cmu.edu
Sat Jun 27 20:50:47 EDT 2009

On Jun 27, 2009, at 20:37 , Geoffrey Irving wrote:
>    "The last statement in a 'do' construct must be an expression"

Right, the "where" terminates the entire expression, you can't use it  
in the middle like that.  I'm pretty sure that's mandatory per the  
standard, and nobody really wants to open the can of worms involved  
with allowing its nested use as an extension.  (Layout is hard enough  
to parse already; IIRC, strictly speaking, the behavior specified in  
the standard is impossible to implement, and even "almost right" is  
extremely difficult.)  Use a subsidiary "let" instead:

>            caseType (c,vl,e')
>              | Just tl <-
>                 let a = length tl
>                 in List.lookup c cases =
>                  if length vl == a then
>                    expr prog global (foldl (\e (v,t) -> Map.insert v  
> t e) env (zip vl (map (subst tenv) tl))) e'
>                  else
>                    typeError ("arity mismatch in pattern: "++show  
> (pretty c)++"expected"++show a++" argument"++(if a == 1 then "" else  
> "s")
>                      ++" but got ["++concat (intersperse ", " (map  
> (show . pretty) vl))++"]")

brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery at kf8nh.com
system administrator [openafs,heimdal,too many hats] allbery at ece.cmu.edu
electrical and computer engineering, carnegie mellon university    KF8NH

-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 195 bytes
Desc: This is a digitally signed message part
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090627/93e284a7/PGP.bin

More information about the Haskell-Cafe mailing list