1- // Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
1+ /* Copyright (c) 2015-present, Facebook, Inc. All rights reserved. */
22let run () => TestUtils . printSection "Basic Structures" ;
33
44while something {
@@ -36,7 +36,7 @@ let x = !(!foo).bar;
3636
3737let x = ! (! foo)# bar;
3838
39- // Prefix operator
39+ /* Prefix operator */
4040let x = !! foo. bar;
4141
4242let x = !! foo# bar;
@@ -64,9 +64,9 @@ let x = !!foo.bar;
6464
6565let x = !! foo# bar;
6666
67- // Comments
68- // Below is an empty comment
69- //
67+ /* Comments */
68+ /* Below is an empty comment*/
69+ /* * /
7070/** IF
7171 *============================================================================
7272 */
@@ -109,7 +109,7 @@ let loop appTime frameTime => {
109109 process appTime frameTime
110110};
111111
112- // These parens should be kept around the entire last if/then/else
112+ /* These parens should be kept around the entire last if/then/else */
113113if something {
114114 if somethingElse {
115115 ()
@@ -118,7 +118,7 @@ if something {
118118 }
119119};
120120
121- // These parens should be kept around just the last if/then
121+ /* These parens should be kept around just the last if/then*/
122122if something {
123123 if somethingElse {
124124 ()
@@ -137,7 +137,7 @@ if true {
137137 }
138138};
139139
140- // Should print two
140+ /* Should print two */
141141if true {
142142 if false {
143143 print_string "one"
@@ -146,7 +146,7 @@ if true {
146146 }
147147};
148148
149- // Should not print
149+ /* Should not print */
150150if false {
151151 if true {
152152 print_string "one"
@@ -209,7 +209,7 @@ if printIfFirstArgGreater {
209209 }
210210};
211211
212- // Should Be Parsed As: Cleary a type error, but at least the parsing makes that clear
212+ /* Should Be Parsed As: Cleary a type error, but at least the parsing makes that clear */
213213if printIfFirstArgGreater {
214214 fun a b =>
215215 if (a > b) {
@@ -227,7 +227,7 @@ fun a b =>
227227 print_string "a > b"
228228 };
229229
230- // What you probably wanted was:
230+ /* What you probably wanted was: */
231231if printIfFirstArgGreater {
232232 fun a b =>
233233 if (a > b) {
@@ -240,7 +240,7 @@ if printIfFirstArgGreater {
240240 }
241241};
242242
243- // Mutative if statement: Not used to evaluate to something.
243+ /* Mutative if statement: Not used to evaluate to something. */
244244if (10 < 100 ) {
245245 let msg = "If there was any doubt, 10 is in fact less than 100." ;
246246 print_string msg
@@ -266,12 +266,12 @@ let x: int = 10;
266266
267267let x : int = (10 : int );
268268
269- // let (x:int) = (10:string);
270- // let (x:string) = ("hello":int);
269+ /* let (x:int) = (10:string); */
270+ /* let (x:string) = ("hello":int); */
271271/** TUPLES
272272 *============================================================================
273273 */
274- // In Reason, types look like the data they model! Tuples are no exception.
274+ /* In Reason, types look like the data they model! Tuples are no exception. */
275275type pairOfInts = (int, int);
276276
277277let letBindingWithTypeConstraint : int = 10 ;
@@ -281,22 +281,22 @@ let (tupleItem: int, withTypeConstraint: int) = (
281281 20
282282);
283283
284- // To make sure that tuple field annotations are annotating the entire field
284+ /* To make sure that tuple field annotations are annotating the entire field */
285285let _dummyFunc x => 10 ;
286286
287287let annotatingFuncApplication = (
288288 _dummyFunc "a" : int ,
289289 _dummyFunc "a" : int
290290);
291291
292- // Pretty printer might stick the [int] at the label.
292+ /* Pretty printer might stick the [int] at the label. */
293293let annotatingSingleFuncApplication : int = _dummyFunc "a" ;
294294
295- // So lets try a place where it won't
295+ /* So lets try a place where it won't */
296296let annotatingSingleFuncApplication = {
297- // Commenting a let binding.
297+ /* Commenting a let binding. */
298298 let a = 100 ;
299- // Commenting another let binding.
299+ /* Commenting another let binding. */
300300 let int = 200 ;
301301 /*
302302 * This demonstrates why named arguments cannot simply have the form (func
@@ -324,31 +324,31 @@ let (tupleItem, withOutsideTypeConstraint): (
324324/** Immutable Lists
325325 * ============================================================================
326326 */
327- // Anatomy: -Head- --------- Tail--------- nil: You can't see nil
327+ /* Anatomy: -Head- --------- Tail--------- nil: You can't see nil */
328328let x : list int = [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 ] ;
329329
330330let hd = "appendedToHead" ;
331331
332332let tl = [ "listTo" , "append" , "to" ] ;
333333
334- // To push *one* and only *one* item to the front of a list - use [hd, ...tl]
334+ /* To push *one* and only *one* item to the front of a list - use [hd, ...tl] */
335335let result : list string = [ hd, ... tl] ;
336336
337- // Is the same as writing
337+ /* Is the same as writing */
338338let result : list string = [
339339 "appendedToHead" ,
340340 "listTo" ,
341341 "append" ,
342342 "to"
343343] ;
344344
345- // To operate on lists, use pattern matching
345+ /* To operate on lists, use pattern matching */
346346let rec size =
347347 fun
348348 | [] => 0
349349 | [ hd , ... tl ] => 1 + size tl;
350350
351- // Optimize for tail recursion
351+ /* Optimize for tail recursion */
352352let rec size soFar lst =>
353353 switch lst {
354354 | [] => 0
@@ -410,15 +410,15 @@ let MyThing _ as ppp | YourThing _ as ppp = ppp;
410410 * But this isn't needed in Reason because OR patterns have much lower
411411 * precedence - they should be pretty printed in the same way.
412412 */
413- // TODO:
414- // let rec nestedMatch lstLst => match lstLst with {
415- // hd::tl: match tl with {
416- // []: 0 + 0,
417- // tlHd::tlTl: 0 + 1,
418- // },
419- // []: 0
420- // };
421- //
413+ /* TODO: */
414+ /* let rec nestedMatch lstLst => match lstLst with { */
415+ /* hd::tl: match tl with { */
416+ /* []: 0 + 0, */
417+ /* tlHd::tlTl: 0 + 1, */
418+ /* }, */
419+ /* []: 0 */
420+ /* }; */
421+ /* * /
422422/** ARRAYS
423423 * ============================================================================
424424 * Arrays are weird looking. Usually you want lists because they support pattern
@@ -433,11 +433,11 @@ let arrayWithTwo = [|10, 10|];
433433
434434let secondItem = arrayWithTwo. ( 1 ) ;
435435
436- // Getting And Setting: Yeah, we should really change this
437- // Get an array item at index 1
436+ /* Getting And Setting: Yeah, we should really change this */
437+ /* Get an array item at index 1 */
438438let secondItem = arrayWithTwo. ( 1 ) ;
439439
440- // Set an array item at index 1
440+ /* Set an array item at index 1 */
441441arrayWithTwo. ( 1 ) = 300 ;
442442
443443/**
@@ -447,7 +447,7 @@ arrayWithTwo.(1) = 300;
447447 */
448448let myString = "asdf" ;
449449
450- // Replacing a character: I could do without this sugar
450+ /* Replacing a character: I could do without this sugar */
451451myString. [2] = '9';
452452
453453/* FUNCTIONS
@@ -460,20 +460,20 @@ let one = 900;
460460
461461let two = 10000 ;
462462
463- // Tuple expressions can be annotated without additional paren wrapping
463+ /* Tuple expressions can be annotated without additional paren wrapping */
464464let myTuple = (one: int , two: int );
465465
466466type myTupleType = (int, int);
467467
468468let myTuple : myTupleType = myTuple;
469469
470- // Anything *outside* of a tuple, must still be annotated within parens.
470+ /* Anything *outside* of a tuple, must still be annotated within parens. */
471471let myTuple : myTupleType = (one: int , two: int );
472472
473- // Now functions that accept a single argument being a tuple look familiar
473+ /* Now functions that accept a single argument being a tuple look familiar */
474474let addValues (a : int , b : int ) => a + b;
475475
476- // Impossible to annotate return values of fun lambdas - just like in OCaml
476+ /* Impossible to annotate return values of fun lambdas - just like in OCaml */
477477let addValues (a : int , b : int ) => a + b;
478478
479479let functionReturnValueType
@@ -489,7 +489,7 @@ let curriedFormTwo (i: int, x: int) :(int, int) => (
489489 x
490490);
491491
492- // let nonCurriedFormTwo = fun (i:int, x:int) (:(int, int)) => (i, x);
492+ /* let nonCurriedFormTwo = fun (i:int, x:int) (:(int, int)) => (i, x); */
493493let curriedFormThree
494494 (i : int , (a : int , b : int ): (int , int ))
495495 : (int , int , int ) => (
@@ -498,7 +498,7 @@ let curriedFormThree
498498 b
499499);
500500
501- // let nonCurriedFormThree = fun (i:int, (a:int, b:int):(int, int)) (:(int, int, int)) => (i, a, b);
501+ /* let nonCurriedFormThree = fun (i:int, (a:int, b:int):(int, int)) (:(int, int, int)) => (i, a, b); */
502502/** TODO: But this, however doesn't work.
503503 * let (myCurriedFunc: int => int) a => a;
504504 * Note: This is likely because only "simple patterns" are accepted as constraints
0 commit comments