Changeset 15492
- Timestamp:
- 03/06/07 12:59:21 (21 months ago)
- Files:
-
- 1 modified
-
src/Pugs/Class.hs (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Pugs/Class.hs
r15490 r15492 69 69 asPrim f x _ = ivDispatch (mkVal x) f 70 70 71 -- Auto-generate pure instances from Eval instances 72 instance MethodPrimable (a -> b -> Eval z) a => MethodPrimable (a -> b -> z) a where 73 asPrim f = asPrim ((\x args -> return (f x args)) :: (a -> b -> Eval z)) 74 71 75 instance (Boxable a, Boxable z) => MethodPrimable (a -> z) a where 72 76 asPrim f x _ = return (mkVal (f x)) … … 75 79 asPrim f x _ = fmap mkVal (f x) 76 80 77 instance (Boxable a, Boxable z) => MethodPrimable (a -> Val -> z) a where78 asPrim f x args = return (mkVal (f x (args !: 0)))79 80 81 instance (Boxable a, Boxable z) => MethodPrimable (a -> Val -> Eval z) a where 81 82 asPrim f x args = fmap mkVal (f x (args !: 0)) 82 83 83 instance (Boxable a, Boxable z) => MethodPrimable (a -> [:Val:] -> z) a where84 asPrim f x args = return (mkVal (f x args))84 instance (Boxable a, Boxable z) => MethodPrimable (a -> [:Val:] -> Eval z) a where 85 asPrim f x args = fmap mkVal (f x args) 85 86 86 instance (Boxable a, Boxable z) => MethodPrimable (a -> [Val] -> z) a where87 asPrim f x args = return (mkVal (f x (cast args)))87 instance (Boxable a, Boxable z) => MethodPrimable (a -> [Val] -> Eval z) a where 88 asPrim f x args = fmap mkVal (f x (cast args)) 88 89 89 instance (Boxable a, Boxable b, Boxable z) => MethodPrimable (a -> [b] -> z) a where90 instance (Boxable a, Boxable b, Boxable z) => MethodPrimable (a -> [b] -> Eval z) a where 90 91 asPrim f x args = do 91 92 args' <- mapM coerceVal (cast args) 92 return (mkVal (f x args'))93 fmap mkVal (f x args') 93 94 94 instance (Boxable a, Boxable b, Boxable z) => MethodPrimable (a -> b -> z) a where95 instance (Boxable a, Boxable b, Boxable z) => MethodPrimable (a -> b -> Eval z) a where 95 96 asPrim f x args = do 96 97 y <- coerceVal (args !: 0) 97 return (mkVal (f x y))98 fmap mkVal (f x y) 98 99 99 100 (...) :: MethodPrimable a b => String -> a -> (ID, MethodPrim b)
