Safe Haskell | None |
---|---|
Language | Haskell2010 |
Variant biased towards one type
This allows definition of common type classes (Functor, etc.) that can't be provided for Variant
Synopsis
- data VEither es a
- pattern VLeft :: forall x xs. V xs -> VEither xs x
- pattern VRight :: forall x xs. x -> VEither xs x
- veitherFromVariant :: V (a ': es) -> VEither es a
- veitherToVariant :: VEither es a -> V (a ': es)
- veitherToValue :: forall a. VEither '[] a -> a
- veitherBimap :: (V es -> V fs) -> (a -> b) -> VEither es a -> VEither fs b
- type VEitherLift es es' = LiftVariant es es'
- veitherLift :: forall es' es a. VEitherLift es es' => VEither es a -> VEither es' a
- veitherAppend :: forall ns es a. VEither es a -> VEither (Concat es ns) a
- veitherPrepend :: forall ns es a. KnownNat (Length ns) => VEither es a -> VEither (Concat ns es) a
- veitherCont :: (V es -> u) -> (a -> u) -> VEither es a -> u
- veitherToEither :: VEither es a -> Either (V es) a
- veitherProduct :: KnownNat (Length (b ': e2)) => VEither e1 a -> VEither e2 b -> VEither (Tail (Product (a ': e1) (b ': e2))) (a, b)
- module Haskus.Utils.Variant
Documentation
Variant biased towards one type
Instances
Monad (VEither es) Source # | Monad instance for VEither
|
Functor (VEither es) Source # | Functor instance for VEither
|
Applicative (VEither es) Source # | Applicative instance for VEither
|
Defined in Haskus.Utils.Variant.VEither | |
Foldable (VEither es) Source # | Foldable instance for VEither
|
Defined in Haskus.Utils.Variant.VEither fold :: Monoid m => VEither es m -> m # foldMap :: Monoid m => (a -> m) -> VEither es a -> m # foldr :: (a -> b -> b) -> b -> VEither es a -> b # foldr' :: (a -> b -> b) -> b -> VEither es a -> b # foldl :: (b -> a -> b) -> b -> VEither es a -> b # foldl' :: (b -> a -> b) -> b -> VEither es a -> b # foldr1 :: (a -> a -> a) -> VEither es a -> a # foldl1 :: (a -> a -> a) -> VEither es a -> a # toList :: VEither es a -> [a] # null :: VEither es a -> Bool # length :: VEither es a -> Int # elem :: Eq a => a -> VEither es a -> Bool # maximum :: Ord a => VEither es a -> a # minimum :: Ord a => VEither es a -> a # | |
Traversable (VEither es) Source # | |
Defined in Haskus.Utils.Variant.VEither | |
(Show a, Show (V es)) => Show (VEither es a) Source # | |
pattern VLeft :: forall x xs. V xs -> VEither xs x Source #
Left value
>>>
VLeft (V "failed" :: V '[String,Int]) :: VEither '[String,Int] Bool
VLeft "failed"
pattern VRight :: forall x xs. x -> VEither xs x Source #
Right value
>>>
VRight True :: VEither '[String,Int] Bool
VRight True
veitherFromVariant :: V (a ': es) -> VEither es a Source #
Convert a Variant into a VEither
>>>
let x = V "Test" :: V '[Int,String,Double]
>>>
veitherFromVariant x
VLeft "Test"
veitherToVariant :: VEither es a -> V (a ': es) Source #
Convert a VEither into a Variant
>>>
let x = VRight True :: VEither '[Int,Float] Bool
>>>
veitherToVariant x
True
veitherToValue :: forall a. VEither '[] a -> a Source #
Extract from a VEither without left types
>>>
let x = VRight True :: VEither '[] Bool
>>>
veitherToValue x
True
veitherBimap :: (V es -> V fs) -> (a -> b) -> VEither es a -> VEither fs b Source #
Bimap for VEither
>>>
let x = VRight True :: VEither '[Int,Float] Bool
>>>
veitherBimap id not x
VRight False
type VEitherLift es es' = LiftVariant es es' Source #
veitherLift :: forall es' es a. VEitherLift es es' => VEither es a -> VEither es' a Source #
Lift a VEither into another
veitherAppend :: forall ns es a. VEither es a -> VEither (Concat es ns) a Source #
Append errors to VEither
veitherPrepend :: forall ns es a. KnownNat (Length ns) => VEither es a -> VEither (Concat ns es) a Source #
Prepend errors to VEither
veitherCont :: (V es -> u) -> (a -> u) -> VEither es a -> u Source #
VEither continuations
veitherToEither :: VEither es a -> Either (V es) a Source #
Convert a VEither into an Either
>>>
let x = VRight True :: VEither '[Int,Float] Bool
>>>
veitherToEither x
Right True
veitherProduct :: KnownNat (Length (b ': e2)) => VEither e1 a -> VEither e2 b -> VEither (Tail (Product (a ': e1) (b ': e2))) (a, b) Source #
Product of two VEither
module Haskus.Utils.Variant