1{-# LANGUAGE TypeFamilies #-}
2-- | The interface for types which represent changes made to other types
3module Reflex.Patch.Class where
5import Control.Monad.Identity
8-- | A 'Patch' type represents a kind of change made to a datastructure.
10 type PatchTarget p :: *
11 -- | Apply the patch @p a@ to the value @a@. If no change is needed, return
13 apply :: p -> PatchTarget p -> Maybe (PatchTarget p)
15-- | Apply a 'Patch'; if it does nothing, return the original value
16applyAlways :: Patch p => p -> PatchTarget p -> PatchTarget p
17applyAlways p t = fromMaybe t $ apply p t
19-- | 'Identity' can be used as a 'Patch' that always fully replaces the value
20instance Patch (Identity a) where
21 type PatchTarget (Identity a) = a
22 apply (Identity a) _ = Just a
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list