Changeset 2812 for src/Pugs/Bind.hs

Show
Ignore:
Timestamp:
05/07/05 13:48:01 (4 years ago)
Author:
scook0
svk:copy_cache_prev:
4340
Message:

Initial Haddocks for Bind

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/Bind.hs

    r2774 r2812  
    1515import Pugs.Types 
    1616 
     17-- |Contains either a valid value of \'a\' (@Right@), or a @String@ error 
     18-- message (@Left@). 
    1719type MaybeError a = Either String a 
    1820 
    1921isRequired prm = not ( isOptional prm || isNamed prm ) 
    2022 
    21 bindNames :: [Exp] -> [Param] -> (Bindings, [Exp], [Param]) 
     23-- |Match up named arguments with named parameters, producing a list of new 
     24-- bindings, and lists of remaining unbound args and params. 
     25bindNames :: [Exp] -- ^ List of argument expressions to be bound 
     26          -> [Param] -- ^ List of parameters to try binding; includes both 
     27                     --     named params and positional params 
     28          -> (Bindings, [Exp], [Param]) -- ^ Bindings made; remaining (unbound) 
     29                                        --     named args; remaining 
     30                                        --     (positional) params 
    2231bindNames exps prms = (bound, exps', prms') 
    2332    where 
     
    8089    []      -> internalError $ "bindEmpty: empty string encountered" 
    8190 
     91-- |Return @True@ if the given expression represents a pair (i.e. it uses the 
     92-- \"=>\" pair composer). 
    8293isPair :: Exp -> Bool 
    8394isPair (Pos _ exp) = isPair exp 
     
    8899isPair _                         = False 
    89100 
     101-- |Decompose a pair-constructor 'Exp'ression (\"=>\") into a Haskell pair 
     102-- (@key :: 'String'@, @value :: 'Exp'@). 
    90103unPair :: Exp -> (String, Exp) 
    91104unPair (Pos _ exp) = unPair exp 
     
    97110 
    98111-- performs a binding and then verifies that it's complete in one go 
    99 bindParams :: VCode -> [Exp] -> [Exp] -> MaybeError VCode 
     112{-| 
     113Bind parameters to a callable, then verify that the binding is complete 
     114(i.e. all mandatory params are bound; all unspecified params have default 
     115bindings). Uses 'bindSomeParams' to perform the initial binding, then uses 
     116'finalizeBindings' to check all required params and give default values to 
     117any unbound optional ones. 
     118-} 
     119bindParams :: VCode -- ^ A code object to perform bindings on 
     120           -> [Exp] -- ^ List of invocants to bind 
     121           -> [Exp] -- ^ List of arguments (actual params) to bind 
     122           -> MaybeError VCode -- ^ Returns either a new 'VCode' with all the 
     123                               --     bindings in place, or an error message 
    100124bindParams sub invsExp argsExp = do 
    101125    case bindSomeParams sub invsExp argsExp of 
     
    138162 
    139163-- takes invocants and arguments, and creates a binding from the remaining params in the sub 
     164{-| 
     165Take a code object and lists of invocants and arguments, and produce (if 
     166possible) a new 'VCode' value representing the same code object, with as many 
     167parameters bound as possible (using the given invocants and args). 
     168-} 
    140169bindSomeParams :: VCode -> [Exp] -> [Exp] -> MaybeError VCode 
    141170bindSomeParams sub invsExp argsExp = do