summaryrefslogtreecommitdiff
path: root/testsuite/tests/typecheck/should_run/T1735_Help/Context.hs
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/tests/typecheck/should_run/T1735_Help/Context.hs')
-rw-r--r--testsuite/tests/typecheck/should_run/T1735_Help/Context.hs57
1 files changed, 57 insertions, 0 deletions
diff --git a/testsuite/tests/typecheck/should_run/T1735_Help/Context.hs b/testsuite/tests/typecheck/should_run/T1735_Help/Context.hs
new file mode 100644
index 0000000000..25b9df94a8
--- /dev/null
+++ b/testsuite/tests/typecheck/should_run/T1735_Help/Context.hs
@@ -0,0 +1,57 @@
+{-# LANGUAGE UndecidableInstances, OverlappingInstances, EmptyDataDecls #-}
+
+{-
+
+(C) 2004 Ralf Laemmel
+
+Context parameterisation and context passing.
+
+-}
+
+
+module T1735_Help.Context
+
+where
+
+------------------------------------------------------------------------------
+
+--
+-- The Sat class from John Hughes' "Restricted Data Types in Haskell"
+--
+
+class Sat a
+ where
+ dict :: a
+
+
+------------------------------------------------------------------------------
+
+-- No context
+
+data NoCtx a
+
+noCtx :: NoCtx ()
+noCtx = undefined
+
+instance Sat (NoCtx a) where dict = undefined
+
+
+------------------------------------------------------------------------------
+
+-- Pair context
+
+data PairCtx l r a
+ = PairCtx { leftCtx :: l a
+ , rightCtx :: r a }
+
+pairCtx :: l () -> r () -> PairCtx l r ()
+pairCtx _ _ = undefined
+
+instance (Sat (l a), Sat (r a))
+ => Sat (PairCtx l r a)
+ where
+ dict = PairCtx { leftCtx = dict
+ , rightCtx = dict }
+
+
+------------------------------------------------------------------------------