Show
Ignore:
Timestamp:
07/10/05 16:32:40 (4 years ago)
Author:
autrijus
svk:copy_cache_prev:
7349
Message:

* Lambdas and Camels, I present... precompiled Prelude!

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/Compile/Pugs.hs

    r5358 r5360  
    104104 
    105105instance Compile (String, [(TVar Bool, TVar VRef)]) where 
    106     compile ((_:'?':_), _) = return empty -- XXX - @?S etc; punt for now 
    107     compile ((_:'*':_), _) = return empty -- XXX - @*INIT etc; punt for now 
    108     compile ((_:'=':_), _) = return empty -- XXX - @=POS etc; punt for now 
     106    compile ((':':'*':_), _) = return empty -- XXX - :*Bool etc; punt for now 
    109107    compile (n, tvars) = do 
    110         tvarsC <- compile tvars 
    111         return $ prettyDo  
    112                 [ prettyBind "tvars" (text "sequence" `sep1` tvarsC) 
     108        tvarsC <- fmap (filter (not . isEmpty)) $ mapM compile tvars 
     109        if null tvarsC then return empty else do 
     110        return $ prettyDo  
     111                [ prettyBind "tvars" (text "sequence" `sep1` prettyList tvarsC) 
    113112                , text ("return (" ++ show n ++ ", tvars)") 
    114113                ] 
     
    121120        freshC <- compile fresh 
    122121        tvarC  <- compile tvar 
     122        if isEmpty tvarC then return empty else do 
    123123        return $ prettyDo  
    124124                [ prettyBind "fresh" freshC 
     
    136136        vref    <- liftSTM $ readTVar fresh 
    137137        vrefC   <- compile vref 
     138        if isEmpty vrefC then return empty else do 
    138139        return $ prettyDo 
    139140            [ prettyBind "vref" vrefC 
     
    145146        vsub    <- code_fetch cv 
    146147        vsubC   <- compile vsub 
     148        if isEmpty vsubC then return empty else do 
    147149        return $ prettyDo 
    148150            [ prettyBind "vsub" vsubC 
     
    152154        sv  <- scalar_fetch sv 
    153155        svC <- compile sv 
     156        if isEmpty svC then return empty else do 
    154157        return $ prettyDo 
    155158            [ prettyBind "sv" svC 
     
    168171    compile x = return $ text "return" $+$ parens (text $ show x) 
    169172 
    170 -- This wants a total rewrite.  I strongly want Data.Generics at this point now. 
     173-- We need a compile VObject! 
    171174 
    172175-- Haddock can't cope with Template Haskell 
    173176instance Compile VCode where 
    174     compile MkCode{ subBody = Prim _ } = return $ text "return mkPrim" 
     177    -- compile MkCode{ subBody = Prim _ } = return $ text "return mkPrim" 
     178    compile MkCode{ subBody = Prim _ } = return empty 
    175179    compile code = do  
    176180        bodyC <- compile $ subBody code