38 |
53 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/src/Freckle/Helpers.fs:
--------------------------------------------------------------------------------
1 | ///A helper module used for the library, use at your own discrestion
2 | module FSharp.Helpers
3 |
4 | let inline undefined<'a> : 'a = failwith "undefined"
5 |
6 | let inline swap (a,b) = (b,a)
7 |
8 | let inline flip f a b = f b a
9 |
10 | let inline const' k = fun _ -> k
11 |
12 |
13 | let safeUnbox (o : obj) =
14 | match o with
15 | | :? 'a as a -> Some a
16 | | _ -> None
17 |
18 | let tuple fst snd = (fst, snd)
19 |
20 |
21 | type SortedType(t) =
22 | member x.Type : System.Type = t
23 | override x.Equals(yobj) =
24 | match yobj with
25 | | :? SortedType as y -> (x.Type = y.Type)
26 | | _ -> false
27 | override x.GetHashCode() = hash x.Type
28 | interface System.IComparable with
29 | member x.CompareTo yobj =
30 | match yobj with
31 | | :? SortedType as y -> compare (hash x.Type) (hash y.Type)
32 | | _ -> invalidArg "yobj" "cannot compare values of different types"
33 | module AutoResetEvent =
34 | open System.Threading
35 |
36 | let wait (a : AutoResetEvent) = a.WaitOne() |> ignore
37 |
38 | let release (a : AutoResetEvent) = a.Set() |> ignore
39 |
40 | module Async =
41 | open System.Threading
42 | open System.Threading.Tasks
43 |
44 | let (>>=) ma f = async.Bind(ma, f)
45 | let ( *>>) ma mb = async.Bind(ma, (fun _ -> mb))
46 |
47 | let startFreeChild a =
48 | a
49 | |> Async.StartChild
50 | |> Async.Ignore
51 |
52 | let doNothing = async.Zero()
53 |
54 | type Signal<'a> = Continue of 'a
55 | | Completed of 'a
56 |
57 | let recursion (f : 's -> AsyncPM> Install-Package Freckle25 |