Changeset 2852 for src/Pugs/Bind.hs
- Timestamp:
- 05/08/05 15:07:38 (4 years ago)
- svk:copy_cache_prev:
- 4407
- Files:
-
- 1 modified
-
src/Pugs/Bind.hs (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Pugs/Bind.hs
r2817 r2852 15 15 import Pugs.Types 16 16 17 -- |Contains either a valid value of \'a\'(@Right@), or a @String@ error17 -- |Contains either a valid value of @a@ (@Right@), or a @String@ error 18 18 -- message (@Left@). 19 19 type MaybeError a = Either String a … … 44 44 emptyArrayExp = Val $ VList [] -- VArray $ vCast $ VList [] 45 45 46 bindHash :: [Exp] -> [Param] -> MaybeError Bindings 46 {-| 47 Create a binding from the slurpy hash parameter (e.g. @\*%_@) to a hash 48 containing all the remaining named arguments. If multiple slurpy hashes 49 are given, only the first gets the arguments--the rest get an empty hash. 50 Used by 'bindSomeParams'. 51 -} 52 bindHash :: [Exp] -- ^ Named arguments (pair expressions) that were not 53 -- consumed by explicit named parameters 54 -> [Param] -- ^ List of slurpy hash parameters 55 -> MaybeError Bindings 47 56 bindHash _ [] = return [] 48 57 bindHash [] [p] = return [ (p, emptyHashExp) ] … … 66 75 prms = map (\p -> (p, (head (paramName p)))) ps 67 76 68 doSlice :: Exp -> VInt -> Exp 77 -- |Construct an expression representing an infinite slice of the given 78 -- array expression, beginning at element /n/ (i.e. @\@array\[\$n...\]@). 79 -- Used by 'doBindArray' to bind a slurpy array parameter to the rest of 80 -- the slurpable arguments. 81 doSlice :: Exp -- ^ The array expression to slice 82 -> VInt -- ^ Index of the first element in the resulting slice (/n/) 83 -> Exp 69 84 doSlice v n = Syn "[...]" [v, Val $ VInt n] 70 85 71 86 -- XXX - somehow force failure 87 -- |Construct an expression representing element /n/ in the given array 88 -- expression (i.e. @\@array\[\$n\]@). Used by 'doBindArray' to bind a 89 -- particular slurpy scalar parameter to one of the slurpable arguments. 72 90 doIndex :: Exp -> VInt -> Exp 73 91 doIndex v n = Syn "[]" [Syn "val" [v], Val $ VInt n] … … 82 100 doBindArray _ (_, _) (_, x) = internalError $ "doBindArray: unexpected char: " ++ (show x) 83 101 102 -- |(Does this even get used? It seems to be a leftover fragment of 103 -- 'doBindArray'...) 84 104 bindEmpty :: Param -> MaybeError (Param, Exp) 85 105 bindEmpty p = case paramName p of
