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@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH