[project @ 1996-01-08 20:28:12 by partain]
[ghc-hetmet.git] / ghc / compiler / tests / deSugar / ds025.hs
diff --git a/ghc/compiler/tests/deSugar/ds025.hs b/ghc/compiler/tests/deSugar/ds025.hs
new file mode 100644 (file)
index 0000000..c28b16d
--- /dev/null
@@ -0,0 +1,18 @@
+--!!! ds025 -- overloaded assoc -- AbsBinds
+
+module Util where
+
+ehead xs loc | null xs = error ("4"++loc)
+             | True = head xs
+
+assoc key lst loc
+   = if (null res) then error ("1"++loc++"2"++(show key))
+                   else (ehead res "3")
+     where res = [ val | (key',val) <- lst, key==key']
+
+assocMaybe :: (Eq a) => a -> [(a,b)] -> Maybe b
+assocMaybe key lst
+ = if (null res) then Nothing else (Just (head res))
+   where res =  [ val | (key',val) <- lst, key==key']
+
+data Maybe a = Just a | Nothing deriving ()