Skip to content

Commit

Permalink
Add conditional compile for Fable
Browse files Browse the repository at this point in the history
  • Loading branch information
fcallejon committed Nov 20, 2022
1 parent e99bbfd commit fe91dbe
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/FSharpPlus/Control/Alternative.fs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ type IsAltLeftZero =
static member inline IsAltLeftZero (_: ref< ^t> when ^t: null and ^t: struct , _mthd: Default1) = ()

static member IsAltLeftZero (t: ref<option<_> > , _mthd: IsAltLeftZero) = Option.isSome t.Value
#if !FABLE_COMPILER
static member IsAltLeftZero (t: ref<voption<_> >, _mthd: IsAltLeftZero) = ValueOption.isSome t.Value
#endif
static member IsAltLeftZero (t: ref<Result<_,_>> , _mthd: IsAltLeftZero) = match t.Value with (Ok _ ) -> true | _ -> false
static member IsAltLeftZero (t: ref<Choice<_,_>> , _mthd: IsAltLeftZero) = match t.Value with (Choice1Of2 _) -> true | _ -> false

Expand Down
8 changes: 8 additions & 0 deletions src/FSharpPlus/Control/Applicative.fs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ type Lift2 =
#endif
static member Lift2 (f, (x , y ), _mthd: Lift2) = Async.map2 f x y
static member Lift2 (f, (x , y ), _mthd: Lift2) = Option.map2 f x y

#if !FABLE_COMPILER
static member Lift2 (f, (x , y ), _mthd: Lift2) = ValueOption.map2 f x y
#endif
static member Lift2 (f, (x: Result<'T,'Error> , y: Result<'U,'Error> ), _mthd: Lift2) = Result.map2 f x y
static member Lift2 (f, (x: Choice<'T,'Error> , y: Choice<'U,'Error> ), _mthd: Lift2) = Choice.map2 f x y
static member Lift2 (f, (x: Map<'Key,'T> , y : Map<'Key,'U> ), _mthd: Lift2) = Map.mapValues2 f x y
Expand Down Expand Up @@ -123,7 +126,10 @@ type Lift3 =
#endif
static member Lift3 (f, (x , y , z ), _mthd: Lift3) = Async.map3 f x y z
static member Lift3 (f, (x , y , z ), _mthd: Lift3) = Option.map3 f x y z

#if !FABLE_COMPILER
static member Lift3 (f, (x , y , z ), _mthd: Lift3) = ValueOption.map3 f x y z
#endif
static member Lift3 (f, (x: Result<'T,'Error> , y: Result<'U,'Error> , z: Result<'V, 'Error> ), _mthd: Lift3) = Result.map3 f x y z
static member Lift3 (f, (x: Choice<'T,'Error> , y: Choice<'U,'Error> , z: Choice<'V, 'Error> ), _mthd: Lift3) = Choice.map3 f x y z
static member Lift3 (f, (x: Map<'Key,'T> , y: Map<'Key,'U> , z: Map<'Key, 'V> ), _mthd: Lift3) = Map.mapValues3 f x y z
Expand Down Expand Up @@ -154,7 +160,9 @@ type IsLeftZero =
static member IsLeftZero (t: ref<list<_>> , _mthd: IsLeftZero) = List.isEmpty t.Value
static member IsLeftZero (t: ref<array<_>> , _mthd: IsLeftZero) = Array.isEmpty t.Value
static member IsLeftZero (t: ref<option<_>> , _mthd: IsLeftZero) = Option.isNone t.Value
#if !FABLE_COMPILER
static member IsLeftZero (t: ref<voption<_>> , _mthd: IsLeftZero) = ValueOption.isNone t.Value
#endif
static member IsLeftZero (t: ref<Result<_,_>> , _mthd: IsLeftZero) = match t.Value with Error _ -> true | _ -> false
static member IsLeftZero (t: ref<Choice<_,_>> , _mthd: IsLeftZero) = match t.Value with Choice2Of2 _ -> true | _ -> false

