5 people like it.

Duck Typed Dereferencing!

Make the (!) operator even more useful by duck typing it. Simple and effective!

1: 
2: 
3: 
4: 
/// Duck typed dereferencing operator. Duck typing enables us to use it with
/// other types besides reference cells, for example, lazy values and options,
/// as well as any of your own types that implement the Value property.
let inline ( ! ) x = (^X : (member get_Value : unit -> _) (x))
val x : 'X (requires member get_Value)
type unit = Unit

Full name: Microsoft.FSharp.Core.unit
Raw view New version

More information

Link:http://fssnip.net/nI
Posted:5 years ago
Author:Sami Perttu
Tags: operators , options , lazy values , reference cells