Last active
August 29, 2015 14:24
-
-
Save dmitry-a-morozov/874d65a88d6bee6abaa7 to your computer and use it in GitHub Desktop.
object expression with interface chain
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type IOOP = abstract Mutate: unit -> unit | |
type IFunctional<'T> = abstract Reduce: 'T list * ('T -> 'T -> 'T) -> 'T | |
type ProgramThatMatters = | |
static member Run<'T, 'a when 'a :> IOOP and 'a :> IFunctional<'T>>(paradigm: 'a) = () | |
let myCode = { | |
new IFunctional<int> with | |
member __.Reduce(xs, f) = List.reduce f xs | |
interface IOOP with | |
member __.Mutate() = () | |
} | |
ProgramThatMatters.Run myCode | |
//fails to compile with | |
// Error 1 The type 'IFunctional<int>' is not compatible with the type 'IOOP' ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Workaround:
Spec (section 6.3.8):