row-types-1.0.1.2: Open Records and Variants
Safe HaskellNone
LanguageHaskell2010

Data.Row.Switch

Description

This module provides the ability to discharge a polymorphic variant using a record that has matching fields.

Synopsis

Documentation

class AppliesTo r f x | r x -> f, f r -> x where Source #

A simple class that we use to provide a constraint for function application.

Methods

applyTo :: f -> x -> r Source #

Instances

Instances details
AppliesTo r (x -> r) x Source # 
Instance details

Defined in Data.Row.Switch

Methods

applyTo :: (x -> r) -> x -> r Source #

switch :: forall v r x. BiForall r v (AppliesTo x) => Var v -> Rec r -> x Source #

A Var and a Rec can combine if their rows line up properly. Given a Variant along with a Record of functions from each possible value of the variant to a single output type, apply the correct function to the value in the variant.

caseon :: forall v r x. BiForall r v (AppliesTo x) => Rec r -> Var v -> x Source #

The same as switch but with the argument order reversed