Fsharpplus: traverse: A unique overload for method 'Traverse' could not be determined

Created on 2 May 2020  路  2Comments  路  Source: fsprojects/FSharpPlus

Repro steps

This code:

open FSharpPlus

let doSomething v =
    printfn "doSomething: %A" v
    sprintf "some: %A" v
    |> async.Return

seq [1..10] 
|> traverse doSomething
|> map  (head >> printfn "%A")
|> Async.Start

generates the following error message:

typecheck: A unique overload for method 'Traverse' could not be determined based on type information prior to this program point. 
A type annotation may be needed. Candidates: 
static member Control.Traverse.Traverse : t:seq<'T> * f:('T ->  ^Functor<'U>) * _output: ^Functor<seq<'U>> * _impl:Internals.Default2 ->  ^Functor<seq<'U>> when (Control.Apply or  ^a2 or  ^Functor<'U> or  ^a3) : (static member ( <*> ) :  ^a2 *  ^Functor<'U> *  ^a3 * Control.Apply ->  ^a3) and (Control.IsLeftZero or  ^Functor<'U>) : (static member IsLeftZero :  ^Functor<'U> ref * Control.IsLeftZero -> bool) and (Control.Map or  ^a3 or  ^a2) : (static member Map : ( ^a3 * ('a5 [] -> 'a5 -> 'a5 [])) * Control.Map ->  ^a2) and (Control.Return or  ^a3) : (static member Return :  ^a3 * Control.Return -> 'a4 [] ->  ^a3) and (Control.Map or  ^a3 or  ^Functor<seq<'U>>) : (static member Map : ( ^a3 * ('a7 [] -> seq<'a7>)) * Control.Map ->  ^Functor<seq<'U>>), 
static member Control.Traverse.Traverse : t:seq<'a0> * f:('a0 ->  ^a1) * _output:'R * _impl:Internals.Default3 ->  ^a4 when (Control.Map or  ^a1 or  ^a2) : (static member Map : ( ^a1 * ('a -> seq<'a> -> seq<'a>)) * Control.Map ->  ^a2) and (Control.Apply or  ^a2 or  ^a4) : (static member ( <*> ) :  ^a2 *  ^a4 *  ^a4 * Control.Apply ->  ^a4) and (Control.Return or  ^a4) : (static member Return :  ^a4 * Control.Return -> seq<'a5> ->  ^a4), 
static member Control.Traverse.Traverse : t:seq<'t> * f:('t -> Async<'u>) * _output:Async<seq<'u>> * _impl:Internals.Default2 -> Async<seq<'u>>

Expected behavior

No error messages

Known workarounds

sequence works as expected:

open FSharpPlus

let doSomething v =
    printfn "doSomething: %A" v
    sprintf "some: %A" v
    |> async.Return

seq [1..10] 
|> map doSomething
|> sequence 
|> map  (head >> printfn "%A")
|> Async.Start

generating output:

doSomething: 1
"some: 1"
bug

Most helpful comment

A fix for this is ready to go in #317
Tests seems to be passing, but I leave it open in order to give some time to try to figure out if there are other types involved in the regression.

All 2 comments

I updated your code (print wasn't in this lib) and I confirm this is a regression.

For instance in 1.1.0-RC3 it works fine.

A fix for this is ready to go in #317
Tests seems to be passing, but I leave it open in order to give some time to try to figure out if there are other types involved in the regression.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

TOTBWF picture TOTBWF  路  7Comments

cannorin picture cannorin  路  5Comments

robkuz picture robkuz  路  5Comments

NickDarvey picture NickDarvey  路  9Comments

cmeeren picture cmeeren  路  10Comments