Show
Ignore:
Timestamp:
04/28/05 18:38:12 (4 years ago)
Author:
autrijus
svk:copy_cache_prev:
3914
Message:

* AST.hs-boot elimianted!

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/Types/Scalar.hs

    r2221 r2441  
    1 {-# OPTIONS_GHC -fglasgow-exts #-} 
    21 
    3 module Pugs.Types.Scalar where 
     2class (Typeable a) => ScalarClass a where 
     3    scalar_iType :: a -> Type 
     4    scalar_iType = const $ mkType "Scalar" 
     5    scalar_fetch :: a -> Eval VScalar 
     6    scalar_store :: a -> VScalar -> Eval () 
    47 
    5 import {-# SOURCE #-} Pugs.AST 
    6 import Pugs.Internals 
    7 import Pugs.Types 
     8instance ScalarClass IScalarProxy where 
     9    scalar_iType = const $ mkType "Scalar::Proxy" 
     10    scalar_fetch = fst 
     11    scalar_store = snd 
    812 
    9 class (Typeable a) => Class a where 
    10     iType :: a -> Type 
    11     iType = const $ mkType "Scalar" 
    12     fetch :: a -> Eval VScalar 
    13     store :: a -> VScalar -> Eval () 
     13instance ScalarClass IScalar where 
     14    scalar_fetch = liftSTM . readTVar 
     15    scalar_store = (liftSTM .) . writeTVar 
     16 
     17instance ScalarClass IScalarLazy where 
     18    scalar_iType = const $ mkType "Scalar::Lazy" 
     19    scalar_fetch = return . maybe undef id 
     20    scalar_store _ v = retConstError v 
     21 
     22instance ScalarClass IScalarCwd where 
     23    scalar_iType = const $ mkType "Scalar::Cwd" 
     24    scalar_fetch _ = do 
     25        str <- liftIO $ getCurrentDirectory 
     26        return $ VStr str 
     27    scalar_store _ val = do 
     28        str <- fromVal val 
     29        tryIO () $ setCurrentDirectory str 
     30 
     31instance ScalarClass VScalar where 
     32    scalar_iType = const $ mkType "Scalar::Const" 
     33    scalar_fetch (VRef ref) = readRef ref 
     34    scalar_fetch v = return v 
     35    scalar_store _ v = retConstError v 
     36