optics
optics copied to clipboard
Unwrapping newtype should be easier than `coercedTo`.
A minimal example of unwrapping a newtype
{-# LANGUAGE TypeApplications #-}
import Optics.Core
newtype Index = Index Int deriving (Show, Eq)
ix :: Index
ix = Index 3
ix2 = ix & coercedTo @Int %~ (*2)
@Int
bugs me. When I unwrap a newtype, I shouldn't have to specify the wrapped type.
coerced
often fails to infer the right types without explicit type declarations.