sop-extras-0.2.0.0: Type-level and data utilities that build upon SOP.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.SOP.Match

Description

Intended for qualified import

import           Data.SOP.Match (Mismatch(..))
import qualified Data.SOP.Match as Match
Synopsis

Documentation

data Mismatch f g xs where Source #

We have a mismatch in the index between two NS

Constructors

ML ∷ f x → NS g xs → Mismatch f g (x ': xs)

The left is at the current x and the right is somewhere in the later xs

MRNS f xs → g x → Mismatch f g (x ': xs)

The right is at the current x and the left is somewhere in the later xs

MSMismatch f g xs → Mismatch f g (x ': xs)

There is a mismatch later on in the xs

Instances

Instances details
(∀ (x ∷ k2) (y ∷ k2). LiftedCoercible p p x y) ⇒ HTrans (Mismatch p ∷ (k2 → Type) → [k2] → Type) (Mismatch p ∷ (k2 → Type) → [k2] → Type) Source # 
Instance details

Defined in Data.SOP.Match

Methods

htrans ∷ ∀ c (xs ∷ l1) (ys ∷ l2) proxy f g. AllZipN (Prod (Mismatch p)) c xs ys ⇒ proxy c → (∀ (x ∷ k1) (y ∷ k20). c x y ⇒ f x → g y) → Mismatch p f xs → Mismatch p g ys Source #

hcoerce ∷ ∀ (f ∷ k1 → Type) (g ∷ k20 → Type) (xs ∷ l1) (ys ∷ l2). AllZipN (Prod (Mismatch p)) (LiftedCoercible f g) xs ys ⇒ Mismatch p f xs → Mismatch p g ys Source #

HAp (Mismatch f ∷ (k → Type) → [k] → Type) Source # 
Instance details

Defined in Data.SOP.Match

Methods

hap ∷ ∀ (f0 ∷ k0 → Type) (g ∷ k0 → Type) (xs ∷ l). Prod (Mismatch f) (f0 -.-> g) xs → Mismatch f f0 xs → Mismatch f g xs Source #

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

Defined in Data.SOP.Match

Methods

showsPrecIntMismatch f g xs → ShowS #

showMismatch f g xs → String #

showList ∷ [Mismatch f g xs] → ShowS #

(All (Compose Eq f) xs, All (Compose Eq g) xs) ⇒ Eq (Mismatch f g xs) Source # 
Instance details

Defined in Data.SOP.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 Data.SOP.Match

Methods

compareMismatch 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 #

maxMismatch f g xs → Mismatch f g xs → Mismatch f g xs #

minMismatch f g xs → Mismatch f g xs → Mismatch f g xs #

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

Defined in Data.SOP.Match

type Same (Mismatch f ∷ (k2 → Type) → [k2] → Type) Source # 
Instance details

Defined in Data.SOP.Match

type Same (Mismatch f ∷ (k2 → Type) → [k2] → Type) = Mismatch f
type Prod (Mismatch f ∷ (k → Type) → [k] → Type) Source # 
Instance details

Defined in Data.SOP.Match

type Prod (Mismatch f ∷ (k → Type) → [k] → Type) = NP ∷ (k → Type) → [k] → Type
type SListIN (Mismatch f ∷ (k → Type) → [k] → Type) Source # 
Instance details

Defined in Data.SOP.Match

type SListIN (Mismatch f ∷ (k → Type) → [k] → Type) = SListI ∷ [k] → Constraint
type AllN (Mismatch f ∷ (k → Type) → [k] → Type) (c ∷ k → Constraint) Source # 
Instance details

Defined in Data.SOP.Match

type AllN (Mismatch f ∷ (k → Type) → [k] → Type) (c ∷ k → Constraint) = All c

flipMatchMismatch f g xs → Mismatch g f xs Source #

matchNSNS f xs → NS g xs → Either (Mismatch f g xs) (NS (Product f g) xs) Source #

matchTelescopeNS h xs → Telescope g f xs → Either (Mismatch h f xs) (Telescope g (Product h f) xs) Source #

Utilities

mismatchNotEmptyMismatch f g xs → (∀ x xs'. xs ~ (x ': xs') ⇒ Mismatch f g (x ': xs') → a) → a Source #

mismatchNotFirstMismatch f g (x ': xs) → Either (NS f xs) (NS g xs) Source #

mismatchOneMismatch f g '[x] → Void Source #

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

mismatchToNSMismatch 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

mismatchTwoMismatch 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

mkMismatchTwoEither (f x, g y) (f y, g x) → Mismatch f g '[x, y] Source #

mustMatchNS ∷ ∀ f g xs. HasCallStackStringNS 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

bihapNP (f -.-> f') xs → NP (g -.-> g') xs → Mismatch f g xs → Mismatch f' g' xs Source #

bihcmapAll c xs ⇒ proxy c → (∀ x. c x ⇒ f x → f' x) → (∀ x. c x ⇒ g x → g' x) → Mismatch f g xs → Mismatch f' g' xs Source #

Bifunctor analogue of hcmap

bihmapSListI xs ⇒ (∀ x. f x → f' x) → (∀ x. g x → g' x) → Mismatch f g xs → Mismatch f' g' xs Source #