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

Safe HaskellSafe
LanguageHaskell2010

Data.Diverse.CaseTypeable

Synopsis

Documentation

newtype CaseTypeable r xs Source #

This handler stores a polymorphic function for all Typeables. This is an example of how to define and instance of Case for polymorphic function into a specified result type.

let y = pick (5 :: Int) :: Which '[Int, Bool]
switch y (CaseTypeable (show . typeRep . (pure @Proxy))) `shouldBe` Int
let x = (5 :: Int) ./ False ./ 'X' ./ Just 'O' ./ (6 :: Int) ./ Just 'A' ./ nul
afoldr (:) [] (forMany (CaseTypeable (show . typeRep . (pure @Proxy))) x) `shouldBe`
    ["Int", "Bool", "Char", "Maybe Char", "Int", "Maybe Char"]

Constructors

CaseTypeable (forall x. Typeable x => x -> r) 

Instances

Reiterate (CaseTypeable r) xs Source # 
Typeable Type x => Case (CaseTypeable r) ((:) Type x xs) Source # 

Methods

case' :: CaseTypeable r ((Type ': x) xs) -> Head Type ((Type ': x) xs) -> CaseResult * Type (CaseTypeable r) (Head Type ((Type ': x) xs)) Source #

type CaseResult * Type (CaseTypeable r) x Source # 
type CaseResult * Type (CaseTypeable r) x = r

newtype CaseTypeable' xs Source #

This handler stores a polymorphic function for all Typeables. This is an example of how to define and instance of Case for polymorphic function that doesn't change the type

Constructors

CaseTypeable' (forall x. Typeable x => x -> x)