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