# Pastebin Dio1MtKJ memo' :: forall t a. Grouping t => (t -> a) -> IO (t -> IO a) memo' t2a = do f <- getGroup (grouping @t) \(t, ref1) -> let a = t2a t writeIORef ref1 a pure \(_, ref2) -> writeIORef ref2 a pure \t -> do ref <- newIORef undefined f t (t, ref) readIORef ref