| Safe Haskell | Safe |
|---|---|
| Language | Haskell2010 |
Contains
Description
Synopsis
-
class Contains a b where
- to :: a -> b
-
class With a b where
- with :: a -> b -> a
- onContained :: (Contains a b, With a b) => (b -> b) -> a -> a
- onContainedE :: (Contains a b, With a b) => MonadError e m => (b -> m b) -> a -> m a
Documentation
Class to extract a piece b from a type a. Used for generically
extracting values and can be used together with With to map
over a subpart of a type.
Please refrain from writing convenience instances for setting a single
field of a record, and also from writing the automatic lifting
Contains a b => Contains a c => Contains (b, c). That would yield
harder to understand code, for not much value.
I could also use lens terminology, this is close to view
Instances
| Contains Deck T # | |
| Contains Game T # | |
| Contains Game (Kernel ()) # | |
| Contains Game (Kernel Player) # | |
| Contains (Playable a) a # | |
| Contains (Playable a) (T Core) # | |
| (Contains (Playable a) (T Core), Contains (Playable a) a) => Contains (Playable a) (T Core, a) # | |
| Contains (Kernel a) (Model, T Core, T UI) # | |
| Contains (Kernel a) (Model, T Core, T UI, Animation) # | |
Class to set a piece b into a value of type a.
Please refrain from writing convenience instances for setting a single
field of a record, and also from writing the automatic lifting
Contains a b => Contains a c => Contains (b, c). That would yield
harder to understand code, for not much value.
I could also use lens terminology, this is a variant of over
Instances
| With World Coord # | |
| With Game (Kernel ()) # | |
| With Game (Kernel Player) # | |
| With (Playable a) a # | |
| With (Player a) Coord # | |
| With (Playable a) (T Core) # | |
| (With (Playable a) (T Core), With (Playable a) a) => With (Playable a) (T Core, a) # | |
| With (Kernel a) (Model, T Core, T UI) # | |
| With (Kernel a) (Model, T Core, T UI, Animation) # | |
onContained :: (Contains a b, With a b) => (b -> b) -> a -> a #
onContained f a applies f on the subset of a of type b and
then returns a variant of a where the subset has been mapped over.
onContainedE :: (Contains a b, With a b) => MonadError e m => (b -> m b) -> a -> m a #
onContainedE f a applies f on the subset of a of type b and
then returns a variant of a where the subset has been mapped over. Fails
if the application on the subset fails.