# Pastebin HgYfkiew {-# LANGUAGE TemplateHaskell #-} import Control.Lens newtype Foo a = Foo { _ayys :: [a] } deriving (Show) newtype Bar = Bar { _bar :: Int } deriving Show newtype Baz = Baz { _baz :: String } deriving Show -- I normally use generic-lens these days but whatever. $(makeLenses ''Foo) $(makeLenses ''Bar) $(makeLenses ''Baz) foos :: [Foo Bar] foos = [Foo [Bar 2, Bar 3], Foo [Bar 5], Foo [Bar 7, Bar 11, Bar 13]] batch :: [Bar] -> IO [Baz] batch = pure . map (Baz . show . _bar) bars :: IO [Foo Baz] bars = foos & unsafePartsOf (traverse . ayys . traverse) %%~ batch