Skip to content

Commit fe1b04d

Browse files
authored
Merge pull request #148 from alfonsogarciacaro/fable3
Update to Fable 3
2 parents e1c8162 + dd7c7fb commit fe1b04d

8 files changed

Lines changed: 16428 additions & 6598 deletions

File tree

.config/dotnet-tools.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
"commands": [
88
"fsdocs"
99
]
10+
},
11+
"fable": {
12+
"version": "3.4.2",
13+
"commands": [
14+
"fable"
15+
]
1016
}
1117
}
12-
}
18+
}

.github/workflows/pull-request.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@ jobs:
1313
uses: actions/setup-dotnet@v1
1414
with:
1515
dotnet-version: '5.0.202'
16+
- name: Setup Node.js environment
17+
uses: actions/[email protected]
18+
with:
19+
node-version: 14.17.*
1620
- name: Install tools
1721
run: dotnet tool restore
18-
- name: Build Test and Docs using FAKE
19-
run: dotnet fake build
22+
- name: Build and Test
23+
run: dotnet test -c Release
24+
- name: Test Fable
25+
run: cd tests/fable && npm i && npm test && cd ../..

src/FSharp.Control.AsyncSeq/AsyncSeq.fs

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,7 @@ module internal Utils =
109109
/// when implementing the Subscribe method of IObservable interface.
110110
static member StartDisposable(op:Async<unit>) =
111111
let ct = new System.Threading.CancellationTokenSource()
112-
#if !FABLE_COMPILER
113112
Async.Start(op, ct.Token)
114-
#else
115-
Async.StartImmediate(op, ct.Token)
116-
#endif
117113
{ new IDisposable with
118114
member x.Dispose() = ct.Cancel() }
119115

@@ -216,16 +212,9 @@ module AsyncGenerator =
216212

217213

218214
static member Bind (g:AsyncGenerator<'a>, cont:unit -> AsyncGenerator<'a>) : AsyncGenerator<'a> =
219-
#if !FABLE_COMPILER
220215
match g with
221216
| :? GenerateCont<'a> as g -> GenerateCont<_>.Bind (g.Generator, (fun () -> GenerateCont<_>.Bind (g.Cont(), cont)))
222217
| _ -> (new GenerateCont<'a>(g, cont) :> AsyncGenerator<'a>)
223-
#else
224-
let g' = g :?> GenerateCont<'a>
225-
if unbox<AsyncGenerator<_> option>(g'.Generator).IsSome then
226-
GenerateCont<_>.Bind (g'.Generator, (fun () -> GenerateCont<_>.Bind (g'.Cont(), cont)))
227-
else (new GenerateCont<'a>(g, cont) :> AsyncGenerator<'a>)
228-
#endif
229218

230219
/// Right-associating binder.
231220
let bindG (g:AsyncGenerator<'a>) (cont:unit -> AsyncGenerator<'a>) : AsyncGenerator<'a> =
@@ -268,28 +257,14 @@ module AsyncGenerator =
268257
member __.Disposer = Some ((fun () -> (enum :> IDisposable).Dispose()))
269258

