@@ -76,8 +76,6 @@ module ProcessHelper =
7676 ()
7777 }
7878
79-
80-
8179type ResultOrString < 'a > = Result< 'a, string>
8280
8381type Serializer = obj -> string
@@ -251,141 +249,6 @@ module AsyncResult =
251249 let inline bimap okF errF r = Async.map ( Result.bimap okF errF) r
252250 let inline ofOption recover o = Async.map ( Result.ofOption recover) o
253251
254- // Maybe computation expression builder, copied from ExtCore library
255- /// https://github.com/jack-pappas/ExtCore/blob/master/ExtCore/Control.fs
256- [<Sealed>]
257- type MaybeBuilder () =
258- // 'T -> M<'T>
259- [<DebuggerStepThrough>]
260- member inline __.Return value : 'T option = Some value
261-
262- // M<'T> -> M<'T>
263- [<DebuggerStepThrough>]
264- member inline __.ReturnFrom value : 'T option = value
265-
266- // unit -> M<'T>
267- [<DebuggerStepThrough>]
268- member inline __.Zero () : unit option = Some() // TODO: Should this be None?
269-
270- // (unit -> M<'T>) -> M<'T>
271- [<DebuggerStepThrough>]
272- member __.Delay ( f : unit -> 'T option ) : 'T option = f ()
273-
274- // M<'T> -> M<'T> -> M<'T>
275- // or
276- // M<unit> -> M<'T> -> M<'T>
277- [<DebuggerStepThrough>]
278- member inline __.Combine ( r1 , r2 : 'T option ) : 'T option =
279- match r1 with
280- | None -> None
281- | Some() -> r2
282-
283- // M<'T> * ('T -> M<'U>) -> M<'U>
284- [<DebuggerStepThrough>]
285- member inline __.Bind ( value , f : 'T -> 'U option ) : 'U option = Option.bind f value
286-
287- // 'T * ('T -> M<'U>) -> M<'U> when 'U :> IDisposable
288- [<DebuggerStepThrough>]
289- member __.Using ( resource : ( 'T :> IDisposable ), body : _ -> _ option ) : _ option =
290- try
291- body resource
292- finally
293- if not <| obj.ReferenceEquals( null , box resource) then
294- resource.Dispose()
295-
296- // (unit -> bool) * M<'T> -> M<'T>
297- [<DebuggerStepThrough>]
298- member x.While ( guard , body : _ option ) : _ option =
299- if guard () then
300- // OPTIMIZE: This could be simplified so we don't need to make calls to Bind and While.
301- x.Bind( body, ( fun () -> x.While( guard, body)))
302- else
303- x.Zero()
304-
305- // seq<'T> * ('T -> M<'U>) -> M<'U>
306- // or
307- // seq<'T> * ('T -> M<'U>) -> seq<M<'U>>
308- [<DebuggerStepThrough>]
309- member x.For ( sequence : seq < _ >, body : 'T -> unit option ) : _ option =
310- // OPTIMIZE: This could be simplified so we don't need to make calls to Using, While, Delay.
311- x.Using( sequence.GetEnumerator(), ( fun enum -> x.While( enum .MoveNext, x.Delay( fun () -> body enum .Current))))
312-
313- [<Sealed>]
314- type AsyncMaybeBuilder () =
315- [<DebuggerStepThrough>]
316- member __.Return value : Async < 'T option > = Some value |> async.Return
317-
318- [<DebuggerStepThrough>]
319- member __.ReturnFrom value : Async < 'T option > = value
320-
321- [<DebuggerStepThrough>]
322- member __.ReturnFrom ( value : 'T option ) : Async < 'T option > = async.Return value
323-
324- [<DebuggerStepThrough>]
325- member __.Zero () : Async < unit option > = Some() |> async.Return
326-
327- [<DebuggerStepThrough>]
328- member __.Delay ( f : unit -> Async < 'T option >) : Async < 'T option > = f ()
329-
330- [<DebuggerStepThrough>]
331- member __.Combine ( r1 , r2 : Async < 'T option >) : Async < 'T option > =
332- async {
333- let! r1 ' = r1
334-
335- match r1' with
336- | None -> return None
337- | Some() -> return ! r2
338- }
339-
340- [<DebuggerStepThrough>]
341- member __.Bind ( value : Async < 'T option >, f : 'T -> Async < 'U option >) : Async < 'U option > =
342- async {
343- let! value ' = value
344-
345- match value' with
346- | None -> return None
347- | Some result -> return ! f result
348- }
349-
350- [<DebuggerStepThrough>]
351- member __.Bind ( value : 'T option , f : 'T -> Async < 'U option >) : Async < 'U option > =
352- async {
353- match value with
354- | None -> return None
355- | Some result -> return ! f result
356- }
357-
358- [<DebuggerStepThrough>]
359- member __.Using ( resource : ( 'T :> IDisposable ), body : _ -> Async < _ option >) : Async < _ option > =
360- try
361- body resource
362- finally
363- if not << isNull <| resource then
364- resource.Dispose()
365-
366- [<DebuggerStepThrough>]
367- member x.While ( guard , body : Async < _ option >) : Async < _ option > =
368- if guard () then
369- x.Bind( body, ( fun () -> x.While( guard, body)))
370- else
371- x.Zero()
372-
373- [<DebuggerStepThrough>]
374- member x.For ( sequence : seq < _ >, body : 'T -> Async < unit option >) : Async < _ option > =
375- x.Using( sequence.GetEnumerator(), ( fun enum -> x.While( enum .MoveNext, x.Delay( fun () -> body enum .Current))))
376-
377- [<DebuggerStepThrough>]
378- member inline __.TryWith ( computation : Async < 'T option >, catchHandler : exn -> Async < 'T option >) : Async < 'T option > =
379- async.TryWith( computation, catchHandler)
380-
381- [<DebuggerStepThrough>]
382- member inline __.TryFinally ( computation : Async < 'T option >, compensation : unit -> unit ) : Async < 'T option > =
383- async.TryFinally( computation, compensation)
384-
385- [<CompilationRepresentation( CompilationRepresentationFlags.ModuleSuffix) >]
386- module AsyncMaybe =
387- let inline liftAsync ( async : Async < 'T >) : Async < _ option > = async |> Async.map Some
388-
389252
390253[<RequireQualifiedAccess>]
391254[<CompilationRepresentation( CompilationRepresentationFlags.ModuleSuffix) >]
@@ -533,9 +396,6 @@ module List =
533396 |> List.groupBy ( fst)
534397 |> List.map ( fun ( key , list ) -> key, list |> List.map snd)
535398
536-
537-
538-
539399[<RequireQualifiedAccess>]
540400[<CompilationRepresentation( CompilationRepresentationFlags.ModuleSuffix) >]
541401module String =
@@ -731,8 +591,6 @@ type Path with
731591
732592let inline debug msg = Printf.kprintf Debug.WriteLine msg
733593let inline fail msg = Printf.kprintf Debug.Fail msg
734- let asyncMaybe = AsyncMaybeBuilder()
735- let maybe = MaybeBuilder()
736594
737595
738596let chooseByPrefix ( prefix : string ) ( s : string ) =
0 commit comments