|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
Object | +--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.
| 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 |
Object name
| Constructor Detail |
Lens()
| Method Detail |
void error(msg)
thunk get_is(cval, val)
cval - The value in C to put through
val - The expected value of lens.get(cval) (in A)
thunk get_throws(cval, e_pred)
cval - The value to get (in C)
e_pred - {function} A predicate matching the desired exception
thunk getput(cval)
cval - The value to put through the lens
thunk putback_is(aval, cval, val)
aval - The value in A to put through
cval - The value in C
val - The expected value of lens.putback(aval, cval) (in C)
thunk putback_throws(aval, cval, <function> e_pred)
aval - The abstract tree to putback (in A)
cval - The concrete tree to putback (in C)
e_pred - A predicate matching the desired exception
thunk putget(aval, cval)
aval - The value in A to put through the lens
cval - The value in C to put through the lens
thunk putput(aval1, aval2, cval)
aval1 - The first value in A to put through the lens
aval2 - The second value in A
cval - The value in C
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||