summaryrefslogtreecommitdiff
path: root/src/CC/Name.idr
blob: 4c25f5ccaee54586c69ec95ed77062927d633ba5 (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
module CC.Name

import public Control.Relation

import Decidable.Equality

import Text.Bounded
import Text.PrettyPrint.Prettyprinter

infix 4 ~~

-- Definitions -----------------------------------------------------------------

||| Names of variables.
export
Name : Type
Name = WithBounds String

%name Name n, m

||| Equivalence relation on names.
export
(~~) : Rel Name
m ~~ n = m.val = n.val

%name (~~) prf

-- Interfaces ------------------------------------------------------------------

export
Interpolation Name where
  interpolate n = n.val

export
Pretty Name where
  pretty n = pretty n.val

export
Reflexive Name (~~) where
  reflexive = Refl

export
Symmetric Name (~~) where
  symmetric prf = sym prf

export
Transitive Name (~~) where
  transitive prf1 prf2 = trans prf1 prf2

export Equivalence Name (~~) where

-- Operations ------------------------------------------------------------------

||| Constructs a new name from a bounded String.
export
MkName : WithBounds String -> Name
MkName = id

||| Decides if two names are equivalent
export
decEquiv : (m, n : Name) -> Dec (m ~~ n)
decEquiv m n = decEq m.val n.val

||| Returns the bounds of `name`, if any.
export
bounds : (name : Name) -> Maybe Bounds
bounds name = if name.isIrrelevant then Nothing else Just name.bounds