Shortened/diversified pattern aliases
Getty Ritter
9 years ago
3 | 3 |
module Data.SCargot.Repr.Basic
|
4 | 4 |
( -- * Basic 'SExpr' representation
|
5 | 5 |
R.SExpr(..)
|
| 6 |
-- * Shorthand Patterns
|
| 7 |
, pattern (:::)
|
| 8 |
, pattern A
|
| 9 |
, pattern Nil
|
6 | 10 |
) where
|
7 | 11 |
|
8 | 12 |
import Data.SCargot.Repr as R
|
| 13 |
|
| 14 |
-- | A shorter infix alias for `SCons`
|
| 15 |
pattern x ::: xs = SCons x xs
|
| 16 |
|
| 17 |
-- | A shorter alias for `SAtom`
|
| 18 |
pattern A x = SAtom x
|
| 19 |
|
| 20 |
-- | A (slightly) shorter alias for `SNil`
|
| 21 |
pattern Nil = SNil
|
6 | 6 |
, R.toRich
|
7 | 7 |
, R.fromRich
|
8 | 8 |
-- * Useful pattern synonyms
|
9 | |
, pattern List
|
10 | |
, pattern DotList
|
11 | |
, pattern Atom
|
| 9 |
, pattern (:::)
|
| 10 |
, pattern A
|
| 11 |
, pattern L
|
| 12 |
, pattern DL
|
| 13 |
, pattern Nil
|
12 | 14 |
) where
|
13 | 15 |
|
14 | 16 |
import Data.SCargot.Repr as R
|
15 | 17 |
|
16 | |
pattern Atom a = R.RSAtom a
|
17 | |
pattern List xs = R.RSList xs
|
18 | |
pattern DotList xs x = R.RSDotted xs x
|
| 18 |
-- | A shorter infix alias to grab the head
|
| 19 |
-- and tail of an `RSList`.
|
| 20 |
pattern x ::: xs = R.RSList (x : xs)
|
| 21 |
|
| 22 |
-- | A shorter alias for `RSAtom`
|
| 23 |
pattern A a = R.RSAtom a
|
| 24 |
|
| 25 |
-- | A shorter alias for `RSList`
|
| 26 |
pattern L xs = R.RSList xs
|
| 27 |
|
| 28 |
-- | A shorter alias for `RSDotted`
|
| 29 |
pattern DL xs x = R.RSDotted xs x
|
| 30 |
|
| 31 |
-- | A shorter alias for `RSList []`
|
| 32 |
pattern Nil = R.RSList []
|
6 | 6 |
, R.toWellFormed
|
7 | 7 |
, R.fromWellFormed
|
8 | 8 |
-- * Useful pattern synonyms
|
9 | |
, pattern List
|
10 | |
, pattern Atom
|
| 9 |
, pattern (:::)
|
| 10 |
, pattern L
|
| 11 |
, pattern A
|
| 12 |
, pattern Nil
|
11 | 13 |
) where
|
12 | 14 |
|
13 | 15 |
import Data.SCargot.Repr as R
|
14 | 16 |
|
15 | |
pattern List xs = R.WFSList xs
|
16 | |
pattern Atom a = R.WFSAtom a
|
| 17 |
-- | A shorter infix alias to grab the head
|
| 18 |
-- and tail of a `WFSList`
|
| 19 |
pattern x ::: xs = R.WFSList (x : xs)
|
| 20 |
|
| 21 |
-- | A shorter alias for `WFSList`
|
| 22 |
pattern L xs = R.WFSList xs
|
| 23 |
|
| 24 |
-- | A shorter alias for `WFSAtom`
|
| 25 |
pattern A a = R.WFSAtom a
|
| 26 |
|
| 27 |
-- | A shorter alias for `WFSList []`
|
| 28 |
pattern Nil = R.WFSList []
|