summaryrefslogtreecommitdiff
path: root/testsuite/tests/linear/should_compile/Foldr.hs
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/tests/linear/should_compile/Foldr.hs')
-rw-r--r--testsuite/tests/linear/should_compile/Foldr.hs29
1 files changed, 29 insertions, 0 deletions
diff --git a/testsuite/tests/linear/should_compile/Foldr.hs b/testsuite/tests/linear/should_compile/Foldr.hs
new file mode 100644
index 0000000000..759256d5b2
--- /dev/null
+++ b/testsuite/tests/linear/should_compile/Foldr.hs
@@ -0,0 +1,29 @@
+{-# LANGUAGE LinearTypes #-}
+{-# LANGUAGE NoImplicitPrelude #-}
+module FoldrExample where
+{-
+inplace/bin/ghc-stage1 -O2 -dcore-lint
+-}
+
+import GHC.Base
+import Data.Maybe
+
+qux :: [Maybe Char] -> String
+qux str = foldr (maybe id (:)) "" str
+
+{-
+
+[1 of 1] Compiling FoldrExample ( linear-tests/Foldr.hs, linear-tests/Foldr.o )
+
+linear-tests/Foldr.hs:11:27: error:
+ • Couldn't match type ‘[Char] ⊸ [Char]’ with ‘[Char] -> [Char]’
+ Expected type: Char -> [Char] -> [Char]
+ Actual type: Char ⊸ [Char] ⊸ [Char]
+ • In the second argument of ‘maybe’, namely ‘(:)’
+ In the first argument of ‘foldr’, namely ‘(maybe id (:))’
+ In the expression: foldr (maybe id (:)) "" str
+ |
+11 | qux str = foldr (maybe id (:)) "" str
+ | ^^^
+
+-}