I'm trying to define a module containing a generic type with operator overloading, but the mono compiler seems to ignore my types in the implementation file. My interface file looks like:
module Vector
[<Sealed>]
type Vector<'a> =
static member ( +. ) : Vector<'a> * Vector<'a> -> Vector<'a>
val make : 'a * 'a -> Vector<'a>
val coord : Vector<'a> -> 'a * 'a
And my implementation is
module Vector
type Vector<'a> =
| V of 'a * 'a
static member ( +. ) (V(x1,y1), V(x2,y2)) = V(x1+x2, y1+y2)
let make (x, y) = V(x, y)
let coord (V(x, y)) = (x, y)
When I compile I get:
fsharpc -a VectorParam.fsi VectorParam.fs
F# Compiler for F# 3.1 (Open Source Edition)
Freely distributed under the Apache 2.0 Open Source License
/.../VectorParam.fs(4,19): error FS0034: Module 'Vector' contains
static member Vector.( +. ) : Vector<int> * Vector<int> -> Vector<int>
but its signature specifies
static member Vector.( +. ) : Vector<'a> * Vector<'a> -> Vector<'a>
The types differ
which I don't understand, since I'm using a tagged type. And, if I remove all "<'a>" and replace remaining type aliases with float, then everything works fine. Can anyone help me understand the right syntax?
Thanks, Jon