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
Post a Comment