Skip to content
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

+ HKTs Monad Transformers #482

Draft
wants to merge 35 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
ef60f80
Initial implementation
gusty Aug 23, 2019
032f0e5
+ Some basic tests
gusty Aug 23, 2019
7070c94
Roundtrip test fails with Lazy, use Async
gusty Aug 23, 2019
231da23
+ More tests
gusty Aug 23, 2019
ad89c2a
Adapt bind for non-sealed types
gusty Aug 23, 2019
1e0ad43
Workaround F# bug for generic bind
gusty Aug 23, 2019
9d646a6
Rename iter to iterM and add a (non-M) iter
gusty Aug 26, 2019
3dfad1c
fix
gusty Aug 26, 2019
20bbea6
+ filterM and filter
gusty Aug 26, 2019
e6f8549
fix
gusty Aug 26, 2019
cdb81a3
Align filterM filter type with iterM action type
gusty Aug 26, 2019
d68e3a5
+ Error, Reader Writer and State
gusty Jul 7, 2022
2011924
Fix tests
gusty Jul 7, 2022
11905eb
Fix try-finally
gusty Jul 8, 2022
b1d191c
Re-introduce dummy overload
gusty Jul 8, 2022
c3fb4fc
Split TryFinally
gusty Jul 8, 2022
95cfbe4
Split TryWith
gusty Jul 8, 2022
2733156
split more
gusty Jul 9, 2022
7207b2b
fix/add type annotations to docs
gusty Jul 9, 2022
038859e
HKTize Free and Coproduct
gusty Jul 10, 2022
ff912be
Bring ListT
gusty Jul 11, 2022
322b663
HKTize ListT
gusty Jul 15, 2022
9f8a5dc
Fix TyrFinally overload set for Fable
gusty Jul 15, 2022
0cb2e18
+ Fable version of ListT.Take without type params
gusty Jul 16, 2022
a92db9e
More accurate Delay signature
gusty Jul 17, 2022
46d7598
+ failing test
gusty Jul 19, 2022
026d1bd
Change TryWith and TryFinally signature
gusty Jul 19, 2022
18072da
Remove #exn type param
gusty Jul 20, 2022
772ac6d
Add ambiguity for each default overload
gusty Jul 20, 2022
bc55b44
Unify return type in TryWith
gusty Jul 22, 2022
860ddc4
Clean up try-blocks design
gusty Jul 24, 2022
ffe5685
add / remove spaces
gusty Sep 18, 2022
de38014
Better apply for ListT (not bind based)
gusty Sep 18, 2022
66438bf
bring master
gusty Mar 9, 2023
4840c2a
Fix in Try methods
gusty Sep 16, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions docsrc/content/abstraction-monad.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ let some14 =

(**
```f#
let fn : ResultT<Reader<int,Result<_,string>>> =
let fn : ResultT<string, Reader<int,__>, _> =
monad {
let! x1 = lift ask
let! x2 =
Expand Down Expand Up @@ -190,7 +190,7 @@ let decodeError = function

// Now the following functions compose the Error monad with the Async one.

let getValidPassword : ResultT<_> =
let getValidPassword : ResultT<_, _, _> =
monad {
let! s = liftAsync getLine
if isValid s then return s
Expand Down Expand Up @@ -262,11 +262,11 @@ module CombineReaderWithWriterWithResult =
let! w = eitherConv divide5By 6.0
let! x = eitherConv divide5By 3.0
let! y = eitherConv divide5By 0.0
let! z = eitherConv otherDivide5By 0.0 </catch/> (throw << (fun _ -> "Unknown error"))
let! z = eitherConv otherDivide5By 0.0 </catch/> (throw << (fun (_: unit) -> "Unknown error"))

return (w, x, y, z) }

let run expr = ReaderT.run expr >> ResultT.run >> Writer.run
let run expr = ReaderT.run expr >> ResultT.run >> Writer.run

let (_, log) = run divide DateTime.UtcNow

Expand Down
22 changes: 11 additions & 11 deletions src/FSharpPlus/Builders.fs
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,20 @@ module GenericBuilders =

type StrictBuilder<'``monad<'t>``> () =
inherit Builder<'``monad<'t>``> ()
member inline _.Delay ([<InlineIfLambda>]expr) = expr : unit -> '``Monad<'T>``
member inline _.Run ([<InlineIfLambda>]f) = f () : '``monad<'t>``
member inline _.TryWith ([<InlineIfLambda>]expr, [<InlineIfLambda>]handler) = TryWith.InvokeForStrict expr handler : '``Monad<'T>``
member inline _.TryFinally ([<InlineIfLambda>]expr, [<InlineIfLambda>]compensation) = TryFinally.InvokeForStrict expr compensation : '``Monad<'T>``
member __.Delay expr = expr : unit -> '``Monad<'T>``
member __.Run f = f () : '``monad<'t>``
member inline __.TryWith (expr, handler) = TryWith.Invoke expr handler : '``Monad<'T>``
member inline __.TryFinally (expr, compensation) = TryFinally.Invoke expr compensation : '``Monad<'T>``

member inline _.Using (disposable: #IDisposable, [<InlineIfLambda>]body) = Using.Invoke disposable body

type DelayedBuilder<'``monad<'t>``> () =
inherit Builder<'``monad<'t>``> ()
member inline _.Delay ([<InlineIfLambda>]expr: _->'``Monad<'T>``) = Delay.Invoke expr : '``Monad<'T>``
member _.Run f = f : '``monad<'t>``
member inline _.TryWith (expr, [<InlineIfLambda>]handler ) = TryWith.Invoke expr handler : '``Monad<'T>``
member inline _.TryFinally (expr, [<InlineIfLambda>]compensation) = TryFinally.Invoke expr compensation : '``Monad<'T>``
member inline _.Using (disposable: #IDisposable, [<InlineIfLambda>]body) = Using.Invoke disposable body : '``Monad<'T>``
member inline __.Delay (expr: _->'``Monad<'T>``) = Delay.Invoke expr : '``Monad<'T>``
member __.Run f = f : '``monad<'t>``
member inline __.TryWith (expr, handler ) = TryWith.InvokeFromDelayedCE (fun () -> expr) handler : '``Monad<'T>``
member inline __.TryFinally (expr, compensation) = TryFinally.Invoke (fun () -> expr) compensation : '``Monad<'T>``
member inline __.Using (disposable: #IDisposable, body) = Using.Invoke disposable body : '``Monad<'T>``

type MonadPlusStrictBuilder<'``monad<'t>``> () =
inherit StrictBuilder<'``monad<'t>``> ()
Expand Down Expand Up @@ -127,7 +127,7 @@ module GenericBuilders =

member inline this.While ([<InlineIfLambda>]guard, body: '``MonadPlus<'T>``) : '``MonadPlus<'T>`` =
// Check the type is lazy, otherwise display a warning.
let __ () = TryWith.InvokeForWhile (Unchecked.defaultof<'``MonadPlus<'T>``>) (fun (_: exn) -> Unchecked.defaultof<'``MonadPlus<'T>``>) : '``MonadPlus<'T>``
let __ () = TryWith.InvokeFromWhile (Unchecked.defaultof<'``MonadPlus<'T>``>) (fun (_: exn) -> Unchecked.defaultof<'``MonadPlus<'T>``>) : '``MonadPlus<'T>``

this.WhileImpl (guard, body)

Expand Down Expand Up @@ -167,7 +167,7 @@ module GenericBuilders =

member inline this.While ([<InlineIfLambda>]guard, body: '``Monad<unit>``) : '``Monad<unit>`` =
// Check the type is lazy, otherwise display a warning.
let __ () = TryWith.InvokeForWhile (Unchecked.defaultof<'``Monad<unit>``>) (fun (_: exn) -> Unchecked.defaultof<'``Monad<unit>``>) : '``Monad<unit>``
let __ () = TryWith.InvokeFromWhile (Unchecked.defaultof<'``Monad<unit>``>) (fun (_: exn) -> Unchecked.defaultof<'``Monad<unit>``>) : '``Monad<unit>``
this.WhileImpl (guard, body)

member inline this.For (p: #seq<'T>, [<InlineIfLambda>]rest: 'T->'``Monad<unit>``) : '``Monad<unit>``=
Expand Down
65 changes: 29 additions & 36 deletions src/FSharpPlus/Control/Monad.fs
Original file line number Diff line number Diff line change
Expand Up @@ -185,16 +185,14 @@ type Delay =
static member Delay (_mthd: Delay , x: unit-> Task<_> , _ ) = x () : Task<'T>
static member Delay (_mthd: Delay , x: unit-> Lazy<_> , _ ) = lazy (x().Value) : Lazy<'T>

static member inline Invoke (source : unit -> '``Monad<'T>``) : '``Monad<'T>`` =
static member inline Invoke (source : unit -> 'R) : 'R =
let inline call (mthd: ^M, input: unit -> ^I) = ((^M or ^I) : (static member Delay : _*_*_ -> _) mthd, input, Unchecked.defaultof<Delay>)
call (Unchecked.defaultof<Delay>, source)

#else

static member inline Invoke (source : unit -> '``Monad<'T>``) : '``Monad<'T>`` = Bind.Invoke (Return.Invoke ()) source

#endif

#if NETSTANDARD2_1 && !FABLE_COMPILER
static member Delay (_mthd: Delay , x: unit-> ValueTask<_> , _ ) = x () : ValueTask<'T>
#endif
Expand All @@ -221,71 +219,66 @@ type TryWith =
inherit Default1

[<CompilerMessage(MessageWhile , CodeWhile , IsError = false)>]
static member TryWith (_: unit -> '``Monad<'T>`` when '``Monad<'T>`` : not struct, _: exn -> '``Monad<'T>``, _: Default4, _defaults: While) = raise Internals.Errors.exnUnreachable

static member TryWith (_: unit -> '``Monad<'T>`` when '``Monad<'T>`` : not struct, _: exn -> '``Monad<'T>``, _: Default4, _defaults: While) = raise Internals.Errors.exnUnreachable
[<CompilerMessage(MessageWhile , CodeWhile , IsError = false)>]
static member TryWith (_: unit -> '``Monad<'T>`` when '``Monad<'T>`` : struct, _: exn -> '``Monad<'T>``, _: Default3, _defaults: While) = raise Internals.Errors.exnUnreachable
static member TryWith (_: unit -> '``Monad<'T>`` when '``Monad<'T>`` : struct, _: exn -> '``Monad<'T>``, _: Default3, _defaults: While) = raise Internals.Errors.exnUnreachable

[<CompilerMessage(MessageTryWith, CodeTryWith, IsError = true)>]
static member TryWith (_: unit -> '``Monad<'T>`` when '``Monad<'T>`` : not struct, _: exn -> '``Monad<'T>``, _: Default4, _defaults: False) = raise Internals.Errors.exnUnreachable

static member TryWith (_: unit -> '``Monad<'T>`` when '``Monad<'T>`` : not struct, _: exn -> '``Monad<'T>``, _: Default4, _defaults: False) = raise Internals.Errors.exnUnreachable
[<CompilerMessage(MessageTryWith, CodeTryWith, IsError = true)>]
static member TryWith (_: unit -> '``Monad<'T>`` when '``Monad<'T>`` : struct, _: exn -> '``Monad<'T>``, _: Default3, _defaults: False) = raise Internals.Errors.exnUnreachable
static member TryWith (_: unit -> '``Monad<'T>`` when '``Monad<'T>`` : struct, _: exn -> '``Monad<'T>``, _: Default3, _defaults: False) = raise Internals.Errors.exnUnreachable

static member TryWith (computation: unit -> '``Monad<'T>`` when '``Monad<'T>`` : not struct, catchHandler: exn -> '``Monad<'T>``, _: Default4, _defaults: True ) = try computation () with e -> catchHandler e
static member TryWith (computation: unit -> '``Monad<'T>`` when '``Monad<'T>`` : struct, catchHandler: exn -> '``Monad<'T>``, _: Default3, _defaults: True ) = try computation () with e -> catchHandler e

static member TryWith (computation: unit -> '``Monad<'T>`` when '``Monad<'T>`` : not struct, catchHandler: exn -> '``Monad<'T>``, _: Default4, _defaults: True) = try computation () with e -> catchHandler e
static member TryWith (computation: unit -> '``Monad<'T>`` when '``Monad<'T>`` : struct, catchHandler: exn -> '``Monad<'T>``, _: Default3, _defaults: True) = try computation () with e -> catchHandler e

static member inline TryWith (computation: unit -> '``Monad<'T>``, catchHandler: exn -> '``Monad<'T>``, _: Default1, _) = (^``Monad<'T>`` : (static member TryWith : _*_->_) computation (), catchHandler) : '``Monad<'T>``
static member inline TryWith (computation: unit -> '``Monad<'T>``, catchHandler: exn -> '``Monad<'T>``, _: Default1, _) = (^``Monad<'T>`` : (static member TryWith : _*_->_) computation, catchHandler) : '``Monad<'T>``
static member inline TryWith (_: unit -> ^t when ^t: null and ^t: struct, _ : exn -> 't , _: Default1, _) = ()

static member TryWith (computation: unit -> seq<_> , catchHandler: exn -> seq<_> , _: Default2, _) = seq (try (Seq.toArray (computation ())) with e -> Seq.toArray (catchHandler e))
static member TryWith (computation: unit -> NonEmptySeq<_>, catchHandler: exn -> NonEmptySeq<_>, _: Default2, _) = seq (try (Seq.toArray (computation ())) with e -> Seq.toArray (catchHandler e)) |> NonEmptySeq.unsafeOfSeq
static member TryWith (computation: unit -> 'R -> _ , catchHandler: exn -> 'R -> _ , _: Default2, _) = (fun s -> try (computation ()) s with e -> catchHandler e s) : 'R ->_
static member TryWith (computation: unit -> Async<_> , catchHandler: exn -> Async<_> , _: TryWith , _) = async.TryWith ((computation ()), catchHandler)
static member TryWith (computation: unit -> Async<_> , catchHandler: exn -> Async<_> , _: TryWith, _) = async.TryWith ((computation ()), catchHandler)
#if !FABLE_COMPILER
static member TryWith (computation: unit -> Task<_> , catchHandler: exn -> Task<_> , _: TryWith, True) = Task.tryWith computation catchHandler
#endif
static member TryWith (computation: unit -> Lazy<_> , catchHandler: exn -> Lazy<_> , _: TryWith , _) = lazy (try (computation ()).Force () with e -> (catchHandler e).Force ()) : Lazy<_>
static member TryWith (computation: unit -> Lazy<_> , catchHandler: exn -> Lazy<_> , _: TryWith, _) = lazy (try (computation ()).Force () with e -> (catchHandler e).Force ()) : Lazy<_>

static member inline Invoke (source: '``Monad<'T>``) (f: exn -> '``Monad<'T>``) : '``Monad<'T>`` =
let inline call (mthd: 'M, input: unit -> 'I, _output: 'R, h: exn -> 'I) = ((^M or ^I) : (static member TryWith : _*(exn -> _)*_*_ -> _) input, h, mthd, False)
call (Unchecked.defaultof<TryWith>, (fun () -> source), Unchecked.defaultof<'``Monad<'T>``>, f)
static member inline Invoke (source: unit ->'``Monad<'T>``) (f: exn -> '``Monad<'T>``) : '``Monad<'T>`` =
let inline call (mthd: 'M, input: unit -> 'I, _output: 'I, h: exn -> 'I) = ((^M or ^I) : (static member TryWith : _*(exn -> _)*_*_ -> 'I) input, h, mthd, True)
call (Unchecked.defaultof<TryWith>, source, Unchecked.defaultof<'``Monad<'T>``>, f)

static member inline InvokeForStrict (source: unit ->'``Monad<'T>``) (f: exn -> '``Monad<'T>``) : '``Monad<'T>`` =
let inline call (mthd: 'M, input: unit -> 'I, _output: 'R, h: exn -> 'I) = ((^M or ^I) : (static member TryWith : _*(exn -> _)*_*_ -> _) input, h, mthd, True)
/// Entry point for F#+ delayed builders, it doesn't consider defaults for try-with.
/// A compiler error is displayed if an implementation is not found.
static member inline InvokeFromDelayedCE (source: unit ->'``Monad<'T>``) (f: exn -> '``Monad<'T>``) : '``Monad<'T>`` =
let inline call (mthd: 'M, input: unit -> 'I, _output: 'I, h: exn -> 'I) = ((^M or ^I) : (static member TryWith : _*(exn -> _)*_*_ -> 'I) input, h, mthd, False)
call (Unchecked.defaultof<TryWith>, source, Unchecked.defaultof<'``Monad<'T>``>, f)

static member inline InvokeForWhile (source: '``Monad<'T>``) (f: exn -> '``Monad<'T>``) : '``Monad<'T>`` =
let inline call (mthd: 'M, input: unit -> 'I, _output: 'R, h: exn -> 'I) = ((^M or ^I) : (static member TryWith : _*(exn -> _)*_*_ -> _) input, h, mthd, While)
/// Entry point for F#+ delayed builders from While method
/// It doesn't consider defaults for TryWith, an error message is displayed if a suitable TryWith implementation is not found.
static member inline InvokeFromWhile (source: '``Monad<'T>``) (f: exn -> '``Monad<'T>``) : '``Monad<'T>`` =
let inline call (mthd: 'M, input: unit -> 'I, _output: 'I, h: exn -> 'I) = ((^M or ^I) : (static member TryWith : _*(exn -> _)*_*_ -> 'I) input, h, mthd, While)
call (Unchecked.defaultof<TryWith>, (fun () -> source), Unchecked.defaultof<'``Monad<'T>``>, f)


type TryFinally =
inherit Default1

static member TryFinally ((computation: unit -> seq<_> , compensation: unit -> unit), _: Default2, _, _) = seq (try (Seq.toArray (computation ())) finally compensation ())
static member TryFinally ((computation: unit -> NonEmptySeq<_>, compensation: unit -> unit), _: Default2, _, _) = seq (try (Seq.toArray (computation ())) finally compensation ()) |> NonEmptySeq.unsafeOfSeq

[<CompilerMessage(MessageTryFinally, CodeTryFinally, IsError = true)>]
static member TryFinally ((_: unit -> 'R -> _ , _: unit -> unit), _: Default2 , _, _defaults: False) = raise Internals.Errors.exnUnreachable
static member TryFinally ((computation: unit -> 'R -> _ , compensation: unit -> unit), _: Default2 , _, _defaults: True ) = fun s -> try computation () s finally compensation ()

static member TryFinally ((computation: unit -> Id<_> , compensation: unit -> unit), _: TryFinally, _, _) = try computation () finally compensation ()
static member TryFinally ((computation: unit -> Async<_>, compensation: unit -> unit), _: TryFinally, _, _) = async.TryFinally (computation (), compensation) : Async<_>
#if !FABLE_COMPILER
static member TryFinally ((computation: unit -> Task<_> , compensation: unit -> unit), _: TryFinally, _, True) = Task.tryFinally computation compensation : Task<_>
#else
static member TryFinally ((computation: unit -> Tuple<_> , compensation: unit -> unit), _: TryFinally, _, True) = try computation () finally compensation ()
#endif
static member TryFinally ((computation: unit -> Lazy<_> , compensation: unit -> unit), _: TryFinally, _, _) = lazy (try (computation ()).Force () finally compensation ()) : Lazy<_>

static member inline Invoke (source: '``Monad<'T>``) (f: unit -> unit) : '``Monad<'T>`` =
let inline call (mthd: 'M, input: unit ->'I, _output: 'I, h: unit -> unit) = ((^M or ^I) : (static member TryFinally : (_*_)*_*_*_ -> _) (input, h), mthd, Unchecked.defaultof<TryFinally>, False)
call (Unchecked.defaultof<TryFinally>, (fun () -> source), Unchecked.defaultof<'``Monad<'T>``>, f)

static member inline InvokeForStrict (source: unit ->'``Monad<'T>``) (f: unit -> unit) : '``Monad<'T>`` =
static member inline Invoke (source: unit ->'``Monad<'T>``) (f: unit -> unit) : '``Monad<'T>`` =
let inline call (mthd: 'M, input: unit ->'I, _output: 'I, h: unit -> unit) = ((^M or ^I) : (static member TryFinally : (_*_)*_*_*_ -> _) (input, h), mthd, Unchecked.defaultof<TryFinally>, True)
call (Unchecked.defaultof<TryFinally>, source, Unchecked.defaultof<'``Monad<'T>``>, f)

static member inline InvokeOnInstance (source: '``Monad<'T>``) (f: unit -> unit) : '``Monad<'T>`` = (^``Monad<'T>`` : (static member TryFinally : _*_->_) source, f) : '``Monad<'T>``
static member inline InvokeOnInstance (source: unit -> '``Monad<'T>``) (f: unit -> unit) : '``Monad<'T>`` = (^``Monad<'T>`` : (static member TryFinally : _*_->_) source, f) : '``Monad<'T>``

type TryFinally with

Expand All @@ -298,8 +291,8 @@ type TryFinally with
static member TryFinally ((computation: unit -> '``Monad<'T>`` when '``Monad<'T>`` : struct, compensation: unit -> unit), _: Default3, _: Default2, _defaults: True) = try computation () finally compensation ()
static member TryFinally ((computation: unit -> '``Monad<'T>`` when '``Monad<'T>`` : not struct, compensation: unit -> unit), _: Default3, _: Default1, _defaults: True) = try computation () finally compensation ()

static member inline TryFinally ((computation: unit -> '``Monad<'T>`` , compensation: unit -> unit), _: Default1, _: TryFinally, _) = TryFinally.InvokeOnInstance (computation ()) compensation: '``Monad<'T>``
static member inline TryFinally (( _ : unit -> ^t when ^t:null and ^t:struct , _ : unit -> unit), _: Default1, _ , _) = ()
static member inline TryFinally ((computation: unit -> '``Monad<'T>`` , compensation: unit -> unit), _: Default1, _: TryFinally, _defaults: _) = TryFinally.InvokeOnInstance computation compensation: '``Monad<'T>``
static member inline TryFinally (( _: unit -> ^t when ^t : null and ^t : struct , _ : unit -> unit), _: Default1, _ , _ ) = ()


type Using =
Expand All @@ -324,7 +317,7 @@ type Using =
type Using with
static member inline Using (resource: 'T when 'T :> IDisposable, body: 'T -> '``Monad<'U>`` when '``Monad<'U>``: struct , _: Default3) = using resource body
static member inline Using (resource: 'T when 'T :> IDisposable, body: 'T -> '``Monad<'U>`` when '``Monad<'U>``: not struct , _: Default2) = using resource body
static member inline Using (resource: 'T when 'T :> IDisposable, body: 'T -> '``Monad<'U>`` , _: Default1) = TryFinally.InvokeOnInstance (body resource) (fun () -> if not (isNull (box resource)) then resource.Dispose ()) : '``Monad<'U>``
static member inline Using (resource: 'T when 'T :> IDisposable, body: 'T -> '``Monad<'U>`` , _: Default1) = TryFinally.InvokeOnInstance (fun () -> body resource) (fun () -> if not (isNull (box resource)) then resource.Dispose ()) : '``Monad<'U>``
static member inline Using (resource: 'T when 'T :> IDisposable, body: 'T -> '``Monad<'U>`` , _: Using ) = Using.InvokeOnInstance resource body : '``Monad<'U>``
static member inline Using (_ , _ : 'a -> ^t when ^t : null and ^t: struct , _: Using ) = ()

Expand Down
6 changes: 3 additions & 3 deletions src/FSharpPlus/Data/Cont.fs
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ type Cont<'r,'t> with
static member (>=>) (f, (g: 'U -> _)) : 'T -> Cont<'R, 'V> = fun x -> Cont.bind g (f x)

static member Delay f = Cont (fun k -> Cont.run (f ()) k) : Cont<'R,'T>
static member TryWith (Cont c, h) = Cont (fun k -> try (c k) with e -> Cont.run (h e) k) : Cont<'R,'T>
static member TryFinally (Cont c, h) = Cont (fun k -> try (c k) finally h ()) : Cont<'R,'T>
static member Using (resource, f: _ -> Cont<'R,'T>) = Cont.TryFinally (f resource, fun () -> dispose resource)
static member TryWith (c: unit -> Cont<_, _>, h) = Cont (fun k -> try (Cont.run (c ()) k) with e -> Cont.run (h e) k) : Cont<'R,'T>
static member TryFinally (c: unit -> Cont<_, _>, h) = Cont (fun k -> try (Cont.run (c ()) k) finally h ()) : Cont<'R,'T>
static member Using (resource, f: _ -> Cont<'R,'T>) = Cont.TryFinally ((fun () -> f resource), fun () -> dispose resource)

[<EditorBrowsable(EditorBrowsableState.Never)>]
static member CallCC (f: ('T -> Cont<'R,'U>) -> _) = Cont.callCC f : Cont<'R,'T>
Expand Down
Loading