Changeset 6229

Show
Ignore:
Timestamp:
08/13/05 21:16:15 (3 years ago)
Author:
autrijus
svk:copy_cache_prev:
8452
Message:

* de-GADT PIL structure -- likely to break all PIL2JS work

Location:
src/Pugs
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/CodeGen/PIL.hs

    r5891 r6229  
    55import Pugs.Internals 
    66import Pugs.AST 
    7 import Emit.PIR 
    87import Pugs.Compile 
    98 
     
    1211    glob        <- askGlobal 
    1312    main        <- asks envBody 
    14     globPIL     <- compile glob :: Eval [PIL Decl] 
    15     mainPIL     <- compile main :: Eval (PIL [Stmt]) 
     13    globPIL     <- compile glob :: Eval [PIL_Decl] 
     14    mainPIL     <- compile main :: Eval PIL_Stmts 
    1615    return . VStr . unlines $ 
    1716        [ "PIL_Environment" 
  • src/Pugs/CodeGen/PIR.hs

    r5891 r6229  
    99    statements, etc.) to an abstract syntax tree ('PIL' -- Pugs Intermediate 
    1010    Language) using the 'compile' function and 'Compile' class, and then 
    11     translate the PIL to a data structure of type 'PIR' using the 'trans' 
     11    translate the PIL_to a data structure of type 'PIR' using the 'trans' 
    1212    function and 'Translate' class. This data structure is then reduced to 
    1313    final PIR code by "Emit.PIR". 
     
    4545    ++ (show $ typeOf (undefined :: b)) 
    4646 
    47 instance (Typeable a) => Translate (PIL a) a where 
     47instance Translate PIL_Stmts [Stmt] where 
    4848    trans PNil = return [] 
     49    trans (PStmts this rest) = do 
     50        thisC   <- trans this 
     51        tell [thisC] 
     52        trans rest 
     53    trans (PPad SMy pad exps) = do 
     54        valsC   <- mapM trans (map snd pad) 
     55        pass $ do 
     56            expsC   <- trans exps 
     57            return ([], (StmtPad (map fst pad `zip` valsC) expsC:)) 
     58    trans (PPad _ pad exps) = do 
     59        -- XXX - maybe warn about bad pads? 
     60        trans (PPad SMy pad exps) 
     61 
     62instance Translate PIL_Stmt Stmt where 
    4963    trans PNoop = return (StmtComment "") 
     64    trans (PStmt (PLit (PVal VUndef))) = return $ StmtComment "" 
     65    trans (PStmt exp) = do 
     66        expC    <- trans exp 
     67        return $ StmtIns $ InsExp expC 
    5068    trans (PPos pos exp rest) = do 
    5169        dep     <- asks tTokDepth 
     
    5472        tell [StmtComment $ (replicate dep ' ') ++ "}}} " ++ pretty pos] 
    5573        return expC 
     74 
     75instance Translate PIL_Expr Expression where 
     76    trans (PRawName name) = fmap ExpLV $ genName name 
     77    trans (PExp exp) = fmap ExpLV $ trans exp 
    5678    trans (PLit (PVal VUndef)) = do 
    5779        pmc     <- genLV "undef" 
     
    6385        tellIns $ pmc <== ExpLit litC 
    6486        return $ ExpLV pmc 
     87    trans (PThunk exp) = do 
     88        [begL, sndL, retL, endL] <- genLabel ["thunkBegin", "thunkAgain", "thunkReturn", "thunkEnd"] 
     89        this    <- genPMC "block" 
     90        tellIns $ "newsub" .- [reg this, bare ".Continuation", bare begL] 
     91        tellIns $ "goto" .- [bare endL] 
     92        tellLabel begL 
     93        cc      <- genPMC "cc" 
     94        fetchCC cc (reg this) 
     95        expC    <- trans exp 
     96        tellIns $ "set_addr" .- [reg this, bare sndL] 
     97        tellIns $ "goto" .- [bare retL] 
     98        tellLabel sndL 
     99        fetchCC cc (reg this) 
     100        tellLabel retL 
     101        tellIns $ if parrotBrokenXXX 
     102            then "store_global" .- [tempSTR, expC] 
     103            else "set_args" .- [lit "(0b10)", expC] 
     104        tellIns $ "invoke" .- [reg cc] 
     105        tellLabel endL 
     106        return (ExpLV this) 
     107    trans (PCode styp params body) = do 
     108        [begL, endL] <- genLabel ["blockBegin", "blockEnd"] 
     109        this    <- genPMC "block" 
     110        tellIns $ "newsub" .- [reg this, bare ".Closure", bare begL] 
     111        tellIns $ "goto" .- [bare endL] 
     112        tellLabel begL 
     113        let prms = map tpParam params 
     114        mapM_ (tellIns . InsLocal RegPMC . prmToIdent) prms 
     115        tellIns $ "get_params" .- sigList (map prmToSig prms) 
     116        tellIns $ "new_pad" .- [lit curPad] 
     117        wrapSub styp $ do 
     118            mapM storeLex params 
     119            trans body  -- XXX - consistency check 
     120            bodyC   <- lastPMC 
     121            tellIns $ "set_returns" .- retSigList [bodyC] 
     122            tellIns $ "returncc" .- [] 
     123        tellLabel endL 
     124        return (ExpLV this) 
     125 
     126instance Translate PIL_Decl Decl where 
     127    trans (PSub name styp params body) | Just (pkg, name') <- isQualified name = do 
     128        declC <- trans $ PSub name' styp params body 
     129        return $ DeclNS pkg [declC] 
     130    trans (PSub name styp params body) = do 
     131        (_, stmts)  <- listen $ do 
     132            let prms = map tpParam params 
     133            mapM_ (tellIns . InsLocal RegPMC . prmToIdent) prms 
     134            tellIns $ "get_params" .- sigList (map prmToSig prms) 
     135            tellIns $ "new_pad" .- [lit curPad] 
     136            wrapSub styp $ do 
     137                mapM storeLex params 
     138                trans body 
     139                bodyC <- lastPMC 
     140                tellIns $ "set_returns" .- retSigList [bodyC] 
     141                tellIns $ "returncc" .- [] 
     142        return (DeclSub name [] stmts) 
     143 
     144instance Translate PIL_Literal Literal where 
    65145    trans (PVal (VBool bool)) = return $ LitInt (toInteger $ fromEnum bool) 
    66146    trans (PVal (VStr str)) = return $ LitStr str 
     
    70150    trans (PVal (VList [])) = return $ LitInt 0 -- XXX Wrong 
    71151    trans val@(PVal _) = transError val 
     152 
     153instance Translate PIL_LValue LValue where 
    72154    trans (PVar name) | Just (pkg, name') <- isQualified name = do 
    73155        -- XXX - this is terribly ugly.  Fix at parrot side perhaps? 
     
    88170        tellIns $ pmc <-- "find_name" $ [lit $ possiblyFixOperatorName name] 
    89171        return pmc 
    90     trans (PStmt (PLit (PVal VUndef))) = return $ StmtComment "" 
    91     trans (PStmt exp) = do 
    92         expC    <- trans exp 
    93         return $ StmtIns $ InsExp expC 
    94172    trans (PAssign [lhs] rhs) = do 
    95173        lhsC    <- enter tcLValue $ trans lhs 
     
    107185        tellIns $ lhsC <:= rhsC 
    108186        return lhsC 
    109     trans (PStmts this rest) = do 
    110         thisC   <- trans this 
    111         tell [thisC] 
    112         trans rest 
    113187    trans (PApp _ exp@(PCode _ _ _) Nothing []) = do 
    114188        blockC  <- trans exp 
     
    143217                return pmc 
    144218        -} 
    145     trans (PPad SMy pad exps) = do 
    146         valsC   <- mapM trans (map snd pad) 
    147         pass $ do 
    148             expsC   <- trans exps 
    149             return ([], (StmtPad (map fst pad `zip` valsC) expsC:)) 
    150     trans (PExp exp) = fmap ExpLV $ trans exp 
    151     trans (PCode styp params body) = do 
    152         [begL, endL] <- genLabel ["blockBegin", "blockEnd"] 
    153         this    <- genPMC "block" 
    154         tellIns $ "newsub" .- [reg this, bare ".Closure", bare begL] 
    155         tellIns $ "goto" .- [bare endL] 
    156         tellLabel begL 
    157         let prms = map tpParam params 
    158         mapM_ (tellIns . InsLocal RegPMC . prmToIdent) prms 
    159         tellIns $ "get_params" .- sigList (map prmToSig prms) 
    160         tellIns $ "new_pad" .- [lit curPad] 
    161         wrapSub styp $ do 
    162             mapM storeLex params 
    163             trans body  -- XXX - consistency check 
    164             bodyC   <- lastPMC 
    165             tellIns $ "set_returns" .- retSigList [bodyC] 
    166             tellIns $ "returncc" .- [] 
    167         tellLabel endL 
    168         return (ExpLV this) 
    169     trans (PThunk exp) = do 
    170         [begL, sndL, retL, endL] <- genLabel ["thunkBegin", "thunkAgain", "thunkReturn", "thunkEnd"] 
    171         this    <- genPMC "block" 
    172         tellIns $ "newsub" .- [reg this, bare ".Continuation", bare begL] 
    173         tellIns $ "goto" .- [bare endL] 
    174         tellLabel begL 
    175         cc      <- genPMC "cc" 
    176         fetchCC cc (reg this) 
    177         expC    <- trans exp 
    178         tellIns $ "set_addr" .- [reg this, bare sndL] 
    179         tellIns $ "goto" .- [bare retL] 
    180         tellLabel sndL 
    181         fetchCC cc (reg this) 
    182         tellLabel retL 
    183         tellIns $ if parrotBrokenXXX 
    184             then "store_global" .- [tempSTR, expC] 
    185             else "set_args" .- [lit "(0b10)", expC] 
    186         tellIns $ "invoke" .- [reg cc] 
    187         tellLabel endL 
    188         return (ExpLV this) 
    189     trans (PRawName name) = fmap ExpLV $ genName name 
    190     trans (PSub name styp params body) | Just (pkg, name') <- isQualified name = do 
    191         declC <- trans $ PSub name' styp params body 
    192         return $ DeclNS pkg [declC] 
    193     trans (PSub name styp params body) = do 
    194         (_, stmts)  <- listen $ do 
    195             let prms = map tpParam params 
    196             mapM_ (tellIns . InsLocal RegPMC . prmToIdent) prms 
    197             tellIns $ "get_params" .- sigList (map prmToSig prms) 
    198             tellIns $ "new_pad" .- [lit curPad] 
    199             wrapSub styp $ do 
    200                 mapM storeLex params 
    201                 trans body 
    202                 bodyC <- lastPMC 
    203                 tellIns $ "set_returns" .- retSigList [bodyC] 
    204                 tellIns $ "returncc" .- [] 
    205         return (DeclSub name [] stmts) 
    206219    trans x = transError x 
    207220 
     
    372385            , InsNew tempPMC PerlScalar 
    373386            , "store_global"    .- [lit "$_", tempPMC] 
    374             ]) ++ [ StmtRaw (text (name ++ "()")) | PSub name@('_':'_':_) _ _ _ <- globPIL ] ++ 
     387            ]) ++ [ StmtRaw (text (name ++ "()")) | PSub name@('_':'_':_) _ _ _ <- globPIL] ++ 
    375388            [ StmtRaw (text "main()") 
    376389            , StmtIns $ tempPMC  <-- "find_global" $ [lit "Perl6::Internals", lit "&exit"] 
     
    386399        } 
    387400 
    388 runCodeGenGlob :: TEnv -> [PIL Decl] -> Eval [Decl] 
     401runCodeGenGlob :: TEnv -> [PIL_Decl] -> Eval [Decl] 
    389402runCodeGenGlob tenv = mapM $ fmap fst . runCodeGen tenv 
    390403 
    391 runCodeGenMain :: TEnv -> PIL [Stmt] -> Eval [Stmt] 
     404runCodeGenMain :: TEnv -> PIL_Stmts -> Eval [Stmt] 
    392405runCodeGenMain tenv = fmap snd . runCodeGen tenv 
    393406 
  • src/Pugs/Compile.hs

    r6195 r6229  
    1212 
    1313module Pugs.Compile ( 
    14     PIL(..), 
     14    PIL_Stmts(..), PIL_Stmt(..), PIL_Expr(..), PIL_Decl(..), PIL_Literal(..), PIL_LValue(..), 
    1515    Compile(..), 
    1616    TEnv(..), initTEnv, 
     
    3535-} 
    3636 
    37 #ifndef HADDOCK 
    38 -- Type-indexed with GADT; it is a bit too baroque -- refactor toward ANF? 
    39 data (Typeable a) => PIL a where 
    40     PNil        :: PIL [a] 
    41     PNoop       :: PIL Stmt 
    42  
    43     PPos        :: !Pos -> !Exp -> !(PIL a) -> PIL a 
    44     PRawName    :: !VarName -> PIL Expression -- XXX HACK! 
    45  
    46     PVal        :: !Val -> PIL Literal 
    47     PVar        :: !VarName -> PIL LValue 
    48  
    49     PExp        :: !(PIL LValue) -> PIL Expression  
    50     PLit        :: !(PIL Literal) -> PIL Expression 
    51     PThunk      :: !(PIL Expression) -> PIL Expression  
    52     PCode       :: !SubType -> ![TParam] -> !(PIL [Stmt]) -> PIL Expression  
    53  
    54     PStmt       :: !(PIL Expression) -> PIL Stmt  
    55     PStmts      :: !(PIL Stmt) -> !(PIL [Stmt]) -> PIL [Stmt] 
    56  
    57     PApp        :: !TCxt -> !(PIL Expression) -> !(Maybe (PIL Expression)) -> ![PIL Expression] -> PIL LValue 
    58     PAssign     :: ![PIL LValue] -> !(PIL Expression) -> PIL LValue 
    59     PBind       :: ![PIL LValue] -> !(PIL Expression) -> PIL LValue 
    60  
    61     -- The New Pad: Occurs at whenever a variable may occur 
    62     --    PPad  :: !Scope -> !VarName -> PIL LValue 
    63  
    64     PPad        :: !Scope -> ![(VarName, PIL Expression)] -> !(PIL [Stmt]) -> PIL [Stmt] 
    65     PSub        :: !SubName -> !SubType -> ![TParam] -> !(PIL [Stmt]) -> PIL Decl 
    66 #endif 
    67  
    68 instance Typeable1 PIL where 
    69     typeOf1 _ = typeOf () 
     37data PIL_Stmts = PNil 
     38    | PStmts 
     39        { pStmt  :: !PIL_Stmt 
     40        , pStmts :: !PIL_Stmts 
     41        } 
     42    | PPad 
     43        { pScope :: !Scope 
     44        , pSyms  :: ![(VarName, PIL_Expr)] 
     45        , pStmts :: !PIL_Stmts 
     46        } 
     47    deriving (Show, Eq, Ord, Typeable) 
     48 
     49data PIL_Stmt = PNoop | PStmt { pExpr :: !PIL_Expr } | PPos 
     50        { pPos  :: !Pos 
     51        , pExp  :: !Exp 
     52        , pNode :: !PIL_Stmt 
     53        } 
     54    deriving (Show, Eq, Ord, Typeable) 
     55 
     56data PIL_Expr 
     57    = PRawName { pRawName :: !VarName } 
     58    | PExp { pLV  :: !PIL_LValue } 
     59    | PLit { pLit :: !PIL_Literal } 
     60    | PThunk { pThunk :: !PIL_Expr } 
     61    | PCode 
     62        { pType    :: !SubType 
     63        , pParams  :: ![TParam] 
     64        , pBody    :: !PIL_Stmts 
     65        } 
     66    deriving (Show, Eq, Ord, Typeable) 
     67 
     68data PIL_Decl = PSub 
     69    { pSubName      :: !SubName 
     70    , pSubType      :: !SubType 
     71    , pSubParams    :: ![TParam] 
     72    , pSubBody      :: !PIL_Stmts 
     73    } 
     74    deriving (Show, Eq, Ord, Typeable) 
     75 
     76data PIL_Literal = PVal { pVal :: Val } 
     77    deriving (Show, Eq, Ord, Typeable) 
     78 
     79data PIL_LValue = PVar { pVarName :: !VarName } 
     80    | PApp  
     81        { pCxt  :: !TCxt 
     82        , pFun  :: !PIL_Expr 
     83        , pInv  :: !(Maybe PIL_Expr) 
     84        , pArgs :: ![PIL_Expr] 
     85        } 
     86    | PAssign 
     87        { pLHS  :: ![PIL_LValue] 
     88        , pRHS  :: !PIL_Expr 
     89        } 
     90    | PBind 
     91        { pLHS  :: ![PIL_LValue] 
     92        , pRHS  :: !PIL_Expr 
     93        } 
     94    deriving (Show, Eq, Ord, Typeable) 
    7095 
    7196data TParam = MkTParam 
    7297    { tpParam   :: !Param 
    73     , tpDefault :: !(Maybe (PIL Expression)) 
     98    , tpDefault :: !(Maybe (PIL_Expr)) 
    7499    } 
    75     deriving (Show, Typeable) 
     100    deriving (Show, Eq, Ord, Typeable) 
    76101 
    77102data TCxt 
    78103    = TCxtVoid | TCxtLValue !Type | TCxtItem !Type | TCxtSlurpy !Type 
    79104    | TTailCall !TCxt 
    80     deriving (Show, Eq, Typeable) 
     105    deriving (Show, Eq, Ord, Typeable) 
    81106 
    82107tcVoid, tcLValue :: TCxt 
     
    89114tcSlurpy    = TCxtSlurpy anyType 
    90115-} 
    91  
    92 instance Show (PIL a) where 
    93     show (PVal x) = "(PVal " ++ show x ++ ")" 
    94     show (PVar x) = "(PVar " ++ show x ++ ")" 
    95     show (PLit x) = "(PLit " ++ show x ++ ")" 
    96     show (PStmts x y) = "(PStmts " ++ show x ++ " " ++ show y ++ ")" 
    97     show PNil = "PNil" 
    98     show PNoop = "PNoop" 
    99     -- We don't show the raw Exp here to ease writing parsers for PIL (Exp 
    100     -- contains things like MkEnv, etc.). 
    101     show (PPos x _ z) = "(PPos " ++ show x ++ " Noop " ++ show z ++ ")" 
    102     show (PApp x y i z) = "(PApp " ++ show x ++ " " ++ show y ++ " " ++ show i ++ " " ++ show z ++ ")" 
    103     show (PExp x) = "(PExp " ++ show x ++ ")" 
    104     show (PStmt x) = "(PStmt " ++ show x ++ ")" 
    105     show (PAssign x y) = "(PAssign " ++ show x ++ " " ++ show y ++ ")" 
    106     show (PBind x y) = "(PBind " ++ show x ++ " " ++ show y ++ ")" 
    107     show (PThunk x) = "(PThunk " ++ show x ++ ")" 
    108     show (PRawName x) = "(PRawName " ++ show x ++ ")" 
    109     show (PPad x y z) = unwords ["(PPad", show x, show y, show z, ")"] 
    110     show (PCode x y z) = unwords ["(PCode", show x, show y, show z, ")"] 
    111     show (PSub x y z w) = unwords ["(PSub", show x, show y, show z, show w, ")"] 
    112116 
    113117data TEnv = MkTEnv 
     
    118122    , tLabel    :: !(TVar Int)          -- ^ Label name supply 
    119123    } 
    120     deriving (Show, Eq) 
     124    deriving (Show, Eq, Ord, Typeable) 
    121125 
    122126type Comp a = Eval a 
     
    129133 
    130134-- Compile instances 
    131 instance Compile (Var, [(TVar Bool, TVar VRef)]) (PIL Decl) where 
     135instance Compile (Var, [(TVar Bool, TVar VRef)]) (PIL_Decl) where 
    132136    compile = compError 
    133137 
     
    142146            } 
    143147 
    144 {-| Compiles a 'Pad' to a list of 'PIL Decl's. Currently, only subroutines and 
     148{-| Compiles a 'Pad' to a list of 'PIL_Decl's. Currently, only subroutines and 
    145149    @\@*END@ are compiled. -} 
    146 instance Compile Pad [PIL Decl] where 
     150instance Compile Pad [PIL_Decl] where 
    147151    compile pad = do 
    148152        entries' <- mapM canCompile entries 
     
    164168            cvList  <- fromVals =<< readRef ref :: Comp [VCode] 
    165169            decls   <- eachM cvList $ \(i, cv) -> do 
    166                 compile (("&*END_" ++ show i), cv) :: Comp [PIL Decl] 
     170                compile (("&*END_" ++ show i), cv) :: Comp [PIL_Decl] 
    167171            compile ("&*END", concat decls) 
    168172        canCompile ((_:twigil:_), _) | not (isAlphaNum twigil) = return [] 
     
    186190eachM = forM . ([0..] `zip`) 
    187191 
    188 instance Compile (SubName, [PIL Decl]) [PIL Decl] where 
     192instance Compile (SubName, [PIL_Decl]) [PIL_Decl] where 
    189193    compile (name, decls) = do 
    190194        let bodyC = [ PStmts . PStmt . PExp $ PApp tcVoid (PExp (PVar sub)) Nothing [] 
     
    193197        return (PSub name SubPrim [] (combine bodyC PNil):decls) 
    194198 
    195 instance Compile (SubName, VCode) [PIL Decl] where 
     199instance Compile (SubName, VCode) [PIL_Decl] where 
    196200    compile (name, vsub) | packageOf name /= packageOf (subName vsub) = do 
    197201        let storeC  = PBind [PVar $ qualify name] (PExp . PVar . qualify $ subName vsub) 
     
    206210        return [PSub name (subType vsub) paramsC bodyC] 
    207211 
    208 instance Compile (String, [(TVar Bool, TVar VRef)]) (PIL Expression) where 
     212instance Compile (String, [(TVar Bool, TVar VRef)]) (PIL_Expr) where 
    209213    compile (name, _) = return $ PRawName name 
    210214 
    211 instance Compile Exp (PIL [Stmt]) where 
    212     compile (Pos pos rest) = fmap (PPos pos rest) $ compile rest 
     215instance Compile Exp (PIL_Stmts) where 
     216    compile (Pos _ rest) = compile rest -- fmap (PPos pos rest) $ compile rest 
    213217    compile (Cxt cxt rest) = enter cxt $ compile rest 
    214218    compile (Stmts (Pad SOur _ exp) rest) = do 
     
    229233    enter cxt = local (\e -> e{ envContext = cxt }) 
    230234 
    231 compileStmts :: Exp -> Comp (PIL [Stmt]) 
     235compileStmts :: Exp -> Comp (PIL_Stmts) 
    232236compileStmts exp = case exp of 
    233237    Stmts this Noop -> do 
     
    250254    _           -> compile (Stmts exp Noop) 
    251255 
    252 instance Compile Val (PIL Stmt) where 
     256instance Compile Val (PIL_Stmt) where 
    253257    compile = fmap PStmt . compile . Val 
    254258 
    255 instance Compile Val (PIL Expression) where 
     259instance Compile Val (PIL_Expr) where 
    256260    compile = compile . Val 
    257261 
    258 instance Compile Exp (PIL Stmt) where 
     262instance Compile Exp (PIL_Stmt) where 
    259263    compile (Pos pos rest) = fmap (PPos pos rest) $ compile rest 
    260264    compile (Cxt cxt rest) = enter cxt $ compile rest 
     
    299303    compile exp = fmap PStmt $ compile exp 
    300304 
    301 pBlock :: PIL [Stmt] -> PIL Expression 
     305pBlock :: PIL_Stmts -> PIL_Expr 
    302306pBlock = PCode SubBlock [] 
    303307 
     
    330334    compile x = compError x 
    331335 
    332 instance Compile Exp (PIL LValue) where 
    333     compile (Pos pos rest) = fmap (PPos pos rest) $ compile rest 
     336instance Compile Exp (PIL_LValue) where 
     337    compile (Pos _ rest) = compile rest -- fmap (PPos pos rest) $ compile rest 
    334338    compile (Cxt cxt rest) = enter cxt $ compile rest 
    335339    compile (Var name) = return $ PVar name 
     
    391395    compile exp = compError exp 
    392396 
    393 compLoop :: Exp -> Comp (PIL Stmt) 
     397compLoop :: Exp -> Comp (PIL_Stmt) 
    394398compLoop (Syn name [cond, body]) = do 
    395399    cxt     <- askTCxt 
     
    403407    appropriate function call (@&statement_control:if@ or 
    404408    @&statement_control:unless@). -} 
    405 compConditional :: Exp -> Comp (PIL LValue) 
     409compConditional :: Exp -> Comp (PIL_LValue) 
    406410compConditional (Syn name exps) = do 
    407411    [condC, trueC, falseC] <- compile exps 
     
    411415compConditional exp = compError exp 
    412416 
    413 {-| Compiles various 'Exp's to 'PIL Expression's. -} 
    414 instance Compile Exp (PIL Expression) where 
    415     compile (Pos pos rest) = fmap (PPos pos rest) $ compile rest 
     417{-| Compiles various 'Exp's to 'PIL_Expr's. -} 
     418instance Compile Exp (PIL_Expr) where 
     419    compile (Pos _ rest) = compile rest -- fmap (PPos pos rest) $ compile rest 
    416420    compile (Cxt cxt rest) = enter cxt $ compile rest 
    417421    compile (Var name) = return . PExp $ PVar name 
     
    442446    ++ (show $ typeOf (undefined :: b)) 
    443447 
    444 {-| Compiles a 'Val' to a 'PIL Literal'. -} 
    445 instance Compile Val (PIL Literal) where 
     448{-| Compiles a 'Val' to a 'PIL_Literal'. -} 
     449instance Compile Val (PIL_Literal) where 
    446450    compile val = return $ PVal val 
    447451