News for hackers. Stuff that matters.
Re:OCaml: Objects by tel on Monday March 16, 2015 @02:55PM (#9213482)
I agree that basic (non van Laarhoven) lenses are pretty achievable in OCaml, though I tend to forget about them.

Truly what you want is the "pre-applied" lens or the store comonad

    type ('i, 'j) store = { get : 'j; set : 'j -> 'i };;
Then object types can have something like

    let o = object
      val slot = 3
      method slot = 
        { get = slot
        ; set = fun slot' -> {< slot = slot' >}
        }
    end
which has type

    val o : < slot : ('a, int) store > as 'a
which is kind of a cool pattern.

    # o#slot.get;;
    - : int = 3
    # (o#slot.set 10)#slot.get;;
    - : int = 10
    # o#slot.set o#slot.get;;
    - : < slot : ('a, int) store > as 'a = <obj>
Re:OCaml: Objects by kxyvr on Monday March 16, 2015 @03:34PM (#9213777)
That is an interesting pattern that essentially does what I need and is much easier to macro expand. Nice job on the pattern!
Re:OCaml: Objects by tel on Monday March 16, 2015 @03:45PM (#9213866)
To be fair, this is completely stolen from the Lens literature in Haskell :)