Commit 66fb864a authored by simonpj's avatar simonpj
Browse files

[project @ 2005-04-04 12:04:18 by simonpj]

Add a test for rebindable do-notation syntax
parent 17e04c74
......@@ -13,3 +13,4 @@ test('rebindable3', normal, compile_and_run, [''])
test('rebindable4', normal, compile_and_run, [''])
test('rebindable5', normal, compile_and_run, [''])
test('rebindable6', normal, compile_and_run, [''])
test('rebindable7', normal, compile_and_run, [''])
{-# OPTIONS -fno-implicit-prelude #-}
-- This one tests rebindable syntax for do-notation
module Main where
import qualified Prelude
import GHC.Num
import GHC.Base hiding( Monad(..) )
class Foo a where
op :: a -> a
data T a = MkT a
instance Foo Int where
op x = x+1
(>>=) :: Foo a => T a -> (a -> T b) -> T b
(>>=) (MkT x) f = f (op x)
(>>) :: Foo a => T a -> T b -> T b
(>>) x y = x >>= (\_ -> y)
return :: Num a => a -> T a
return x = MkT (x+1)
fail :: String -> T a
fail s = error "urk"
t1 :: T Int
t1 = MkT 4
myt = do { x <- t1
; return x }
main = case myt of
MkT i -> Prelude.print i
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment