summaryrefslogtreecommitdiff
path: root/testsuite/tests/hiefile/should_compile/Scopes.hs
blob: a6714a9a6832ea48707189811d00181f97366bf2 (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
35
36
37
38
39
{-# LANGUAGE PatternSynonyms, ViewPatterns #-}
{-# LANGUAGE ImplicitParams #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE PolyKinds #-}

module Scopes where

-- Verify that evidence bound by pattern
-- synonyms has correct scope
pattern LL :: Num a => a -> a
pattern LL x <- (subtract 1 -> x)
  where
        LL x = x + 1

data T = C { x :: Int, y :: Char }

-- Verify that names generated from record construction
-- have correct scope
foo = C { x = 1 , y = 'a' }

-- Verify that implicit parameters have correct scope
bar :: (?x :: Int) => Int
bar = ?x + 1

baz :: Int
baz = bar + ?x
  where ?x = 2

-- Verify that variables bound in pattern
-- synonyms have the correct scope
pattern A a b = (a , b)

-- Verify that record wildcards are in scope
sdaf :: T
sdaf = C{..}
  where
    x = 1
    y = 'a'