-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Relates to #22
- Loading branch information
Showing
5 changed files
with
104 additions
and
49 deletions.
There are no files selected for viewing
This file contains 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,42 @@ | ||
-module('Microsoft.FSharp.Control'). | ||
|
||
-export([ | ||
'FSharpAsyncBuilder.Delay'/2, | ||
'FSharpAsyncBuilder.Return'/2, | ||
'FSharpAsyncBuilder.Bind'/3, | ||
'FSharpAsyncBuilder.Zero'/1, | ||
'FSharpAsync.Start'/2, | ||
'FSharpAsync.RunSynchronously'/3 | ||
|
||
]). | ||
|
||
% -type async() :: {async, delay | return | bind | zero, term()}. | ||
|
||
'FSharpAsyncBuilder.Delay'(_B, Fun) -> | ||
{async, delay, Fun}. | ||
|
||
'FSharpAsyncBuilder.Return'(_B, V) -> | ||
{async, return, V}. | ||
|
||
'FSharpAsyncBuilder.Bind'(_B, Async, Binder) -> | ||
{async, bind, {Async, Binder}}. | ||
|
||
'FSharpAsyncBuilder.Zero'(_B) -> | ||
{async, zero, unit}. | ||
|
||
% TODO: can we use token somehow to cancel the async? how would we register? | ||
'FSharpAsync.Start'(Async, _Token) -> | ||
% run async on another process | ||
spawn(fun () -> run(Async) end), | ||
ok. | ||
|
||
'FSharpAsync.RunSynchronously'(Async, _Timeout, _Token) -> | ||
run(Async). | ||
|
||
run({async, zero, unit}) -> ok; | ||
run({async, delay, Fun}) -> | ||
run(Fun()); | ||
run({async, return, V}) -> | ||
V; | ||
run({async, bind, {Async, Binder}}) -> | ||
run(Binder(run(Async))). |
This file contains 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 |
---|---|---|
@@ -1,7 +1,15 @@ | ||
-module('Microsoft.FSharp.Core.ExtraTopLevelOperators'). | ||
-compile(export_all). | ||
-export([ | ||
async/0, | ||
printfn/1, | ||
query/0 | ||
]). | ||
|
||
% dummy value for async builder | ||
async() -> ok. | ||
|
||
printfn(S) -> | ||
io:format(S, []). | ||
|
||
query() -> query_builder. | ||
query() -> ok. | ||
|
This file contains 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 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 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