# Pastebin 7zTQAoyz memo' :: forall t a. Grouping t => (t -> a) -> IO (t -> IO a) memo' t2a = do f <- getGroup (grouping @t) \ref1 -> do a <- readIORef ref1 pure \ref2 -> writeIORef ref2 a pure \t -> do ref <- newIORef (t2a t) -- laziness to the rescue f t ref readIORef ref