我如何将它变成 Setter?
How do I turn this into a Setter?
setOwner :: File -> User -> File
setOwner f o = f & ownerID .~ (o ^. User.uid)
如何将其变成 Setter
?
我不能把它做成镜头因为getUser :: UserID -> IO User
是一个不纯的函数。
我刚刚意识到我之前的回答是错误的。哎呀!
给你:
ownerS :: Setter File File () User
ownerS = sets (\f file -> setOwner file (f ()))
setOwner :: File -> User -> File
setOwner f o = f & ownerID .~ (o ^. User.uid)
如何将其变成 Setter
?
我不能把它做成镜头因为getUser :: UserID -> IO User
是一个不纯的函数。
我刚刚意识到我之前的回答是错误的。哎呀!
给你:
ownerS :: Setter File File () User
ownerS = sets (\f file -> setOwner file (f ()))