diff --git a/R/lens.R b/R/lens.R index b7246c4..fe7b5cb 100644 --- a/R/lens.R +++ b/R/lens.R @@ -8,8 +8,8 @@ #' - **View-Set**: `set(d, l, view(d, l)) == d` #' - **Set-View**: `view(set(d, l, x), l) == x` #' - **Set-Set**: `set(set(d, l, x), l, y) == set(d, l, y)` -#' -#' These laws are not enforced by `tinylens`, but you should strive to follow them +#' +#' These laws are not enforced by `tinylens`, but you should strive to follow them #' when creating your own lenses. #' #' A best effort has been made to ensure that these laws hold for the lenses @@ -24,8 +24,16 @@ #' # create a trivial identity lens #' l <- lens(view = function(x) x, set = function(x, value) value) lens <- S7::new_class("lens", - package = packageName(), - properties = list( - "view" = NULL | class_function, - "set" = NULL | class_function - )) + package = packageName(), + properties = list( + "view" = NULL | class_function, + "set" = NULL | class_function + ), + constructor = function(view, set = NULL) { + S7::new_object( + S7::S7_object(), + view = view, + set = set + ) + } +) diff --git a/man/lens.Rd b/man/lens.Rd index 79b8455..2dbc6d3 100644 --- a/man/lens.Rd +++ b/man/lens.Rd @@ -4,7 +4,7 @@ \alias{lens} \title{Create a lens} \usage{ -lens(view = class_missing, set = class_missing) +lens(view, set = NULL) } \arguments{ \item{view}{A function that takes an object and returns a value}