Changeset 2852 for src/Pugs/Bind.hs

Show
Ignore:
Timestamp:
05/08/05 15:07:38 (4 years ago)
Author:
scook0
svk:copy_cache_prev:
4407
Message:

More Haddocks for Bind

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/Bind.hs

    r2817 r2852  
    1515import Pugs.Types 
    1616 
    17 -- |Contains either a valid value of \'a\' (@Right@), or a @String@ error 
     17-- |Contains either a valid value of @a@ (@Right@), or a @String@ error 
    1818-- message (@Left@). 
    1919type MaybeError a = Either String a 
     
    4444emptyArrayExp = Val $ VList [] -- VArray $ vCast $ VList [] 
    4545 
    46 bindHash :: [Exp] -> [Param] -> MaybeError Bindings 
     46{-| 
     47Create a binding from the slurpy hash parameter (e.g. @\*%_@) to a hash 
     48containing all the remaining named arguments. If multiple slurpy hashes 
     49are given, only the first gets the arguments--the rest get an empty hash. 
     50Used by 'bindSomeParams'. 
     51-} 
     52bindHash :: [Exp]   -- ^ Named arguments (pair expressions) that were not 
     53                    --     consumed by explicit named parameters 
     54         -> [Param] -- ^ List of slurpy hash parameters 
     55         -> MaybeError Bindings 
    4756bindHash _ []           = return [] 
    4857bindHash [] [p]         = return [ (p, emptyHashExp) ] 
     
    6675    prms = map (\p -> (p, (head (paramName p)))) ps  
    6776 
    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. 
     81doSlice :: Exp -- ^ The array expression to slice 
     82        -> VInt -- ^ Index of the first element in the resulting slice (/n/) 
     83        -> Exp  
    6984doSlice v n = Syn "[...]" [v, Val $ VInt n] 
    7085 
    7186-- 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. 
    7290doIndex :: Exp -> VInt -> Exp 
    7391doIndex v n = Syn "[]" [Syn "val" [v], Val $ VInt n] 
     
    82100doBindArray _ (_, _)  (_, x) = internalError $ "doBindArray: unexpected char: " ++ (show x) 
    83101 
     102-- |(Does this even get used? It seems to be a leftover fragment of 
     103-- 'doBindArray'...) 
    84104bindEmpty :: Param -> MaybeError (Param, Exp) 
    85105bindEmpty p = case paramName p of