ouroboros-consensus-0.1.0.0: Consensus layer for the Ouroboros blockchain protocol
Safe HaskellNone
LanguageHaskell2010

Ouroboros.Consensus.HardFork.Combinator.Util.Match

Description

Intended for qualified import

import Ouroboros.Consensus.HardFork.Combinator.Util.Match (Mismatch(..))
import qualified Ouroboros.Consensus.HardFork.Combinator.Util.Match as Match
Synopsis

Documentation

data Mismatch :: (k -> Type) -> (k -> Type) -> [k] -> Type where Source #

Constructors

ML :: f x -> NS g xs -> Mismatch f g (x ': xs) 
MR :: NS f xs -> g x -> Mismatch f g (x ': xs) 
MS :: Mismatch f g xs -> Mismatch f g (x ': xs) 

Instances

Instances details
(All (Compose Eq f) xs, All (Compose Eq g) xs) => Eq (Mismatch f g xs) Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.Util.Match

Methods

(==) :: Mismatch f g xs -> Mismatch f g xs -> Bool #

(/=) :: Mismatch f g xs -> Mismatch f g xs -> Bool #

(All (Compose Eq f) xs, All (Compose Ord f) xs, All (Compose Eq g) xs, All (Compose Ord g) xs) => Ord (Mismatch f g xs) Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.Util.Match

Methods

compare :: Mismatch f g xs -> Mismatch f g xs -> Ordering #

(<) :: Mismatch f g xs -> Mismatch f g xs -> Bool #

(<=) :: Mismatch f g xs -> Mismatch f g xs -> Bool #

(>) :: Mismatch f g xs -> Mismatch f g xs -> Bool #

(>=) :: Mismatch f g xs -> Mismatch f g xs -> Bool #

max :: Mismatch f g xs -> Mismatch f g xs -> Mismatch f g xs #

min :: Mismatch f g xs -> Mismatch f g xs -> Mismatch f g xs #

(All (Compose Show f) xs, All (Compose Show g) xs) => Show (Mismatch f g xs) Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.Util.Match

Methods

showsPrec :: Int -> Mismatch f g xs -> ShowS #

show :: Mismatch f g xs -> String #

showList :: [Mismatch f g xs] -> ShowS #

(All (Compose NoThunks f) xs, All (Compose NoThunks g) xs) => NoThunks (Mismatch f g xs) Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.Util.Match

matchNS :: NS f xs -> NS g xs -> Either (Mismatch f g xs) (NS (Product f g) xs) Source #

matchTelescope :: NS h xs -> Telescope g f xs -> Either (Mismatch h f xs) (Telescope g (Product h f) xs) Source #

flip :: Mismatch f g xs -> Mismatch g f xs Source #

Utilities

mismatchToNS :: Mismatch f g xs -> (NS f xs, NS g xs) Source #

Project two NS from a Mismatch

We should have the property that

uncurry matchNS (mismatchToNS m) == Left m

mismatchOne :: Mismatch f g '[x] -> Void Source #

We cannot give a mismatch if we have only one type variable

mismatchTwo :: Mismatch f g '[x, y] -> Either (f x, g y) (f y, g x) Source #

If we only have two eras, only two possibilities for a mismatch

mkMismatchTwo :: Either (f x, g y) (f y, g x) -> Mismatch f g '[x, y] Source #

mismatchNotEmpty :: Mismatch f g xs -> (forall x xs'. xs ~ (x ': xs') => Mismatch f g (x ': xs') -> a) -> a Source #

mismatchNotFirst :: Mismatch f g (x ': xs) -> Either (NS f xs) (NS g xs) Source #

mustMatchNS :: forall f g xs. HasCallStack => String -> NS f xs -> NS g xs -> NS (Product f g) xs Source #

Variant of matchNS for when we know the two NSs must match. Otherwise an error, mentioning the given String, is thrown.

SOP operators

bihap :: NP (f -.-> f') xs -> NP (g -.-> g') xs -> Mismatch f g xs -> Mismatch f' g' xs Source #

bihmap :: SListI xs => (forall x. f x -> f' x) -> (forall x. g x -> g' x) -> Mismatch f g xs -> Mismatch f' g' xs Source #

bihcmap :: All c xs => proxy c -> (forall x. c x => f x -> f' x) -> (forall x. c x => g x -> g' x) -> Mismatch f g xs -> Mismatch f' g' xs Source #

Bifunctor analogue of hcmap