Class Lens

Object
   |
   +--Lens
Direct Known Subclasses:
LFocus, LCcond, LLength, LConst, LMap, LConcat, LAdd, LWmap, LHoistNonunique, LPlunge, LRename, LCopy, LXfork, LTextTag, LFork, LMerge, LLayout, LListFilter, LOp, LPrune, LHead, LIndex, LReverse, LFilter, LAcond, LTail, LRotate, LConstTag, lens, LOptionTag, LOrder, LError, LArith, LCond, LRenameIfPresent, LTag, LHoist, LGroup, LSeq, LId

class Lens


Lenses work over two domains, A ("abstract") and C ("concrete"). The types of the get and putback functions are:

     get :: C -> A
     putback :: A x C -> C
 

Thus these are much better termed "project" and "merge". In the case of the lens library, C is taken to be a JavaScript model (e.g. the domain of values in JavaScript) and A is taken to be the DOM. Thus, in Flapjax terms, get is "insertDom" and putback is "extract". Don't be daunted by the use of 'abstract tree' and 'concrete tree' in the documentation -- it's an artifact of the theoretical research on bidirectional computation.

Lenses are themselves implemented as objects with get and putback methods; the resulting lens driver requires nothing else, but won't interfere with other fields or methods. Thus it is not required to have the prototype of a lens constructor point to Lens, but this library follows that pattern.


Defined in lens.js


Field Summary
 Object name
          
 
Constructor Summary
Lens()
           
 
Method Summary
 void error(msg)
          
 thunk get_is(cval, val)
           Tests that the get of a lens is equal to some value.
 thunk get_throws(cval, e_pred)
           Tests that get of a lens throws a specific error.
 thunk getput(cval)
           Tests the getput law: For all c in C and a in A, put(get(c), a) = c
 thunk putback_is(aval, cval, val)
           Tests that the putback of a lens is equal to some value.
 thunk putback_throws(aval, cval, <function> e_pred)
           Tests that putback of a lens throws a specific error.
 thunk putget(aval, cval)
           Tests the putget law: For all c in C and a in A, get(putback(a, c)) = a
 thunk putput(aval1, aval2, cval)
           Tests the putput pseudo-law, which is not true of all lenses: For all c in C and a1, a2 in A, putback(a2, putback(a1, c)) = putback(a2, c)

Field Detail

name

Object name

Constructor Detail

Lens

Lens()

Method Detail

error

void error(msg)

get_is

thunk get_is(cval, val)

get_throws

thunk get_throws(cval, e_pred)

getput

thunk getput(cval)

putback_is

thunk putback_is(aval, cval, val)

putback_throws

thunk putback_throws(aval, cval, <function> e_pred)

putget

thunk putget(aval, cval)

putput

thunk putput(aval1, aval2, cval)


Documentation generated by JSDoc on Wed Feb 14 15:36:01 2007