-
Notifications
You must be signed in to change notification settings - Fork 0
/
haskell.js
85 lines (84 loc) · 2.1 KB
/
haskell.js
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
module.exports = function(hljs) {
var TYPE = {
className: 'type',
begin: '\\b[A-Z][\\w\']*',
relevance: 0
};
var CONTAINER = {
className: 'container',
begin: '\\(', end: '\\)',
illegal: '"',
contains: [
{className: 'type', begin: '\\b[A-Z][\\w]*(\\((\\.\\.|,|\\w+)\\))?'},
{className: 'title', begin: '[_a-z][\\w\']*'}
]
};
var CONTAINER2 = {
className: 'container',
begin: '{', end: '}',
contains: CONTAINER.contains
}
return {
keywords:
'let in if then else case of where do module import hiding qualified type data ' +
'newtype deriving class instance not as foreign ccall safe unsafe',
contains: [
{
className: 'comment',
begin: '--', end: '$'
},
{
className: 'preprocessor',
begin: '{-#', end: '#-}'
},
{
className: 'comment',
contains: ['self'],
begin: '{-', end: '-}'
},
{
className: 'string',
begin: '\\s+\'', end: '\'',
contains: [hljs.BACKSLASH_ESCAPE],
relevance: 0
},
hljs.QUOTE_STRING_MODE,
{
className: 'import',
begin: '\\bimport', end: '$',
keywords: 'import qualified as hiding',
contains: [CONTAINER],
illegal: '\\W\\.|;'
},
{
className: 'module',
begin: '\\bmodule', end: 'where',
keywords: 'module where',
contains: [CONTAINER],
illegal: '\\W\\.|;'
},
{
className: 'class',
begin: '\\b(class|instance)', end: 'where',
keywords: 'class where instance',
contains: [TYPE]
},
{
className: 'typedef',
begin: '\\b(data|(new)?type)', end: '$',
keywords: 'data type newtype deriving',
contains: [TYPE, CONTAINER, CONTAINER2]
},
hljs.C_NUMBER_MODE,
{
className: 'shebang',
begin: '#!\\/usr\\/bin\\/env\ runhaskell', end: '$'
},
TYPE,
{
className: 'title', begin: '^[_a-z][\\w\']*'
},
{begin: '->|<-'} // No markup, relevance booster
]
};
};