File tree Expand file tree Collapse file tree 1 file changed +24
-2
lines changed Expand file tree Collapse file tree 1 file changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -17,8 +17,30 @@ module BasicTests =
1717 CollectionAssert.AreEqual ( res, exp)
1818
1919 [<Test>]
20- let infiniteLists =
20+ let infiniteLists () =
2121 let ( infinite : ListT < Lazy < _ >>) = ListT.unfold ( fun x -> monad { return ( Some ( x, x + 1 ) ) }) 0
2222 let finite = take 12 infinite
2323 let res = finite <|> infinite
24- CollectionAssert.AreEqual ( res |> take 13 |> ListT.run |> extract, [ 0 ; 1 ; 2 ; 3 ; 4 ; 5 ; 6 ; 7 ; 8 ; 9 ; 10 ; 11 ; 0 ])
24+ CollectionAssert.AreEqual ( res |> take 13 |> ListT.run |> extract, [ 0 ; 1 ; 2 ; 3 ; 4 ; 5 ; 6 ; 7 ; 8 ; 9 ; 10 ; 11 ; 0 ])
25+
26+ // Compile tests
27+ let binds () =
28+ let res = listT ( [| [ 1 .. 4 ] |]) >>= fun x -> listT ( [| [ x * 2 ] |])
29+ () // but for some reason it doesn't work for Task, ResizeArray, Lazy and seq
30+
31+ let bind_for_ideantity () =
32+ let res = listT ( Identity [ 1 .. 4 ]) >>= fun x -> listT ( Identity [ x * 2 ])
33+ ()
34+
35+ let computation_expressions () =
36+ let oneTwoThree : ListT < _ > = monad.plus {
37+ do ! lift <| Async.Sleep 10
38+ yield 1
39+ do ! lift <| Async.Sleep 50
40+ yield 2
41+ yield 3 }
42+ ()
43+
44+ let applicative_with_options () =
45+ let x = (+) <!> listT None <*> listT ( Some [ 1 ; 2 ; 3 ; 4 ])
46+ () // It doesn't work with asyncs
You can’t perform that action at this time.
0 commit comments