Skip to content

Instantly share code, notes, and snippets.

@sevanspowell
Last active October 29, 2018 22:22
Show Gist options
  • Save sevanspowell/1f31a4e548266b64d0549ccabc474877 to your computer and use it in GitHub Desktop.
Save sevanspowell/1f31a4e548266b64d0549ccabc474877 to your computer and use it in GitHub Desktop.
Satisfying multiple "Has" constraints
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
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