Changeset 15439
- Timestamp:
- 03/04/07 14:40:43 (21 months ago)
- Files:
-
- 1 modified
-
src/Pugs/Class.hs (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Pugs/Class.hs
r15425 r15439 1 {-# OPTIONS_GHC -fglasgow-exts - cpp#-}1 {-# OPTIONS_GHC -fglasgow-exts -fparr #-} 2 2 3 3 {-| … … 24 24 import MO.Compile 25 25 import MO.Compile.Class 26 import MO.Util 26 import MO.Util hiding (traceM, traceShow) 27 27 import Pugs.Internals 28 28 import Pugs.AST.Eval 29 29 import Control.Monad.Fix 30 import qualified Data.Map as Map 31 import qualified Data.Typeable as Typeable 30 32 31 33 class (Show a, Typeable a, Ord a, Typeable1 m, Monad m) => Boxable m a | a -> m where … … 44 46 45 47 fromObj :: Invocant m -> m a 46 fromObj (MkInvocant x _) = fromTypeable x 48 fromObj (MkInvocant x _) = case Typeable.cast x of 49 Just y -> return y 50 _ -> fail $ "Cannot coerce from " ++ (show $ typeOf x) ++ " to " ++ (show $ typeOf (undefined :: a)) 47 51 48 52 (...) :: Boxable m b => String -> (a -> b) -> (ID, a -> m (Invocant m)) … … 110 114 } 111 115 112 (./) :: ( Typeable1 m, Monad m) => Invocant m -> ID -> m (Invocant m)113 inv ./ meth = ivDispatch inv $ MkMethodInvocation meth (mkArgs [])116 (./) :: ((:>:) (MethodInvocation Eval) a) => Invocant Eval -> a -> Eval (Invocant Eval) 117 x ./ y = ivDispatch x (cast y) 114 118 115 119 type PureClass = MI Eval … … 126 130 ] 127 131 132 instance ((:>:) (MethodInvocation Eval)) ByteString where 133 cast = (`MkMethodInvocation` CaptSub{ c_feeds = [::] }) . cast 134 135 instance ((:>:) (MethodInvocation Eval) (ByteString, [Invocant Eval], Map ID (Invocant Eval))) where 136 cast (meth, pos, named) = MkMethodInvocation (cast meth) CaptSub{ c_feeds = [: MkFeed (toP pos) (Map.map (\x -> [:x:]) named) :]} 137
