Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Seq seq type as a member parameter in F#

why does not this code work?

type Test() =
  static member func (a: seq<'a seq>) = 5.

let a = [[4.]]
Test.func(a)

It gives following error:

The type 'float list list' is not compatible with the type 'seq<seq<'a>>'
like image 883
Oldrich Svec Avatar asked Jul 29 '10 10:07

Oldrich Svec


1 Answers

Change your code to

type Test() = 
  static member func (a: seq<#seq<'a>>) = 5. 

let a = [[4.]] 
Test.func(a) 

The trick is in the type of a. You need to explicitly allow the outer seq to hold instances of seq<'a> and subtypes of seq<'a>. Using the # symbol enables this.

like image 108
Alex Humphrey Avatar answered Sep 21 '22 14:09

Alex Humphrey