summaryrefslogtreecommitdiff
path: root/testsuite/tests/determinism/determ016/A.hs
diff options
context:
space:
mode:
authorBartosz Nitka <niteria@gmail.com>2016-06-07 13:04:22 -0700
committerBartosz Nitka <niteria@gmail.com>2016-06-07 23:55:24 -0700
commitd4b548efea15943026dd0d4929b6f0f999b4d718 (patch)
tree28a3378648465a39c6f161aef0130e5e702e9bf9 /testsuite/tests/determinism/determ016/A.hs
parentf5f5a8a7957d6c52f47071d2b7419b47e43e9a9d (diff)
downloadhaskell-d4b548efea15943026dd0d4929b6f0f999b4d718.tar.gz
Add some determinism tests
These are the tests that I accumulated fixing real issues. Each test is a separate thing that was broken and they are relatively small. GHC Trac: #4012
Diffstat (limited to 'testsuite/tests/determinism/determ016/A.hs')
-rw-r--r--testsuite/tests/determinism/determ016/A.hs19
1 files changed, 19 insertions, 0 deletions
diff --git a/testsuite/tests/determinism/determ016/A.hs b/testsuite/tests/determinism/determ016/A.hs
new file mode 100644
index 0000000000..81aa34d66d
--- /dev/null
+++ b/testsuite/tests/determinism/determ016/A.hs
@@ -0,0 +1,19 @@
+
+{-# LANGUAGE UnicodeSyntax, MultiParamTypeClasses, FlexibleInstances #-}
+{-# LANGUAGE FlexibleContexts #-}
+{-# OPTIONS -w #-}
+
+module A where
+
+data PSum a b = Empty | Tree a b [(PSum a b)]
+
+extractMinX ∷ (Ord a, Eq b, Num b) ⇒ PSum a b → ((a,b), PSum a b)
+extractMinX Empty = undefined
+extractMinX (Tree v r xs) = ((v,r), Empty)
+
+toListX ∷ (Ord a, Eq b, Num b) ⇒ PSum a b → [(a,b)]
+toListX Empty = []
+toListX x = let (y, z) = extractMinX x in y : toListX z
+
+main ∷ IO ()
+main = print $ take 20 $ toListX $ (Empty :: PSum Int Int)