summaryrefslogtreecommitdiff
path: root/testsuite/tests/linear/should_fail/Linear17.hs
blob: 1d8abfdb09274697f41cc7cc680078b5d6652e33 (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
30
31
32
33
34
{-# LANGUAGE LinearTypes #-}
{-# LANGUAGE UnicodeSyntax #-}
{-# LANGUAGE RebindableSyntax #-}
module Linear17 where

-- Rebindable do notation

(>>=) :: a ⊸ (a ⊸ b) ⊸ b
(>>=) x f = f x

-- `fail` is needed due to pattern matching on ();
-- ideally, it shouldn't be there.
fail :: a
fail = fail

incorrectDo1 = do
  x <- ()
  (y,z) <- ((),())
  () <- y
  () <- z
  ()

incorrectDo2 = do
  x <- ()
  (y,z) <- ((),x)
  () <- y
  ()

incorrectDo3 = do
  x <- ()
  (y,z) <- (x,x)
  () <- y
  () <- z
  ()