summaryrefslogtreecommitdiff
path: root/testsuite/tests/linear/should_compile/Foldr.hs
blob: 759256d5b28c6cb2dbe9a2e549241f0819e59e30 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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
   |                           ^^^

-}