Det här borde verkligen gå att komma längre med.
Mina försök har inte kommit längre än:
let inline map m f = (^x : (member Map: (^a -> ^b) -> ^n) m, f) let inline bind m f = (^x : (static member Bind: ^x -> (^a -> ^b) -> ^n) m, f) let inline (>>=) m f = (^x : (static member Bind: ^x -> (^a -> ^b) -> ^n) m, f)
Det verkar i sig fungera men inte tillsammans med extension-metoder:
type 'a Option with member Bind (x, fn) = match x with | None -> None | Some x -> fn x member x.Map (fn) = match x with | None -> None | Some x -> Some (fn x)
Abstract: ”Many components of a dependently typed programming language are by now well understood, for example the underlying type theory, type checking, unification and evaluation. How to combine these components into a realistic and usable high level language is, however, folklore, discovered anew by succesive language implementations. In this paper, I describe the implementation of a new dependently typed functional programming language, IDRIS. IDRIS is intended to be a general purpose programming language and as such provides high level concepts such as implicit syntax, type classes and do notation. I describe the high level language and the underlying type theory, and present a method for elaborating concrete high level syntax with implicit arguments and type classes into a fully explicit type theory. Furthermore, I show how this method, based on a domain specific language embedded in Haskell, facilitates the implementation of new high level language constructs.”