[project @ 1997-10-15 14:21:58 by simonm]
[ghc-hetmet.git] / ghc / tests / typecheck / should_compile / tc093.hs
diff --git a/ghc/tests/typecheck/should_compile/tc093.hs b/ghc/tests/typecheck/should_compile/tc093.hs
new file mode 100644 (file)
index 0000000..f9a5179
--- /dev/null
@@ -0,0 +1,25 @@
+module ShouldSucceed where
+
+data State c a = State (c -> (a,c))
+
+unState :: State c a -> (c -> (a,c))
+unState (State x) = x
+
+unitState :: a -> State c a
+unitState a = State (\s0 -> (a,s0))
+
+bindState :: State c a -> (a -> State c b) -> State c b
+bindState m k = State (\s0 -> let (a,s1) = (unState m) s0
+                                  (b,s2) = (unState (k a)) s1 
+                              in (b,s2))
+
+instance Eq c => Monad (State c) where
+    return = unitState 
+    (>>=)  = bindState 
+
+data TS = TS { vs::Int } deriving (Show,Eq)
+
+type St = State TS
+
+foo :: Int -> St Int  -- it works if this line is not given
+foo x = return x