haskell - How to "compose" Iso's? -


here type:

newtype sanedate = sanedate universaltime    deriving (show, eq, typeable, generic) makewrapped ''sanedate 

now need iso type:

reprbuild :: iso' (maybe universaltime) (fist sanedate) 

i did this:

reprbuild = iso    (\ t -> first (sanedate <$> t) )    (\ sane_first -> fmap (^. _wrapped) $ getfirst sane_first  ) 

but have impression i'm working extra-hard. there (shorter) way of writing reprbuild iso composition of things?

recent versions of lens have built in:

reprbuild = coerced 

of course, requires safe coercions available since 7.10; backwards compatibility use manual approach mapping.


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

unity3d - Fatal error- Monodevelop-Unity failed to start -