Reputation: 58735
If I have a record type with lenses, is it possible to construct a new record without using the underlying record accessors?
{-# LANGUAGE TemplateHaskell #-}
import Control.Lens
import Control.Lens.TH
data Foo = Foo { _s :: String
, _b :: Bool
} deriving (Show, Eq)
makeLenses ''Foo
I could make Foo
an instance of Data.Default
and then modifiy def
with lenses, but not all record types will have sensible defaults. Does Control.Lens have its own way to do it?
Upvotes: 8
Views: 906