如何将其变为Setter?

时间:2016-01-22 08:38:10

标签: haskell lens lenses

setOwner :: File -> User -> File
setOwner f o = f & ownerID .~ (o ^. User.uid)

如何将其转换为Setter

我无法将它变成镜头,因为getUser :: UserID -> IO User是一种不纯的功能。

1 个答案:

答案 0 :(得分:1)

我刚刚意识到我之前的回答是错误的。糟糕!

你走了:

ownerS :: Setter File File () User
ownerS = sets (\f file -> setOwner file (f ()))