-
-
Save tonymorris/1bbc3aff874a97722d78cb9a9154c494 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE LambdaCase #-} | |
import Control.Lens | |
data UserInfo v b = | |
StartUpRemoteUser | |
{ _privateKey :: v -- ^ The startup key when the tree is created by the | |
-- administrator. | |
, _publicKey :: b -- ^ The public key of the remote user. | |
} | |
| RemoteUser | |
{ | |
_publicKey :: b -- ^ The public key of the remote user. | |
} | |
| LocalUser | |
{ _privateKey :: v -- ^ The private key of the local user | |
, _publicKey :: b -- ^ The public key of the local user | |
} | |
deriving Eq | |
_StartUpRemoteUser :: | |
Prism' | |
(UserInfo v b) | |
(v, b) | |
_StartUpRemoteUser = | |
prism' | |
(\(v, b) -> StartUpRemoteUser v b) | |
(\case | |
StartUpRemoteUser v b -> Just (v, b) | |
_ -> Nothing | |
) | |
_StartUpRemoteUser_privateKey :: | |
Traversal' | |
(UserInfo v b) | |
v | |
_StartUpRemoteUser_privateKey = | |
_StartUpRemoteUser . _1 | |
getPrivateKey :: | |
UserInfo v b | |
-> Maybe v | |
getPrivateKey = | |
preview _StartUpRemoteUser_privateKey | |
overPrivateKey :: | |
(v -> v) | |
-> UserInfo v b | |
-> UserInfo v b | |
overPrivateKey = | |
over _StartUpRemoteUser_privateKey | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment