[ { "state": "comment", "data": [ [ "comment", "(*" ] ] }, { "state": "comment", "data": [ [ "comment", " * Example of early return implementation taken from" ] ] }, { "state": "comment", "data": [ [ "comment", " * http://ocaml.janestreet.com/?q=node/91" ] ] }, { "state": "start", "data": [ [ "comment", " *)" ] ] }, { "state": "start", "data": [] }, { "state": "start", "data": [ [ "keyword", "let" ], [ "text", " " ], [ "identifier", "with_return" ], [ "text", " " ], [ "paren.lparen", "(" ], [ "keyword", "type" ], [ "text", " " ], [ "identifier", "t" ], [ "paren.rparen", ")" ], [ "text", " " ], [ "paren.lparen", "(" ], [ "identifier", "f" ], [ "text", " : " ], [ "identifier", "_" ], [ "text", " " ], [ "keyword.operator", "-" ], [ "keyword.operator", ">" ], [ "text", " " ], [ "identifier", "t" ], [ "paren.rparen", ")" ], [ "text", " " ], [ "keyword.operator", "=" ] ] }, { "state": "start", "data": [ [ "text", " " ], [ "keyword", "let" ], [ "text", " " ], [ "keyword", "module" ], [ "text", " " ], [ "identifier", "M" ], [ "text", " " ], [ "keyword.operator", "=" ] ] }, { "state": "start", "data": [ [ "text", " " ], [ "keyword", "struct" ], [ "text", " " ], [ "keyword", "exception" ], [ "text", " " ], [ "identifier", "Return" ], [ "text", " " ], [ "keyword", "of" ], [ "text", " " ], [ "identifier", "t" ], [ "text", " " ], [ "keyword", "end" ] ] }, { "state": "start", "data": [ [ "text", " " ], [ "keyword", "in" ] ] }, { "state": "start", "data": [ [ "text", " " ], [ "keyword", "let" ], [ "text", " " ], [ "identifier", "return" ], [ "text", " " ], [ "keyword.operator", "=" ], [ "text", " " ], [ "paren.lparen", "{" ], [ "text", " " ], [ "identifier", "return" ], [ "text", " " ], [ "keyword.operator", "=" ], [ "text", " " ], [ "paren.lparen", "(" ], [ "keyword", "fun" ], [ "text", " " ], [ "identifier", "x" ], [ "text", " " ], [ "keyword.operator", "-" ], [ "keyword.operator", ">" ], [ "text", " " ], [ "support.function", "raise" ], [ "text", " " ], [ "paren.lparen", "(" ], [ "identifier", "M" ], [ "text", "." ], [ "identifier", "Return" ], [ "text", " " ], [ "identifier", "x" ], [ "paren.rparen", ")" ], [ "paren.rparen", ")" ], [ "text", "; " ], [ "paren.rparen", "}" ], [ "text", " " ], [ "keyword", "in" ] ] }, { "state": "start", "data": [ [ "text", " " ], [ "keyword", "try" ], [ "text", " " ], [ "identifier", "f" ], [ "text", " " ], [ "identifier", "return" ], [ "text", " " ], [ "keyword", "with" ], [ "text", " " ], [ "identifier", "M" ], [ "text", "." ], [ "identifier", "Return" ], [ "text", " " ], [ "identifier", "x" ], [ "text", " " ], [ "keyword.operator", "-" ], [ "keyword.operator", ">" ], [ "text", " " ], [ "identifier", "x" ] ] }, { "state": "start", "data": [] }, { "state": "start", "data": [] }, { "state": "start", "data": [ [ "comment", "(* Function that uses the 'early return' functionality provided by `with_return` *)" ] ] }, { "state": "start", "data": [ [ "keyword", "let" ], [ "text", " " ], [ "identifier", "sum_until_first_negative" ], [ "text", " " ], [ "support.function", "list" ], [ "text", " " ], [ "keyword.operator", "=" ] ] }, { "state": "start", "data": [ [ "text", " " ], [ "identifier", "with_return" ], [ "text", " " ], [ "paren.lparen", "(" ], [ "keyword", "fun" ], [ "text", " " ], [ "identifier", "r" ], [ "text", " " ], [ "keyword.operator", "-" ], [ "keyword.operator", ">" ] ] }, { "state": "start", "data": [ [ "text", " " ], [ "support.function", "List" ], [ "text", "." ], [ "support.function", "fold" ], [ "text", " " ], [ "support.function", "list" ], [ "text", " " ], [ "keyword.operator", "~" ], [ "support.function", "init" ], [ "text", ":" ], [ "constant.numeric", "0" ], [ "text", " " ], [ "keyword.operator", "~" ], [ "identifier", "f" ], [ "text", ":" ], [ "paren.lparen", "(" ], [ "keyword", "fun" ], [ "text", " " ], [ "identifier", "acc" ], [ "text", " " ], [ "identifier", "x" ], [ "text", " " ], [ "keyword.operator", "-" ], [ "keyword.operator", ">" ] ] }, { "state": "start", "data": [ [ "text", " " ], [ "keyword", "if" ], [ "text", " " ], [ "identifier", "x" ], [ "text", " " ], [ "keyword.operator", ">" ], [ "keyword.operator", "=" ], [ "text", " " ], [ "constant.numeric", "0" ], [ "text", " " ], [ "keyword", "then" ], [ "text", " " ], [ "identifier", "acc" ], [ "text", " " ], [ "keyword.operator", "+" ], [ "text", " " ], [ "identifier", "x" ], [ "text", " " ], [ "keyword", "else" ], [ "text", " " ], [ "identifier", "r" ], [ "text", "." ], [ "identifier", "return" ], [ "text", " " ], [ "identifier", "acc" ], [ "paren.rparen", ")" ], [ "paren.rparen", ")" ] ] } ]