Show
Ignore:
Timestamp:
05/17/05 11:33:37 (4 years ago)
Author:
scook0
svk:copy_cache_prev:
4908
Message:

Style updates for Haddocks

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/AST/Internals.hs

    r3200 r3328  
    129129            Nothing    -> errIndex def idx 
    130130 
    131 -- |Check whether a 'Val' is of the specified type. Based on the result, 
    132 -- either the first or the second evaluation should be performed. 
     131{-| 
     132Check whether a 'Val' is of the specified type. Based on the result, 
     133either the first or the second evaluation should be performed. 
     134-} 
    133135ifValTypeIsa :: Val      -- ^ Value to check the type of 
    134136             -> String   -- ^ Name of the type to check against 
     
    144146        else falseM 
    145147 
    146 -- |If we are in list context (i.e. 'CxtSlurpy'), then perform the first 
    147 -- evaluation; otherwise perform the second. 
     148{-| 
     149If we are in list context (i.e. 'CxtSlurpy'), then perform the first 
     150evaluation; otherwise perform the second. 
     151-} 
    148152ifListContext :: (MonadReader Env m) 
    149153              => m t -- ^ The @then@ case 
     
    156160        _           -> falseM 
    157161 
    158 -- |Return the appropriate 'empty' value for the current context -- either 
    159 -- an empty list ('VList' []), or undef ('VUndef'). 
     162{-| 
     163Return the appropriate 'empty' value for the current context -- either 
     164an empty list ('VList' []), or undef ('VUndef'). 
     165-} 
    160166retEmpty :: Eval Val 
    161167retEmpty = do 
     
    189195-} 
    190196 
    191 -- |Typeclass indicating types that can be converted to\/from 'Val's. 
    192 -- Not to be confused with 'Val' itself, or the 'Exp' constructor @Val@. 
     197{-| 
     198Typeclass indicating types that can be converted to\/from 'Val's. 
     199 
     200Not to be confused with 'Val' itself, or the 'Exp' constructor @Val@. 
     201-} 
    193202class (Typeable n, Show n, Ord n) => Value n where 
    194203    fromVal :: Val -> Eval n 
     
    306315    doCast _           = True 
    307316 
    308 -- |Collapse a junction value into a single boolean value. Works by 
    309 -- recursively casting the junction members to booleans, then performing 
    310 -- the actual junction test. 
     317{-| 
     318Collapse a junction value into a single boolean value. 
     319 
     320Works by recursively casting the junction members to booleans, then performing 
     321the actual junction test. 
     322-} 
    311323juncToBool :: VJunc -> Bool 
    312324juncToBool (MkJunc JAny  _  vs) = True `Set.member` Set.map vCast vs 
     
    481493type VType = Type 
    482494 
    483 -- |Represents a value. Note that 'Val' is also a constructor for 'Exp' (i.e. 
    484 -- an expression containing a value), so don't confuse the two. Similarly, 
    485 -- all the constructors for @data 'Val'@ are themselves puns on the types of 
    486 -- values they contain. 
     495{-| 
     496Represents a value. 
     497 
     498Note that 'Val' is also a constructor for 'Exp' (i.e. an expression containing  
     499a value), so don't confuse the two. Similarly, all the constructors for  
     500@data 'Val'@ are themselves puns on the types of values they contain. 
     501-} 
    487502data Val 
    488503    = VUndef                 -- ^ Undefined value 
     
    512527    deriving (Show, Eq, Ord, Typeable) 
    513528 
    514 -- |Find the 'Type' of the value contained by a 'Val'. See "Pugs.Types" for 
    515 -- info on types. 
     529{-| 
     530Find the 'Type' of the value contained by a 'Val'. 
     531 
     532See "Pugs.Types" for info on types. 
     533-} 
    516534valType :: Val -> Type 
    517535valType VUndef          = mkType "Scalar" 
     
    547565    deriving (Show, Eq, Ord) 
    548566 
    549 -- |Represents a junction value. 
    550 -- Note that @VJunc@ is also a pun for a 'Val' constructor /containing/ a 
    551 -- 'VJunc'. 
     567{-| 
     568Represents a junction value. 
     569 
     570Note that @VJunc@ is also a pun for a 'Val' constructor /containing/ a 'VJunc'. 
     571-} 
    552572data VJunc = MkJunc 
    553573    { juncType :: !JuncType -- ^ 'JAny', 'JAll', 'JNone' or 'JOne' 
     
    564584    } deriving (Eq, Ord) 
    565585 
    566 -- |The combining semantics of a junction. See 'VJunc' for more info. 
     586-- | The combining semantics of a junction. See 'VJunc' for more info. 
    567587data JuncType = JAny  -- ^ Matches if /at least one/ member matches 
    568588              | JAll  -- ^ Matches only if /all/ members match 
     
    585605            "" $ Set.elems set) ++ ")" 
    586606 
    587 -- |Each 'VCode' structure has a 'SubType' indicating what \'level\' of 
    588 -- callable item it is. 'doApply' uses this to figure out how to enter 
    589 -- the proper scope and 'Env' when the sub is called. 
    590 -- Note that this is the \'type\' of a \'sub\', and has nothing to do with 
    591 -- subtyping. 
     607{-| 
     608Each 'VCode' structure has a 'SubType' indicating what \'level\' of 
     609callable item it is. 'doApply' uses this to figure out how to enter 
     610the proper scope and 'Env' when the sub is called. 
     611 
     612Note that this is the \'type\' of a \'sub\', and has nothing to do with 
     613subtyping. 
     614-} 
    592615data SubType = SubMethod  -- ^ Method 
    593616             | SubRoutine -- ^ Regular subroutine 
     
    599622isSlurpy param = isSlurpyCxt $ paramContext param 
    600623 
    601 -- |A formal parameter of a sub (or other callable). These represent 
    602 -- declared parameters; don't confuse them with actual parameter values. 
     624{-| 
     625A formal parameter of a sub (or other callable). 
     626 
     627These represent declared parameters; don't confuse them with actual parameter  
     628values. 
     629-} 
    603630data Param = MkParam 
    604631    { isInvocant    :: !Bool        -- ^ Is it in invocant slot? 
     
    615642    deriving (Show, Eq, Ord) 
    616643 
    617 -- |A list of formal parameters. 
     644-- | A list of formal parameters. 
    618645type Params     = [Param] 
    619 -- |A list of bindings from formal parameters ('Param') to actual parameter 
    620 -- expressions ('Exp'). 
     646{-| 
     647A list of bindings from formal parameters ('Param') to actual parameter 
     648expressions ('Exp'). 
     649-} 
    621650type Bindings   = [(Param, Exp)] 
    622651{-| 
     
    645674type SlurpLimit = [(VInt, Exp)] 
    646675 
    647 -- |Represents a sub, method, closure etc. -- basically anything callable. 
     676-- | Represents a sub, method, closure etc. -- basically anything callable. 
    648677data VCode = MkCode 
    649678    { isMulti       :: !Bool        -- ^ Is this a multi sub\/method? 
     
    661690    deriving (Show, Eq, Ord, Typeable) 
    662691 
    663 -- |Construct a 'VCode' representing a built-in primitive operator. 
    664 -- See "Pugs.Prim" for more info. 
     692{-| 
     693Construct a 'VCode' representing a built-in primitive operator. 
     694 
     695See "Pugs.Prim" for more info. 
     696-} 
    665697mkPrim :: VCode 
    666698mkPrim = MkCode 
     
    712744-} 
    713745 
    714 -- |Represents an expression tree. 
     746-- | Represents an expression tree. 
    715747data Exp 
    716748    = Noop                              -- ^ No-op 
     
    731763 
    732764class Unwrap a where 
    733     -- |Unwrap a nested expression, throwing away wrappers (such as 'Cxt' or 
    734     -- 'Pos' to get at the more interesting expression underneath. Works both 
    735     -- on individual 'Exp's, and elementwise on ['Exp']s. 
     765    {-| 
     766    Unwrap a nested expression, throwing away wrappers (such as 'Cxt' or 
     767    'Pos' to get at the more interesting expression underneath. Works both 
     768    on individual 'Exp's, and elementwise on ['Exp']s. 
     769    -} 
    736770    unwrap :: a -> a 
    737771    unwrap = id 
     
    762796    compare _ _ = EQ 
    763797 
    764 -- |(Is this even used? A @grep@ through the sources doesn't find any 
    765 -- callers...) 
     798{-| 
     799(Is this even used? A @grep@ through the sources doesn't find any callers...) 
     800-} 
    766801extractExp :: Exp -> ([Exp], [String]) -> ([Exp], [String]) 
    767802extractExp ex (exps, vs) = (ex':exps, vs') 
     
    769804    (ex', vs') = extract ex vs 
    770805 
    771 -- |(Used by 'extractExp'...) 
     806-- | (Used by 'extractExp'...) 
    772807extract :: Exp -> [String] -> (Exp, [String]) 
    773808extract (App n invs args) vs = (App n invs' args', vs'') 
     
    803838 
    804839-- can be factored 
    805 -- |Return the context implied by a particular primary sigil 
    806 -- (\$, \@, \% or \&). E.g. used to find what context to impose on 
    807 -- the RHS of a binding (based on the sigil of the LHS). 
     840{-| 
     841Return the context implied by a particular primary sigil 
     842(\$, \@, \% or \&). E.g. used to find what context to impose on 
     843the RHS of a binding (based on the sigil of the LHS). 
     844-} 
    808845cxtOfSigil :: Char -> Cxt 
    809846cxtOfSigil '$'  = cxtItemAny 
     
    815852cxtOfSigil x    = internalError $ "cxtOfSigil: unexpected character: " ++ show x 
    816853 
    817 -- |Return the type of variable implied by a name beginning with the specified 
    818 -- sigil. 
     854{-| 
     855Return the type of variable implied by a name beginning with the specified 
     856sigil. 
     857-} 
    819858typeOfSigil :: Char -> Type 
    820859typeOfSigil '$'  = mkType "Scalar" 
     
    857896type DebugInfo = Maybe (TVar (Map String String)) 
    858897 
    859 -- | Evaluation environment. The current environment is stored in the 
    860 -- @Reader@ monad inside the current 'Eval' monad, and can be retrieved using 
    861 -- @ask@ for the whole 'Env', or @asks@ if you just want a single field. 
     898{-| 
     899Evaluation environment. 
     900 
     901The current environment is stored in the @Reader@ monad inside the current  
     902'Eval' monad, and can be retrieved using @ask@ for the whole 'Env', or @asks@  
     903if you just want a single field. 
     904-} 
    862905data Env = MkEnv 
    863906    { envContext :: !Cxt                 -- ^ Current context 
     
    886929    showCxt (CxtSlurpy typ) = "List (" ++ showType typ ++ ")" 
    887930 
    888 {- |A 'Pad' keeps track of the names of all currently-bound symbols, and 
     931{-| 
     932A 'Pad' keeps track of the names of all currently-bound symbols, and 
    889933associates them with the things they actually represent. 
    890934 
     
    927971            return $ "(unsafePerformIO . atomically $ do { bool <- newTVar True; ref <- (newTVar " ++ vCast dump ++ "); return (bool, ref) })" 
    928972 
    929 -- |Produce a 'Pad' from a list of bindings. The inverse of 'padToList'. 
    930 -- Not to be confused with the actual 'Pad' constructor @MkPad@. 
     973{-| 
     974Produce a 'Pad' from a list of bindings. The inverse of 'padToList'. 
     975 
     976Not to be confused with the actual 'Pad' constructor @MkPad@. 
     977-} 
    931978mkPad :: [(Var, [(TVar Bool, TVar VRef)])] -> Pad 
    932979mkPad = MkPad . Map.fromList 
    933980 
    934 -- |Look up a symbol in a 'Pad'. 
     981-- | Look up a symbol in a 'Pad', returning the ref it is bound to. 
    935982lookupPad :: Var -- ^ Symbol to look for 
    936983          -> Pad -- ^ Pad to look in 
     
    940987    Nothing -> Nothing 
    941988 
    942 -- |Transform a pad into a flat list of bindings. The inverse of 'mkPad'. 
    943 -- Note that @Data.Map.assocs@ returns a list of mappings in ascending key 
    944 -- order. 
     989{-| 
     990Transform a pad into a flat list of bindings. The inverse of 'mkPad'. 
     991 
     992Note that @Data.Map.assocs@ returns a list of mappings in ascending key order. 
     993-} 
    945994padToList :: Pad -> [(Var, [(TVar Bool, TVar VRef)])] 
    946995padToList (MkPad map) = Map.assocs map 
    947996 
    948 -- |Return the difference between two pads. 
     997-- | Return the difference between two pads. 
    949998diffPads :: Pad -- ^ Pad a 
    950999         -> Pad -- ^ Pad b 
     
    10641113defined VUndef  = False 
    10651114defined _       = True 
    1066 -- |Return an undefined value (i.e. 'VUndef'). 
     1115-- | Produce an undefined Perl6 value (i.e. 'VUndef'). 
    10671116undef :: VScalar 
    10681117undef = VUndef