Last active
October 29, 2018 22:22
-
-
Save sevanspowell/1f31a4e548266b64d0549ccabc474877 to your computer and use it in GitHub Desktop.
Satisfying multiple "Has" constraints
This file contains hidden or 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
fn | |
:: ( Monad m | |
, MonadReader r m | |
, HasX r m | |
, HasY r m | |
, HasZ r m | |
) | |
=> m Bool | |
fn = do | |
r <- ask | |
pure True | |
run = runReaderT fn _f |
This file contains hidden or 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
data Xyz = | |
Xyz { _xyzX :: X | |
, _xyzY :: Y | |
, _xyzZ :: Z | |
} | |
makeLenses ''Xyz | |
instance HasX Xyz where | |
x = xyzX | |
instance HasY Xyz where | |
y = xyzY | |
instance HasZ Xyz where | |
z = xyzZ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment