palate 0.3.7

File type detection combining tft and hyperpolyglot
Documentation
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
type component = {displayName: string};

let module Bar = {
  let createElement c::c=? children => {
    displayName: "test"
  };
};

let module Nesting = {
  let createElement children => {
    displayName: "test"
  };
};

let module Much = {
  let createElement children => {
    displayName: "test"
  };
};

let module Foo = {
  let createElement a::a=? b::b=? children => {
    displayName: "test"
  };
};

let module One = {
  let createElement
      test::test=?
      foo::foo=?
      children => {
    displayName: "test"
  };
  let createElementobvioustypo
      test::test
      children => {
    displayName: "test"
  };
};

let module Two = {
  let createElement foo::foo=? children => {
    displayName: "test"
  };
};

let module Sibling = {
  let createElement
      foo::foo=?
      (children: list component) => {
    displayName: "test"
  };
};

let module Test = {
  let createElement yo::yo=? children => {
    displayName: "test"
  };
};

let module So = {
  let createElement children => {
    displayName: "test"
  };
};

let module Foo2 = {
  let createElement children => {
    displayName: "test"
  };
};

let module Text = {
  let createElement children => {
    displayName: "test"
  };
};

let module Exp = {
  let createElement children => {
    displayName: "test"
  };
};

let module Pun = {
  let createElement intended::intended=? children => {
    displayName: "test"
  };
};

let module Namespace = {
  let module Foo = {
    let createElement
        intended::intended=?
        anotherOptional::x=100
        children => {
      displayName: "test"
    };
  };
};

let module LotsOfArguments = {
  let createElement
      argument1::argument1=?
      argument2::argument2=?
      argument3::argument3=?
      argument4::argument4=?
      argument5::argument5=?
      argument6::argument6=?
      children => {
    displayName: "test"
  };
};

let div argument1::argument1=? children => {
  displayName: "test"
};

let module List1 = {
  let createElement children => {
    displayName: "test"
  };
};

let module List2 = {
  let createElement children => {
    displayName: "test"
  };
};

let module List3 = {
  let createElement children => {
    displayName: "test"
  };
};

let (/><) a b => a + b;

let (><) a b => a + b;

let (/>) a b => a + b;

let (><\/) a b => a + b;

let tag1 = 5 />< 6;

let tag2 = 5 >< 7;

let tag3 = 5 /> 7;

let tag4 = 5 ><\/ 7;

let b = 2;

let selfClosing = <Foo />;

let selfClosing2 = <Foo a=1 b=true />;

let selfClosing3 =
  <Foo
    a="really long values that should"
    b="cause the entire thing to wrap"
  />;

let a = <Foo> <Bar c=(fun a => a + 2) /> </Foo>;

let a3 = <So> <Much> <Nesting /> </Much> </So>;

let a4 =
  <Sibling>
    <One test=true foo=b />
    <Two foo=b />
  </Sibling>;

let a5 = <Foo> "testing a string here" </Foo>;

let a6 =
  <Foo2>
    <Text> "testing a string here" </Text>
    <Test yo=1 />
    <Text> "another string" </Text>
    <Bar />
    <Exp> (2 + 4) </Exp>
  </Foo2>;

let intended = true;

let punning = <Pun intended />;

let namespace = <Namespace.Foo />;

let c = <Foo />;

let d = <Foo />;

let spaceBefore =
  <So> <Much> <Nesting /> </Much> </So>;

let spaceBefore2 = <So> <Much /> </So>;

let siblingNotSpaced =
  <So> <Much /> <Much /> </So>;

let jsxInList = [<Foo />];

let jsxInList2 = [<Foo />];

let jsxInListA = [<Foo />];

let jsxInListB = [<Foo />];

let jsxInListC = [<Foo />];

let jsxInListD = [<Foo />];

let jsxInList3 = [<Foo />, <Foo />, <Foo />];

let jsxInList4 = [<Foo />, <Foo />, <Foo />];

let jsxInList5 = [<Foo />, <Foo />];

let jsxInList6 = [<Foo />, <Foo />];

let jsxInList7 = [<Foo />, <Foo />];

let jsxInList8 = [<Foo />, <Foo />];

let testFunc b => b;

let jsxInFnCall = testFunc <Foo />;

let lotsOfArguments =
  <LotsOfArguments
    argument1=1
    argument2=2
    argument3=3
    argument4=4
    argument5=5
    argument6="test">
    <Namespace.Foo />
  </LotsOfArguments>;

let lowerCase = <div argument1=1 />;

let b = 0;

let d = 0;

/*
 * Should pun the first example:
 */
let a = <Foo a> 5 </Foo>;

let a = <Foo a=b> 5 </Foo>;

let a = <Foo a=b b=d> 5 </Foo>;

let a = <Foo a> 0.55 </Foo>;

let a = Foo.createElement "" [@JSX];

let ident = <Foo> a </Foo>;

let fragment1 = <> <Foo /> <Foo /> </>;

let fragment2 = <> <Foo /> <Foo /> </>;

let fragment3 = <> <Foo /> <Foo /> </>;

let fragment4 = <> <Foo /> <Foo /> </>;

let fragment5 = <> <Foo /> <Foo /> </>;

let fragment6 = <> <Foo /> <Foo /> </>;

let fragment7 = <> <Foo /> <Foo /> </>;

let fragment8 = <> <Foo /> <Foo /> </>;

let fragment9 = <> 2 2 2 2 </>;

let fragment10 = <> 2.2 3.2 4.6 1.2 </>;

let fragment11 = <> "str" </>;

let fragment12 = <> (6 + 2) (6 + 2) (6 + 2) </>;

let fragment13 = <> fragment11 fragment11 </>;

let listOfItems1 = <List1> 1 2 3 4 5 </List1>;

let listOfItems2 =
  <List2> 1.0 2.8 3.8 4.0 5.1 </List2>;

let listOfItems3 =
  <List3> fragment11 fragment11 </List3>;

/*
 * Several sequential simple jsx expressions must be separated with a space.
 */
let thisIsRight a b => ();

let tagOne children => ();

let tagTwo children => ();

/* thisIsWrong <tagOne /><tagTwo />; */
thisIsRight <tagOne /> <tagTwo />;

/* thisIsWrong <tagOne> </tagOne><tagTwo> </tagTwo>; */
thisIsRight <tagOne /> <tagTwo />;

let a children => ();

let b children => ();

let thisIsOkay =
  <List1> <a /> <b /> <a /> <b /> </List1>;

let thisIsAlsoOkay =
  <List1> <a /> <b /> </List1>;

/* Doesn't make any sense, but suppose you defined an
   infix operator to compare jsx */
<a /> < <b />;

<a /> > <b />;

<a /> < <b />;

<a /> > <b />;

let listOfListOfJsx = [<> </>];

let listOfListOfJsx = [<> <Foo /> </>];

let listOfListOfJsx = [
  <> <Foo /> </>,
  <> <Bar /> </>
];

let listOfListOfJsx = [
  <> <Foo /> </>,
  <> <Bar /> </>,
  ...listOfListOfJsx
];

let sameButWithSpaces = [<> </>];

let sameButWithSpaces = [<> <Foo /> </>];

let sameButWithSpaces = [
  <> <Foo /> </>,
  <> <Bar /> </>
];

let sameButWithSpaces = [
  <> <Foo /> </>,
  <> <Bar /> </>,
  ...sameButWithSpaces
];

/*
 * Test named tag right next to an open bracket.
 */
let listOfJsx = [];

let listOfJsx = [<Foo />];

let listOfJsx = [<Foo />, <Bar />];

let listOfJsx = [<Foo />, <Bar />, ...listOfJsx];

let sameButWithSpaces = [];

let sameButWithSpaces = [<Foo />];

let sameButWithSpaces = [<Foo />, <Bar />];

let sameButWithSpaces = [
  <Foo />,
  <Bar />,
  ...sameButWithSpaces
];


/**
 * Test no conflict with polymorphic variant types.
 */
type thisType = [ | `Foo | `Bar];

type t 'a = [< thisType] as 'a;

let asd =
  <One test=true foo=2> "a" "b" </One> [@foo];

let asd2 =
  One.createElementobvioustypo
  test::false
  ["a", "b"]
  [@JSX]
  [@foo];

let span
    test::(test: bool)
    foo::(foo: int)
    children => 1;

let asd =
  <span test=true foo=2> "a" "b" </span> [@foo];

/* "video" call doesn't end with a list, so the expression isn't converted to JSX */
let video test::(test: bool) children => children;

let asd2 = video test::false 10 [@JSX] [@foo];

let div children => 1;

((fun () => div) ()) [] [@JSX];

let myFun () =>
  <>
    <Namespace.Foo
      intended=true
      anotherOptional=200
    />
    <Namespace.Foo
      intended=true
      anotherOptional=200
    />
    <Namespace.Foo
      intended=true anotherOptional=200>
      <Foo />
      <Foo />
      <Foo />
      <Foo />
      <Foo />
      <Foo />
      <Foo />
    </Namespace.Foo>
  </>;

let myFun () => <> </>;

let myFun () =>
  <>
    <Namespace.Foo
      intended=true
      anotherOptional=200
    />
    <Namespace.Foo
      intended=true
      anotherOptional=200
    />
    <Namespace.Foo
      intended=true anotherOptional=200>
      <Foo />
      <Foo />
      <Foo />
      <Foo />
      <Foo />
      <Foo />
      <Foo />
    </Namespace.Foo>
  </>;


/**
 * Children should wrap without forcing attributes to.
 */
<Foo a=10 b=0>
  <Bar />
  <Bar />
  <Bar />
  <Bar />
</Foo>;
/**
 * Failing test cases:
 */
/* let res = <Foo a=10 b=(<Foo a=200 />) > */
/*   <Bar /> */
/* </Foo>; */
/* let res = <Foo a=10 b=(<Foo a=200 />) />; */