-
Notifications
You must be signed in to change notification settings - Fork 470
Special case uncurried fun with 1 arg of unit type #6131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
5e978f9
Specia case uncurried fun with 1 arg of unit type
cristianoc 098db4e
Update artifacts.txt
cristianoc 4d80dda
v2
cristianoc a28319c
back
cristianoc 5ee2d13
back
cristianoc e1a2f6f
Update artifacts.txt
cristianoc d8dea18
simplify
cristianoc 47848cd
Seems to work with minimal changes.
cristianoc 6271818
Update artifacts.txt
cristianoc 9176acf
Merge branch 'uncurried_unit' of https://github.com/rescript-lang/res…
cristianoc 46e4fbf
Pass the information oneUnitArg lower down the compiler stack.
cristianoc 68585f9
Update CHANGELOG.md
cristianoc eda5f64
Merge branch 'master' into uncurried_unit
cristianoc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/* Copyright (C) 2017 Hongbo Zhang, Authors of ReScript | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* In addition to the permissions granted to you by the LGPL, you may combine | ||
* or link a "work that uses the Library" with a publicly distributed version | ||
* of this file to produce a combined library or application, then distribute | ||
* that combined work under the terms of your choosing, with no requirement | ||
* to comply with the obligations normally placed on you by section 4 of the | ||
* LGPL version 3 (or the corresponding section of a later version of the LGPL | ||
* should you choose to use a later version). | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | ||
|
||
@@bs.config({flags: ["-bs-no-cross-module-opt"]}) | ||
|
||
/* Internals of forcing lazy values. */ | ||
type t<'a> = { | ||
@as("LAZY_DONE") mutable tag: bool, | ||
/* Invariant: name */ | ||
@as("VAL") mutable value: 'a, | ||
/* its type is ['a] or [unit -> 'a ] */ | ||
} | ||
|
||
%%private(external fnToVal: ((. unit) => 'a) => 'a = "%identity") | ||
%%private(external valToFn: 'a => (. unit) => 'a = "%identity") | ||
%%private(external castToConcrete: lazy_t<'a> => t<'a> = "%identity") | ||
|
||
let is_val = (type a, l: lazy_t<a>): bool => castToConcrete(l).tag | ||
|
||
exception Undefined | ||
|
||
%%private( | ||
let forward_with_closure = (type a, blk: t<a>, closure: (. unit) => a): a => { | ||
let result = closure(.) | ||
blk.value = result | ||
blk.tag = true | ||
result | ||
} | ||
) | ||
|
||
%%private(let raise_undefined = (. ()) => raise(Undefined)) | ||
|
||
/* Assume [blk] is a block with tag lazy */ | ||
%%private( | ||
let force_lazy_block = (type a, blk: t<a>): a => { | ||
let closure = valToFn(blk.value) | ||
blk.value = fnToVal(raise_undefined) | ||
try forward_with_closure(blk, closure) catch { | ||
| e => | ||
blk.value = fnToVal((. ()) => raise(e)) | ||
raise(e) | ||
} | ||
} | ||
) | ||
|
||
/* Assume [blk] is a block with tag lazy */ | ||
%%private( | ||
let force_val_lazy_block = (type a, blk: t<a>): a => { | ||
let closure = valToFn(blk.value) | ||
blk.value = fnToVal(raise_undefined) | ||
forward_with_closure(blk, closure) | ||
} | ||
) | ||
|
||
let force = (type a, lzv: lazy_t<a>): a => { | ||
let lzv: t<_> = castToConcrete(lzv) | ||
if lzv.tag { | ||
lzv.value | ||
} else { | ||
force_lazy_block(lzv) | ||
} | ||
} | ||
|
||
let force_val = (type a, lzv: lazy_t<a>): a => { | ||
let lzv: t<_> = castToConcrete(lzv) | ||
if lzv.tag { | ||
lzv.value | ||
} else { | ||
force_val_lazy_block(lzv) | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
@@ocaml.text(/* ************************************************************************ */ | ||
/* */ | ||
/* OCaml */ | ||
/* */ | ||
/* Damien Doligez, projet Para, INRIA Rocquencourt */ | ||
/* */ | ||
/* Copyright 1997 Institut National de Recherche en Informatique et */ | ||
/* en Automatique. */ | ||
/* */ | ||
/* All rights reserved. This file is distributed under the terms of */ | ||
/* the GNU Lesser General Public License version 2.1, with the */ | ||
/* special exception on linking described in the file LICENSE. */ | ||
/* */ | ||
/* ************************************************************************ */ | ||
|
||
" Run-time support for lazy values. | ||
All functions in this module are for system use only, not for the | ||
casual user. ") | ||
|
||
exception Undefined | ||
|
||
let force: lazy_t<'a> => 'a | ||
/* instrumented by {!Matching} */ | ||
|
||
let force_val: lazy_t<'a> => 'a | ||
|
||
let is_val: lazy_t<'a> => bool |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,7 @@ function eq(loc, x, y) { | |
|
||
var u = 3; | ||
|
||
function nullary(param) { | ||
function nullary() { | ||
return 3; | ||
} | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.