app

Safe Haskell Safe
Language Haskell2010

Contains

Description

Module concerned with the Contains and With classes, that deals with types containing other types.

Synopsis

Documentation

class Contains a b where #

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

Methods

to :: a -> b #

Instances
Contains Deck T #  
Instance details

Defined in Model

Methods

to :: Deck -> T #

Contains Game T #  
Instance details

Defined in Model

Methods

to :: Game -> T #

Contains Game (Kernel ()) #  
Instance details

Defined in Move

Methods

to :: Game -> Kernel () #

Contains Game (Kernel Player) #  
Instance details

Defined in Move

Methods

to :: Game -> Kernel Player #

Contains (Playable a) a #  
Instance details

Defined in Game

Methods

to :: Playable a -> a #

Contains (Playable a) (T Core) #  
Instance details

Defined in Game

Methods

to :: Playable a -> T Core #

(Contains (Playable a) (T Core), Contains (Playable a) a) => Contains (Playable a) (T Core, a) #  
Instance details

Defined in Game

Methods

to :: Playable a -> (T Core, a) #

Contains (Kernel a) (Model, T Core, T UI) #  
Instance details

Defined in Move

Methods

to :: Kernel a -> (Model, T Core, T UI) #

Contains (Kernel a) (Model, T Core, T UI, Animation) #  
Instance details

Defined in Move

Methods

to :: Kernel a -> (Model, T Core, T UI, Animation) #

class With a b where #

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

Methods

with :: a -> b -> a #

Instances
With World Coord #  
Instance details

Defined in Model

Methods

with :: World -> Coord -> World #

With Game (Kernel ()) #  
Instance details

Defined in Move

Methods

with :: Game -> Kernel () -> Game #

With Game (Kernel Player) #  
Instance details

Defined in Move

Methods

with :: Game -> Kernel Player -> Game #

With (Playable a) a #  
Instance details

Defined in Game

Methods

with :: Playable a -> a -> Playable a #

With (Player a) Coord #  
Instance details

Defined in Model

Methods

with :: Player a -> Coord -> Player a #

With (Playable a) (T Core) #  
Instance details

Defined in Game

Methods

with :: Playable a -> T Core -> Playable a #

(With (Playable a) (T Core), With (Playable a) a) => With (Playable a) (T Core, a) #  
Instance details

Defined in Game

Methods

with :: Playable a -> (T Core, a) -> Playable a #

With (Kernel a) (Model, T Core, T UI) #  
Instance details

Defined in Move

Methods

with :: Kernel a -> (Model, T Core, T UI) -> Kernel a #

With (Kernel a) (Model, T Core, T UI, Animation) #  
Instance details

Defined in Move

Methods

with :: Kernel a -> (Model, T Core, T UI, Animation) -> Kernel a #

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.