F# inner generics #642

Closed
cata opened this Issue Jan 20, 2017 · 2 comments

Comments

Projects
None yet
2 participants
@cata
Contributor

cata commented Jan 20, 2017

WebSharper 4 fails to compile the following valid F# code, with
"Failed to resolve generic parameter: b, found: a":

    let span pred l =
        let rec loop l cont =
            match l with
            | [] -> ([],[])
            | x::[] when pred x -> (cont l, [])
            | x::xs when not (pred x) -> (cont [], l)
            | x::xs when pred x -> loop xs (fun rest -> cont (x::rest))
            | _ -> failwith "Unrecognized pattern"
        loop l id
@Jand42

This comment has been minimized.

Show comment
Hide comment
@Jand42

Jand42 Feb 1, 2017

Member

Thanks for the report. In your sample, you can remove inner generics by a type annotation (cont: 'a list -> 'a list)

Generally, compiler could be improved that inner generic type parameters do not give an error, only when a macro would need it (when translation depends on the type), and then give a better error to move the function to a top level [<Inline>] for proper generic use.

Member

Jand42 commented Feb 1, 2017

Thanks for the report. In your sample, you can remove inner generics by a type annotation (cont: 'a list -> 'a list)

Generally, compiler could be improved that inner generic type parameters do not give an error, only when a macro would need it (when translation depends on the type), and then give a better error to move the function to a top level [<Inline>] for proper generic use.

@Jand42 Jand42 changed the title from F# compilation: Incorrect type inferrence to F# inner generics Feb 1, 2017

@Jand42 Jand42 closed this in 41dd922 Feb 10, 2017

@cata

This comment has been minimized.

Show comment
Hide comment
@cata

cata Jun 17, 2017

Contributor

Thanks for the fix!
Sorry for the belated response, I somehow missed your reply.

Contributor

cata commented Jun 17, 2017

Thanks for the fix!
Sorry for the belated response, I somehow missed your reply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment