Changeset 2441 for src/Pugs/Types/Pair.hs
- Timestamp:
- 04/28/05 18:38:12 (4 years ago)
- svk:copy_cache_prev:
- 3914
- Files:
-
- 1 modified
-
src/Pugs/Types/Pair.hs (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/Pugs/Types/Pair.hs
r2323 r2441 1 {-# OPTIONS_GHC -fglasgow-exts #-}2 1 3 module Pugs.Types.Pair where 2 class (Typeable a) => PairClass a where 3 pair_iType :: a -> Type 4 pair_iType = const $ mkType "Pair" 5 pair_fetch :: a -> Eval VPair 6 pair_fetch pv = do 7 key <- pair_fetchKey pv 8 val <- pair_fetchVal pv 9 return (key, val) 10 pair_fetchKey :: a -> Eval VScalar 11 pair_fetchVal :: a -> Eval VScalar 12 pair_fetchVal pv = do 13 readIVar =<< pair_fetchElem pv 14 pair_storeVal :: a -> Val -> Eval () 15 pair_storeVal pv val = do 16 sv <- pair_fetchElem pv 17 writeIVar sv val 18 pair_fetchElem :: a -> Eval (IVar VScalar) 19 pair_fetchElem pv = do 20 return $ proxyScalar (pair_fetchVal pv) (pair_storeVal pv) 4 21 5 import {-# SOURCE #-} Pugs.AST 6 import Pugs.Internals 7 import Pugs.Types 8 9 class (Typeable a) => Class a where 10 iType :: a -> Type 11 iType = const $ mkType "Pair" 12 fetch :: a -> Eval VPair 13 fetch pv = do 14 key <- fetchKey pv 15 val <- fetchVal pv 22 instance PairClass VPair where 23 pair_fetchKey = return . fst 24 pair_fetchVal = return . snd 25 pair_storeVal pv val = do 26 ref <- fromVal (snd pv) 27 writeRef ref val 28 pair_fetch pv = do 29 key <- pair_fetchKey pv 30 val <- pair_fetchVal pv 16 31 return (key, val) 17 fetchKey :: a -> Eval VScalar 18 fetchVal :: a -> Eval VScalar 19 fetchVal pv = do 20 readIVar =<< fetchElem pv 21 storeVal :: a -> Val -> Eval () 22 storeVal pv val = do 23 sv <- fetchElem pv 24 writeIVar sv val 25 fetchElem :: a -> Eval (IVar VScalar) 26 fetchElem pv = do 27 return $ proxyScalar (fetchVal pv) (storeVal pv) 32 pair_fetchElem pv = do 33 return $ proxyScalar (pair_fetchVal pv) (pair_storeVal pv)