Expand Down
2 changes: 2 additions & 0 deletions src/FSharpPlus/Control/Functor.fs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ type Map =
static member Map ((x: Task<'T> , f: 'T->'U), _mthd: Map) = Task.map f x : Task<'U>
#endif
static member Map ((x: option<_> , f: 'T->'U), _mthd: Map) = Option.map f x
#if !FABLE_COMPILER
static member Map ((x: voption<_> , f: 'T->'U), _mthd: Map) = ValueOption.map f x
#endif
static member Map ((x: list<_> , f: 'T->'U), _mthd: Map) = List.map f x : list<'U>
static member Map ((g: 'R->'T , f: 'T->'U), _mthd: Map) = (>>) g f
static member Map ((g: Func<'R, 'T> , f: 'T->'U), _mthd: Map) = Func<'R, 'U> (g.Invoke >> f)
Expand Down
4 changes: 4 additions & 0 deletions src/FSharpPlus/Control/Monad.fs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ type Bind =
static member (>>=) (source , f: 'T -> _ ) = Nullable.bind f source : Nullable<'U>
#endif
static member (>>=) (source , f: 'T -> _ ) = Option.bind f source : option<'U>
#if !FABLE_COMPILER
static member (>>=) (source , f: 'T -> _ ) = ValueOption.bind f source : voption<'U>
#endif
static member (>>=) (source , f: 'T -> _ ) = List.collect f source : list<'U>
static member (>>=) (source , f: 'T -> _ ) = Array.collect f source : 'U []
static member (>>=) (source , k: 'T -> _ ) = (fun r -> k (source r) r) : 'R->'U
Expand Down Expand Up @@ -76,7 +78,9 @@ type Join =
static member Join (x: Task<Task<_>> , [<Optional>]_output: Task<'T> , [<Optional>]_mthd: Join ) = Task.join x : Task<'T>
#endif
static member Join (x , [<Optional>]_output: option<'T> , [<Optional>]_mthd: Join ) = Option.flatten x : option<'T>
#if !FABLE_COMPILER
static member Join (x , [<Optional>]_output: voption<'T> , [<Optional>]_mthd: Join ) = ValueOption.flatten x : voption<'T>
#endif
static member Join (x: list<list<_>> , [<Optional>]_output: list<'T> , [<Optional>]_mthd: Join ) = List.concat x : list<'T>
static member Join (x: _ [][] , [<Optional>]_output: 'T [] , [<Optional>]_mthd: Join ) = Array.concat x : 'T []
static member Join (g , [<Optional>]_output: 'R->'T , [<Optional>]_mthd: Join ) = (fun r -> (g r) r) : 'R->'T
Expand Down
2 changes: 2 additions & 0 deletions src/FSharpPlus/Control/Traversable.fs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ type Sequence with
static member inline Sequence (t: ^a , [<Optional>]_output: 'R , [<Optional>]_impl: Default1) = Sequence.InvokeOnInstance t : 'R

static member inline Sequence (t: option<_> , [<Optional>]_output: 'R , [<Optional>]_impl: Sequence) = match t with Some x -> Map.Invoke Some x | _ -> result None : 'R
#if !FABLE_COMPILER
static member inline Sequence (t: voption<_> , [<Optional>]_output: 'R , [<Optional>]_impl: Sequence) = match t with ValueSome x -> Map.Invoke ValueSome x | _ -> result ValueNone: 'R
#endif
static member inline Sequence (t: list<_> , [<Optional>]_output: 'R , [<Optional>]_impl: Sequence) = Sequence.ForInfiniteSequences(t, IsLeftZero.Invoke, id) : 'R

static member inline Sequence (t: Map<_,_> , [<Optional>]_output: 'R , [<Optional>]_impl: Sequence) : 'R =
Expand Down

0 comments on commit fe91dbe

Please sign in to comment.