File: RegExp

package info (click to toggle)
haskell-data-accessor 0.2.3.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 128 kB
  • sloc: haskell: 458; makefile: 3
file content (17 lines) | stat: -rw-r--r-- 508 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Poor man's Template Haskell -
Here are Regular expression for replacement in NEdit:
Write data declaration like

data T =
   Cons {
      fieldA_ :: String,
      fieldB_ :: Int
   }

Copy the body of the 'data' declaration to where you want to define accessors.
Remove comments at the end of each field.
Use the first line as the pattern to find
and the second line for the pattern to replace by.

^\s*(\w+)_( *):: (.+?),?\n
\1 :: Accessor.T T \3\n\1 =\n   Accessor.fromSetGet (\\x c -> c{\1_ = x}) \1_\n\n