Changeset 3724

Show
Ignore:
Timestamp:
05/23/05 13:09:12 (4 years ago)
Author:
scook0
svk:copy_cache_prev:
5313
Message:

* Some non-toplevel function type signatures (for readability)
* Minor tweaks to Haddocks

Location:
src
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • src/Main.hs

    r3675 r3724  
    3232import Data.IORef 
    3333 
    34 -- |Pugs' entry point. Uses 'Pugs.Run.runWithArgs' to normalise the command-line 
    35 -- arguments and pass them to 'run'. 
     34{-| 
     35Pugs' entry point. Uses 'Pugs.Run.runWithArgs' to normalise the command-line 
     36arguments and pass them to 'run'. 
     37-} 
    3638main :: IO () 
    3739main = do 
     
    135137            CmdReset          -> tabulaRasa >>= (liftSTM . writeTVar env) >> loop 
    136138 
    137 -- |Create a \'blank\' 'Env' for our program to execute in. Of course, 
    138 -- 'prepareEnv' actually declares quite a few symbols in the environment, 
    139 -- e.g. \'\@\*ARGS\', \'\$\*PID\', \'\$\*ERR\' etc. 
    140 -- ('Tabula rasa' is Latin for 'a blank slate'.) 
     139{-| 
     140Create a \'blank\' 'Env' for our program to execute in. Of course, 
     141'prepareEnv' actually declares quite a few symbols in the environment, 
     142e.g. \'\@\*ARGS\', \'\$\*PID\', \'\$\*ERR\' etc. 
     143 
     144('Tabula rasa' is Latin for 'a blank slate'.) 
     145-} 
    141146tabulaRasa :: IO Env 
    142147tabulaRasa = prepareEnv "<interactive>" [] 
  • src/Pugs/AST/Internals.hs

    r3690 r3724  
    287287        doFrom $ concat list 
    288288        where 
     289        doFrom :: [Val] -> Eval [VPair] 
    289290        doFrom [] = return [] 
    290291        doFrom (k:v:list) = do 
     
    574575    , juncDup  :: !(Set Val) 
    575576    -- ^ Only used for @one()@ junctions. Contains those values 
    576     -- that appear more than once (the actual count is 
    577     -- irrelevant), since matching any of these would 
    578     -- automatically violate the 'match /only/ one value' 
    579     -- junctive semantics. 
     577    --     that appear more than once (the actual count is 
     578    --     irrelevant), since matching any of these would 
     579    --     automatically violate the 'match /only/ one value' 
     580    --     junctive semantics. 
    580581    , juncSet  :: !(Set Val) 
    581582    -- ^ Set of values that make up the junction. In @one()@ 
    582     -- junctions, contains the set of values that appear exactly 
    583     -- /once/. 
     583    --     junctions, contains the set of values that appear exactly 
     584    --     /once/. 
    584585    } deriving (Eq, Ord) 
    585586 
     
    10881089--     askGlobal :: m Pad 
    10891090 
     1091{-| 
     1092Retrieve the global 'Pad' from the current evaluation environment. 
     1093 
     1094'Env' stores the global 'Pad' in an STM variable, so we have to @asks@ 
     1095'Eval'\'s @ReaderT@ for the variable, then extract the pad itself from the 
     1096STM var. 
     1097-} 
    10901098askGlobal :: Eval Pad 
    10911099askGlobal = do 
  • src/Pugs/Eval.hs

    r3709 r3724  
    5858         => String             -- ^ Name associated with the environment 
    5959         -> [STM (Pad -> Pad)] -- ^ List of 'Pad'-mutating transactions used 
    60                                -- to declare an initial set of global vars 
     60                               --     to declare an initial set of global vars 
    6161         -> m Env 
    6262emptyEnv name genPad = do 
     
    224224    | otherwise = doFindVarRef name 
    225225    where 
     226    doFindVarRef :: Var -> Eval (Maybe (TVar VRef)) 
    226227    doFindVarRef name = do 
    227228        callCC $ \foundIt -> do 
     
    665666    _ -> retError "Unknown syntactic construct" exp 
    666667    where 
     668    doCond :: (Bool -> Bool) -> Eval Val 
    667669    doCond f = do 
    668670        let [cond, bodyIf, bodyElse] = exps 
     
    673675            else reduce bodyElse 
    674676    -- XXX This treatment of while/until loops probably needs work 
     677    doWhileUntil :: (Bool -> Bool) -> Eval Val 
    675678    doWhileUntil f = do 
    676679        let [cond, body] = exps 
     
    722725        shiftT $ const (retVal val) 
    723726    where 
     727    callerEnv :: Env -> Env 
    724728    callerEnv env = let caller = maybe env id (envCaller env) in 
    725729        env{ envCaller  = envCaller caller 
     
    750754    where 
    751755    err = retError "No compatible subroutine found" name 
     756    applySub :: VCode -> [Exp] -> [Exp] -> Eval Val 
    752757    applySub sub invs args 
    753758        -- list-associativity 
     
    770775        | otherwise 
    771776        = apply sub invs args 
     777    mungeChainSub :: VCode -> [Exp] -> Eval Val 
    772778    mungeChainSub sub invs = do 
    773779        let MkCode{ subAssoc = "chain", subParams = (p:_) } = sub 
     
    777783            Just sub'    -> applyChainSub sub invs sub' invs' args' rest 
    778784            Nothing      -> apply sub{ subParams = (length invs) `replicate` p } invs [] -- XXX Wrong 
     785    applyChainSub :: VCode -> [Exp] -> VCode -> [Exp] -> [a] -> [Exp] -> Eval Val 
    779786    applyChainSub sub invs sub' invs' args' rest 
    780787        | MkCode{ subAssoc = "chain", subBody = fun, subParams = prm }   <- sub 
     
    10441051-- XXX - faking application of lexical contexts 
    10451052-- XXX - what about defaulting that depends on a junction? 
    1046 -- |Apply a sub (or other code) to lists of invocants 
    1047 -- and arguments, in the specified context. 
     1053{-| 
     1054Apply a sub (or other code) to lists of invocants and arguments, in the  
     1055specified context. 
     1056-} 
    10481057doApply :: Env   -- ^ Environment to evaluate in 
    10491058        -> VCode -- ^ Code to apply 
     
    10781087        | typ >= SubBlock = id 
    10791088        | otherwise       = resetT 
     1089    fixEnv :: Env -> Env 
    10801090    fixEnv env 
    10811091        | typ >= SubBlock = env 
     
    11171127                    return (VRef ref) 
    11181128        return (val, (isSlurpyCxt cxt || isCollapsed (typeOfCxt cxt))) 
     1129    checkSlurpyLimit :: (VInt, Exp) -> Eval [Val] 
    11191130    checkSlurpyLimit (n, exp) = do 
    11201131        listVal <- enterLValue $ enterEvalContext (cxtItem "Array") exp 
     
    11221133        elms    <- mapM fromVal list -- flatten 
    11231134        return $ genericDrop n (concat elms :: [Val]) 
     1135    isCollapsed :: Type -> Bool 
    11241136    isCollapsed typ 
    11251137        | isaType (envClasses env) "Bool" typ        = True 
  • src/Pugs/Monads.hs

    r3464 r3724  
    169169    where 
    170170    typ = subType sub 
     171    doCC :: (Val -> Eval b) -> [Val] -> Eval b 
    171172    doCC cc [v] = cc =<< evalVal v 
    172173    doCC _  _   = internalError "enterSub: doCC list length /= 1" 
     174    orig :: VCode -> VCode 
    173175    orig sub = sub { subBindings = [], subParams = (map fst (subBindings sub)) } 
     176    fixEnv :: (Val -> Eval Val) -> Env -> Eval (Env -> Env) 
    174177    fixEnv cc env 
    175178        | typ >= SubBlock = do 
     
    191194                , envOuter   = maybe Nothing envOuter (subEnv sub) 
    192195                } 
     196    ccSub :: (Val -> Eval Val) -> Env -> VCode 
    193197    ccSub cc env = mkPrim 
    194198        { subName = "CALLER_CONTINUATION" 
  • src/Pugs/Run.hs

    r3663 r3724  
    2121import qualified Data.Map as Map 
    2222 
    23 -- |Run 'Main.run' with command line args.  
    24 -- See 'Main.main' and 'Pugs.Run.Args.canonicalArgs' 
     23{-| 
     24Run 'Main.run' with command line args.  
     25 
     26See 'Main.main' and 'Pugs.Run.Args.canonicalArgs' 
     27-} 
    2528runWithArgs :: ([String] -> IO t) -> IO t 
    2629runWithArgs f = do 
     
    3841runEnv env = runEvalMain env $ evaluateMain (envBody env) 
    3942 
    40 -- |Run for 'Pugs.Compile.Pugs' backend 
     43-- | Run for 'Pugs.Compile.Pugs' backend 
    4144runAST :: Pad -> Exp -> IO Val 
    4245runAST glob ast = do 
     
    5053    runEnv env{ envBody = ast, envGlobal = globRef, envDebug = Nothing } 
    5154 
    52 -- |Run for 'Pugs.Compile.Haskell' backend 
     55-- | Run for 'Pugs.Compile.Haskell' backend 
    5356runComp :: Eval Val -> IO Val 
    5457runComp comp = do 
     
    5962    runEvalMain env{ envDebug = Nothing } comp 
    6063 
    61 -- |Initialize globals and install primitives in an 'Env' 
     64-- | Initialize globals and install primitives in an 'Env' 
    6265prepareEnv :: VStr -> [VStr] -> IO Env 
    6366prepareEnv name args = do 
     
    133136        ] 
    134137 
    135 -- |Combine @%*ENV\<PERL6LIB\>@, -I, 'Pugs.Config.config' values and \".\" into 
    136 -- the @\@*INC@ list for 'Main.printConfigInfo' 
     138{-| 
     139Combine @%*ENV\<PERL6LIB\>@, -I, 'Pugs.Config.config' values and \".\" into 
     140the @\@*INC@ list for 'Main.printConfigInfo' 
     141-} 
    137142getLibs :: IO [String] 
    138143getLibs = do