Changeset 8792 for src/Pugs/Bind.hs
- Timestamp:
- 01/27/06 09:59:34 (3 years ago)
- Files:
-
- 1 modified
-
src/Pugs/Bind.hs (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Pugs/Bind.hs
r8298 r8792 22 22 -} 23 23 type MaybeError a = Either String a 24 25 isRequired :: Param -> Bool26 isRequired prm = not $ isOptional prm27 24 28 25 {-| … … 208 205 ++ (show $ subName sub) 209 206 210 let (bound Req, boundOpt) = partition (isRequired. fst) bindings -- bound params which are required211 ( reqPrms, optPrms) = span isRequiredparams -- all params which are required, and all params which are opt207 let (boundOpt, boundReq) = partition (isOptional . fst) bindings -- bound params which are required 208 (optPrms, reqPrms) = partition isOptional params -- all params which are required, and all params which are opt 212 209 213 210 -- Check length of required parameters 214 211 when (length boundReq < length reqPrms) $ do 215 fail $ "Insufficient number of required parameters: " 216 ++ (show $ length boundReq) ++ " actual, " 217 ++ (show $ length reqPrms) ++ " expected" 212 fail $ "Missing required parameters: " 213 ++ unwords (map paramName $ reqPrms \\ map fst boundReq) 218 214 219 215 let unboundOptPrms = optPrms \\ (map fst boundOpt) -- unbound optParams are allPrms - boundPrms … … 250 246 (namedArgs, posArgs) = partition isNamedArg givenArgs 251 247 (boundNamed, namedForSlurp, allPosPrms) = bindNames namedArgs argPrms -- bind pair args to params. namedForSlup = leftover pair args 252 (posPrms, slurpyPrms) = break isSlurpy allPosPrms -- split any prms not yet bound, into regular and slurpy. allPosPrms = not bound by named 248 (itemPrms, slurpyPrms) = break isSlurpy allPosPrms -- split any prms not yet bound, into regular and slurpy. allPosPrms = not bound by named 249 posPrms = filter (not . isNamed) itemPrms 253 250 boundPos = posPrms `zip` posArgs -- bind all the unbound params in positional order 254 251 posForSlurp = drop (length posPrms) posArgs -- and whatever's left will be slurped
