You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes it's handy to break the lens laws, just a little bit. Specifically, it might be useful to have a lens that is allowed to "miss" its target, for which viewing returns false and setting is a no-op. There could even be a general function that given a predicate to determine when a lens won't miss, constructs an improper "falsy lens" which obeys the lens laws for all values the predicate returns true for, but for other values always views false and setting does nothing and returns the value unchanged. Currently, the syntax keyword sequence lenses are falsy lenses (but this behavior is undocumented).
The text was updated successfully, but these errors were encountered:
Note: This is a special case of the more general notion of monadic lenses, lenses that operate on monadic values instead of plain values. For a given monad type M, the monadic lens function types are (I think):
view :: Lens s a -> s -> M a
set :: Lens s a -> s -> a -> M s
transform :: Lens s a -> s -> (a -> M a) -> M s
In this case the specific monad is like the Maybe monad, but instead of monadic values being a Just wrapper around the plain value or Nothing, monadic values are plain values (except #f) or #f.
Sometimes it's handy to break the lens laws, just a little bit. Specifically, it might be useful to have a lens that is allowed to "miss" its target, for which viewing returns false and setting is a no-op. There could even be a general function that given a predicate to determine when a lens won't miss, constructs an improper "falsy lens" which obeys the lens laws for all values the predicate returns true for, but for other values always views false and setting does nothing and returns the value unchanged. Currently, the syntax keyword sequence lenses are falsy lenses (but this behavior is undocumented).
The text was updated successfully, but these errors were encountered: