Skip to content

Commit ecd4fbb

Browse files
committed
+ InlineIfLambda to Free
1 parent b42d346 commit ecd4fbb

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/FSharpPlus/Data/Free.fs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ module Free =
3333
| Free.Pure x -> Choice1Of2 x
3434
| Free.Roll x -> let x = unbox x in Choice2Of2 x
3535

36-
let inline map f x =
36+
let inline map ([<InlineIfLambda>]f) x =
3737
let rec loop (f: 'T->'U) (x: Free<'``Functor<'T>``,'T>) : Free<'``Functor<'U>``,'U> =
3838
match run x with
3939
| Pure x -> Pure (f x)
4040
| Roll (x: ^``Functor<Free<'Functor<'T>,'T>>``) -> Roll (Map.Invoke (loop f : Free<'``Functor<'T>``,'T> -> _) x: ^``Functor<Free<'Functor<'U>,'U>>``)
4141
loop f x
4242

43-
let inline bind (f: 'T -> Free<'``Functor<'U>``,'U>) (x: Free<'``Functor<'T>``,'T>) : Free<'``Functor<'U>``,'U> =
43+
let inline bind ([<InlineIfLambda>]f: 'T -> Free<'``Functor<'U>``,'U>) (x: Free<'``Functor<'T>``,'T>) : Free<'``Functor<'U>``,'U> =
4444
let rec loop f (x: Free<_,_>) =
4545
match run x with
4646
| Pure r -> f r
@@ -54,30 +54,30 @@ module Free =
5454
| Roll (f: ^``Functor<Free<'Functor<'T->'U>,'T->'U>>``) -> Roll (Map.Invoke (loop x: Free<'``Functor<'T->'U>``,'T->'U> -> _) f: '``Functor<Free<'Functor<'U>,'U>>``)
5555
loop x f
5656

57-
let inline map2 (f: 'T->'U->'V) (x: Free<'``Functor<'T>``,'T>) (y: Free<'``Functor<'U>``,'U>) : Free<'``Functor<'V>``,'V> =
57+
let inline map2 ([<InlineIfLambda>]f: 'T->'U->'V) (x: Free<'``Functor<'T>``,'T>) (y: Free<'``Functor<'U>``,'U>) : Free<'``Functor<'V>``,'V> =
5858
let rec loop (y: Free<_,_>) (x: Free<_,_>) =
5959
match run x with
6060
| Pure x -> map<'U,'V,'``Functor<'U>``,'``Functor<Free<'Functor<'U>,'U>>``,'``Functor<Free<'Functor<'V>,'V>>``,'``Functor<'V>``> (f x) y : Free<'``Functor<'V>``,'V>
6161
| Roll (x: ^``Functor<Free<'Functor<'T>,'T>>``) -> Roll (Map.Invoke (loop y: Free<'``Functor<'T>``,'T> -> _) x: '``Functor<Free<'Functor<'V>,'V>>``)
6262
loop y x
6363

64-
let inline map3 (f: 'T->'U->'V->'W) (x: Free<'``Functor<'T>``,'T>) (y: Free<'``Functor<'U>``,'U>) (z: Free<'``Functor<'V>``,'V>) : Free<'``Functor<'W>``,'W> =
64+
let inline map3 ([<InlineIfLambda>]f: 'T->'U->'V->'W) (x: Free<'``Functor<'T>``,'T>) (y: Free<'``Functor<'U>``,'U>) (z: Free<'``Functor<'V>``,'V>) : Free<'``Functor<'W>``,'W> =
6565
let rec loop (y: Free<_,_>) (z: Free<_,_>) (x: Free<_,_>) =
6666
match run x with
6767
| Pure x -> map2<'U,'V,'W,'``Functor<'U>``,'``Functor<Free<'Functor<'U>,'U>>``,'``Functor<Free<'Functor<'W>,'W>>``,'``Functor<Free<'Functor<'V>,'V>>``,'``Functor<'V>``,'``Functor<'W>``> (f x) y z : Free<'``Functor<'W>``,'W>
6868
| Roll (x: ^``Functor<Free<'Functor<'T>,'T>>``) -> Roll (Map.Invoke (loop y z: Free<'``Functor<'T>``,'T> -> _) x: '``Functor<Free<'Functor<'W>,'W>>``)
6969
loop y z x
7070

7171
/// Folds the Free structure into a Monad
72-
let inline fold (f: '``Functor<'T>`` -> '``Monad<'T>``) (x: Free<'``Functor<'U>``,'U>) : '``Monad<'U>`` =
72+
let inline fold ([<InlineIfLambda>]f: '``Functor<'T>`` -> '``Monad<'T>``) (x: Free<'``Functor<'U>``,'U>) : '``Monad<'U>`` =
7373
let rec loop f x =
7474
match run x with
7575
| Pure a -> Return.Invoke a
7676
| Roll x -> f x >>= loop f
7777
loop f x
7878

7979
/// Tear down a Free monad using iteration.
80-
let inline iterM (f: '``Functor<'Monad<'T>>`` -> '``Monad<'T>``) (x: Free<'``Functor<'T>``,'T>) : '``Monad<'T>`` =
80+
let inline iterM ([<InlineIfLambda>]f: '``Functor<'Monad<'T>>`` -> '``Monad<'T>``) (x: Free<'``Functor<'T>``,'T>) : '``Monad<'T>`` =
8181
let rec loop f x =
8282
match run x with
8383
| Pure x -> Return.Invoke x
@@ -88,7 +88,7 @@ module Free =
8888
let inline liftF (x: '``Functor<'T>``) : Free<'``Functor<'T>``,'T> = Roll (Map.Invoke (Pure: 'T -> Free<'``Functor<'T>``,'T>) x : '``Functor<Free<'Functor<'T>,'T>>``)
8989

9090
/// Lift a natural transformation from functor F to functor G into a natural transformation from Free of F to Free of G.
91-
let inline hoist (f: ^``F<Free<'F<'T>, 'T>>`` -> ^``G<Free<'F<'T>, 'T>>``) (x: Free<'``F<'T>``, 'T>) : Free<'``G<'T>``, 'T> =
91+
let inline hoist ([<InlineIfLambda>]f: ^``F<Free<'F<'T>, 'T>>`` -> ^``G<Free<'F<'T>, 'T>>``) (x: Free<'``F<'T>``, 'T>) : Free<'``G<'T>``, 'T> =
9292
let rec loop f x =
9393
if opaqueId false then
9494
let _: '``G<Free<'F<'T>, 'T>>`` = Map.Invoke Unchecked.defaultof<Free<'``G<'T>``, 'T> -> Free<'``F<'T>``, 'T>> Unchecked.defaultof<'``G<Free<'G<'T>, 'T>>``>

0 commit comments

Comments
 (0)