If I have a newtype
newtype Foo = Foo Int
is there an automatic way to get an Iso' Foo Int
?
I saw I could use makeLenses ''Foo
, but I don't know what is the name of the generated iso.
If I have a newtype
newtype Foo = Foo Int
is there an automatic way to get an Iso' Foo Int
?
I saw I could use makeLenses ''Foo
, but I don't know what is the name of the generated iso.
If you name the accessor: newtype Foo = Foo {_unFoo :: Int}
and then do makeLenses ''Foo, it will generate the Iso you want under the name "unFoo"
Note that the accessor must start with an underscore for it to generate the Iso.