Skip to content

Commit 1e0ad43

Browse files
committed
Workaround F# bug for generic bind
1 parent ad89c2a commit 1e0ad43

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/FSharpPlus/List.fs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ module ListT =
5858
loop l1 l2 : ListT<'mt>
5959

6060
let inline bind f (source: ListT<'mt>) : ListT<'mu> =
61-
let _mnil _ = (result Unchecked.defaultof<'t> : 'mt) >>= fun (_: 't) -> (result Unchecked.defaultof<'u>) : 'mu
62-
let rec loop f (ListT input) =
61+
let _mnil = (result Unchecked.defaultof<'t> : 'mt) >>= fun (_: 't) -> (result Unchecked.defaultof<'u>) : 'mu
62+
let rec loop f input =
6363
ListT (
64-
(unbox input : 'mit) >>= function
64+
(unwrap input : 'mit) >>= function
6565
| Nil -> result <| (Nil : ListTNode<'mu,'u>) : 'miu
6666
| Cons (h:'t, t: ListT<'mt>) ->
6767
let res = concat (f h: ListT<'mu>) (loop f t)

tests/FSharpPlus.Tests/ListT.fs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ module BasicTests =
2727
// Compile tests
2828
let binds () =
2929
let res1 = listT [| [1..4] |] >>= fun x -> listT [| [x * 2] |]
30-
let res2 = listT (Task.FromResult [1..4]) |> ListT.bind (fun x -> listT (Task.FromResult [x * 2]))
31-
let res3 = listT (ResizeArray [ [1..4] ]) |> ListT.bind (fun x -> listT (ResizeArray [ [x * 2] ]))
32-
let res4 = listT (lazy [1..4]) |> ListT.bind (fun x -> listT (lazy ( [x * 2])))
33-
let (res5: ListT<_ seq>) = listT (seq [ [1..4] ]) |> ListT.bind (fun x -> listT (seq [ [x * 2] ]))
34-
() // Note: seq needs type annotation, the non-sealead types don't work with generic >>= (internal error, unsolved type var)
30+
let res2 = listT (Task.FromResult [1..4]) >>= (fun x -> listT (Task.FromResult [x * 2]))
31+
let res3 = listT (ResizeArray [ [1..4] ]) >>= (fun x -> listT (ResizeArray [ [x * 2] ]))
32+
let res4 = listT (lazy [1..4]) >>= (fun x -> listT (lazy ( [x * 2])))
33+
let (res5: ListT<_ seq>) = listT (seq [ [1..4] ]) >>= (fun x -> listT (seq [ [x * 2] ]))
34+
() // Note: seq needs type annotation.
3535

3636
let bind_for_ideantity () =
3737
let res = listT (Identity [1..4]) >>= fun x -> listT (Identity [x * 2])

0 commit comments

Comments
 (0)