270259
let enumeratorFromGenerator (g:AsyncGenerator<'a>) : IAsyncEnumerator<'a> =
271-
#if !FABLE_COMPILER
272260
match g with
273261
| :? AsyncEnumeratorGenerator<'a> as g -> g.Enumerator
274262
| _ -> (new AsyncGeneratorEnumerator<_>(g) :> _)
275-
#else
276-
let g' = g :?> AsyncEnumeratorGenerator<'a>
277-
match unbox<IAsyncEnumerator<_> option>(g'.Enumerator) with
278-
| Some asyncEnumerator -> asyncEnumerator
279-
| None -> (new AsyncGeneratorEnumerator<_>(g) :> _)
280-
#endif
281263

282264
let generatorFromEnumerator (e:IAsyncEnumerator<'a>) : AsyncGenerator<'a> =
283-
#if !FABLE_COMPILER
284265
match e with
285266
| :? AsyncGeneratorEnumerator<'a> as e -> e.Generator
286267
| _ -> (new AsyncEnumeratorGenerator<_>(e) :> _)
287-
#else
288-
let e' = e :?> AsyncGeneratorEnumerator<'a>
289-
match unbox<AsyncGenerator<_> option>(e'.Generator) with
290-
| Some asyncGenerator -> asyncGenerator
291-
| None -> (new AsyncEnumeratorGenerator<_>(e) :> _)
292-
#endif
293268

294269
let delay (f:unit -> AsyncSeq<'T>) : AsyncSeq<'T> =
295270
{ new IAsyncEnumerable<'T> with
@@ -388,11 +363,7 @@ module AsyncSeqOp =
388363

389364
/// Module with helper functions for working with asynchronous sequences
390365
module AsyncSeq =
391-
#if FABLE_COMPILER
392366
let inline dispose (d:System.IDisposable) = try d.Dispose() with _ -> ()
393-
#else
394-
let private dispose (d:System.IDisposable) = match d with null -> () | _ -> d.Dispose()
395-
#endif
396367

397368
[<GeneralizableValue>]
398369
let empty<'T> : AsyncSeq<'T> =
@@ -728,17 +699,9 @@ module AsyncSeq =
728699
}
729700

730701
let iterAsync (f: 'T -> Async<unit>) (source: AsyncSeq<'T>) =
731-
#if !FABLE_COMPILER
732702
match source with
733703
| :? AsyncSeqOp<'T> as source -> source.IterAsync f
734704
| _ -> iteriAsync (fun i x -> f x) source
735-
#else
736-
let source' = source :?> AsyncSeqOp<'T>
737-
match (unbox<{| __proto__ : {| IterAsync: (('T -> Async<unit>) -> Async<unit>) option |} option |}>(source')).__proto__ with
738-
| Some proto when proto.IterAsync.IsSome ->
739-
source'.IterAsync f
740-
| _ -> iteriAsync (fun _ x -> f x) source
741-
#endif
742705

743706
let iteri (f: int -> 'T -> unit) (inp: AsyncSeq<'T>) = iteriAsync (fun i x -> async.Return (f i x)) inp
744707

@@ -797,25 +760,13 @@ module AsyncSeq =
797760
// Additional combinators (implemented as async/asyncSeq computations)
798761

799762
let mapAsync f (source : AsyncSeq<'T>) : AsyncSeq<'TResult> =
800-
#if !FABLE_COMPILER
801763
match source with
802764
| :? AsyncSeqOp<'T> as source -> source.MapAsync f
803765
| _ ->
804766
asyncSeq {
805767
for itm in source do
806768
let! v = f itm
807769
yield v }
808-
#else
809-
let source' = source :?> AsyncSeqOp<'T>
810-
match (unbox<{| __proto__ : {| MapAsync: (('T -> Async<_>) -> AsyncSeq<_>) option |} option |}>(source')).__proto__ with
811-
| Some proto when proto.MapAsync.IsSome ->
812-
proto.MapAsync.Value f
813-
| _ ->
814-
asyncSeq {
815-
for itm in source do
816-
let! v = f itm
817-
yield v }
818-
#endif
819770

820771
let mapiAsync f (source : AsyncSeq<'T>) : AsyncSeq<'TResult> = asyncSeq {
821772
let i = ref 0L
@@ -840,7 +791,6 @@ module AsyncSeq =
840791
#endif
841792

842793
let chooseAsync f (source:AsyncSeq<'T>) =
843-
#if !FABLE_COMPILER
844794
match source with
845795
| :? AsyncSeqOp<'T> as source -> source.ChooseAsync f
846796
| _ ->
@@ -850,19 +800,6 @@ module AsyncSeq =
850800
match v with
851801
| Some v -> yield v
852802
| _ -> () }
853-
#else
854-
let source' = source :?> AsyncSeqOp<'T>
855-
match (unbox<{| __proto__ : {| ChooseAsync: (('T -> Async<_ option>) -> AsyncSeq<_>) option |} option |}>(source')).__proto__ with
856-
| Some proto when proto.ChooseAsync.IsSome ->
857-
source'.ChooseAsync f
858-
| _ ->
859-
asyncSeq {
860-
for itm in source do
861-
let! v = f itm
862-
match v with
863-
| Some v -> yield v
864-
| _ -> () }
865-
#endif
866803

867804
let ofSeqAsync (source:seq<Async<'T>>) : AsyncSeq<'T> =
868805
asyncSeq {
@@ -987,17 +924,9 @@ module AsyncSeq =
987924
source |> exists (f >> not) |> Async.map not
988925

989926
let foldAsync f (state:'State) (source : AsyncSeq<'T>) =
990-
#if !FABLE_COMPILER
991927
match source with
992928
| :? AsyncSeqOp<'T> as source -> source.FoldAsync f state
993929
| _ -> source |> scanAsync f state |> lastOrDefault state
994-
#else
995-
let source' = source :?> AsyncSeqOp<'T>
996-
match (unbox<{| __proto__ : {| FoldAsync: (('State -> 'T -> Async<'State>) -> 'State -> Async<'State>) option |} option |}>(source')).__proto__ with
997-
| Some proto when proto.FoldAsync.IsSome ->
998-
proto.FoldAsync.Value f state
999-
| _ -> source |> scanAsync f state |> lastOrDefault state
1000-
#endif
1001930

1002931
let fold f (state:'State) (source : AsyncSeq<'T>) =
1003932
foldAsync (fun st v -> f st v |> async.Return) state source

tests/fable/FSharp.Control.AsyncSeq.Tests/splitter.config.js

Lines changed: 0 additions & 16 deletions
This file was deleted.

tests/fable/babel.config.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module.exports = {
2+
presets: [
3+
[
4+
'@babel/preset-env',
5+
{
6+
targets: {
7+
node: 'current',
8+
},
9+
},
10+
],
11+
],
12+
};

0 commit comments

Comments
 (0)