data-diverse-4.7.0.0: Extensible records and polymorphic variants.

Safe HaskellSafe
LanguageHaskell2010

Data.Diverse.Reduce

Synopsis

Documentation

type family Reduced handler Source #

Convert something v into r using handlers. This class is required in order to step through all the different types in a variant.

Instances
type Reduced (Switcher c r xs) Source # 
Instance details

Defined in Data.Diverse.Which.Internal

type Reduced (Switcher c r xs) = r
type Reduced (SwitcherN c r n xs) Source # 
Instance details

Defined in Data.Diverse.Which.Internal

type Reduced (SwitcherN c r n xs) = r

class Reduce v handler where Source #

Methods

reduce :: handler -> v -> Reduced handler Source #

Instances
Reduce Void (Switcher c r ([] :: [Type])) Source #

Allow Void to be reinterpret'ed or diversifyed into anything else This is safe because Void is uninhabited, and this is already something that can be done with impossible

Instance details

Defined in Data.Diverse.Which.Internal

Methods

reduce :: Switcher c r [] -> Void -> Reduced (Switcher c r []) Source #

(Case (c r) (x ': ([] :: [Type])), r ~ CaseResult (c r) x) => Reduce (Which (x ': ([] :: [Type]))) (Switcher c r (x ': ([] :: [Type]))) Source #

Terminating case of the loop, ensuring that a instance of Case '[] with an empty typelist is not required.

Instance details

Defined in Data.Diverse.Which.Internal

Methods

reduce :: Switcher c r (x ': []) -> Which (x ': []) -> Reduced (Switcher c r (x ': [])) Source #

(Case (c r) (x ': (x' ': xs)), Reduce (Which (x' ': xs)) (Switcher c r (x' ': xs)), Reiterate (c r) (x ': (x' ': xs)), r ~ CaseResult (c r) x) => Reduce (Which (x ': (x' ': xs))) (Switcher c r (x ': (x' ': xs))) Source #

trial0 each type in a Which, and either handle the case' with value discovered, or reiterate trying the next type in the type list.

Instance details

Defined in Data.Diverse.Which.Internal

Methods

reduce :: Switcher c r (x ': (x' ': xs)) -> Which (x ': (x' ': xs)) -> Reduced (Switcher c r (x ': (x' ': xs))) Source #

Reduce (Which (Void ': ([] :: [Type]))) (Switcher c r ([] :: [Type])) Source #

Allow 'Which '[Void]' to be reinterpret'ed or diversifyed into anything else This is safe because Which '[Void] is uninhabited, and this is already something that can be done with impossible

Instance details

Defined in Data.Diverse.Which.Internal

Methods

reduce :: Switcher c r [] -> Which (Void ': []) -> Reduced (Switcher c r []) Source #

Reduce (Which ([] :: [Type])) (Switcher c r ([] :: [Type])) Source #

Allow 'Which '[]' to be reinterpret'ed or diversifyed into anything else This is safe because Which '[] is uninhabited, and this is already something that can be done with impossible

Instance details

Defined in Data.Diverse.Which.Internal

Methods

reduce :: Switcher c r [] -> Which [] -> Reduced (Switcher c r []) Source #

(Case (c r n) (x ': ([] :: [Type])), r ~ CaseResult (c r n) x) => Reduce (Which (x ': ([] :: [Type]))) (SwitcherN c r n (x ': ([] :: [Type]))) Source #

Terminating case of the loop, ensuring that a instance of Case '[] with an empty typelist is not required. You can't reduce zilch

Instance details

Defined in Data.Diverse.Which.Internal

Methods

reduce :: SwitcherN c r n (x ': []) -> Which (x ': []) -> Reduced (SwitcherN c r n (x ': [])) Source #

(Case (c r n) (x ': (x' ': xs)), Reduce (Which (x' ': xs)) (SwitcherN c r (n + 1) (x' ': xs)), ReiterateN (c r) n (x ': (x' ': xs)), r ~ CaseResult (c r n) x) => Reduce (Which (x ': (x' ': xs))) (SwitcherN c r n (x ': (x' ': xs))) Source #

trial0 each type in a Which, and either handle the case' with value discovered, or reiterateN trying the next type in the type list.

Instance details

Defined in Data.Diverse.Which.Internal

Methods

reduce :: SwitcherN c r n (x ': (x' ': xs)) -> Which (x ': (x' ': xs)) -> Reduced (SwitcherN c r n (x ': (x' ': xs))) Source #