darcs-2.12.5: a distributed, interactive, smart revision control system

Safe Haskell | None
Language | Haskell2010

Darcs.Patch.Witnesses.Sealed

Synopsis

- data Sealed a where
  - Sealed :: a wX -> Sealed a
- seal :: a wX -> Sealed a
- data Sealed2 a where
  - Sealed2 :: !(a wX wY) -> Sealed2 a
- seal2 :: a wX wY -> Sealed2 a
- data FlippedSeal a wY where
  - FlippedSeal :: !(a wX wY) -> FlippedSeal a wY
- flipSeal :: a wX wY -> FlippedSeal a wY
- unsafeUnseal :: Sealed a -> a wX
- unsafeUnsealFlipped :: FlippedSeal a wY -> a wX wY
- unsafeUnseal2 :: Sealed2 a -> a wX wY
- unseal :: (forall wX. a wX -> b) -> Sealed a -> b
- unsealM :: Monad m => m (Sealed a) -> (forall wX. a wX -> m b) -> m b
- liftSM :: Monad m => (forall wX. a wX -> b) -> m (Sealed a) -> m b
- mapSeal :: (forall wX. a wX -> b wX) -> Sealed a -> Sealed b
- mapFlipped :: (forall wX. a wX wY -> b wX wZ) -> FlippedSeal a wY -> FlippedSeal b wZ
- unseal2 :: (forall wX wY. a wX wY -> b) -> Sealed2 a -> b
- mapSeal2 :: (forall wX wY. a wX wY -> b wX wY) -> Sealed2 a -> Sealed2 b
- unsealFlipped :: (forall wX wY. a wX wY -> b) -> FlippedSeal a wZ -> b
- newtype Poly a = Poly {
  - unPoly :: forall wX. a wX
  }
- newtype Stepped f a wX = Stepped {
  - unStepped :: f (a wX)
  }
- newtype FreeLeft p = FLInternal (Poly (Stepped Sealed p))
- newtype FreeRight p = FRInternal (Poly (FlippedSeal p))
- unFreeLeft :: FreeLeft p -> Sealed (p wX)
- unFreeRight :: FreeRight p -> FlippedSeal p wX
- class Gap w where

# Documentation

data Sealed a where #

A `Sealed` type is a way of hide an existentially quantified type parameter, in this case wX, inside the type. Note that the only thing we can currently recover about the existentially quantified type wX is that it exists.

Constructors

Sealed :: a wX -> Sealed a |

Instances

MyEq a => Eq (Sealed (a wX)) # |
Methods (==) :: Sealed (a wX) -> Sealed (a wX) -> Bool # (/=) :: Sealed (a wX) -> Sealed (a wX) -> Bool #
Show1 a => Show (Sealed a) # |
Methods showsPrec :: Int -> Sealed a -> ShowS # show :: Sealed a -> String # showList :: [Sealed a] -> ShowS #

seal :: a wX -> Sealed a #

data Sealed2 a where #

The same as `Sealed` but for two parameters (wX and wY).

Constructors

Sealed2 :: !(a wX wY) -> Sealed2 a |

Instances

Show2 a => Show (Sealed2 a) # |
Methods showsPrec :: Int -> Sealed2 a -> ShowS # show :: Sealed2 a -> String # showList :: [Sealed2 a] -> ShowS #

seal2 :: a wX wY -> Sealed2 a #

data FlippedSeal a wY where #

Constructors

FlippedSeal :: !(a wX wY) -> FlippedSeal a wY |

flipSeal :: a wX wY -> FlippedSeal a wY #

unsafeUnseal :: Sealed a -> a wX #

unsafeUnsealFlipped :: FlippedSeal a wY -> a wX wY #

unsafeUnseal2 :: Sealed2 a -> a wX wY #

unseal :: (forall wX. a wX -> b) -> Sealed a -> b #

unsealM :: Monad m => m (Sealed a) -> (forall wX. a wX -> m b) -> m b #

liftSM :: Monad m => (forall wX. a wX -> b) -> m (Sealed a) -> m b #

mapSeal :: (forall wX. a wX -> b wX) -> Sealed a -> Sealed b #

mapFlipped :: (forall wX. a wX wY -> b wX wZ) -> FlippedSeal a wY -> FlippedSeal b wZ #

unseal2 :: (forall wX wY. a wX wY -> b) -> Sealed2 a -> b #

mapSeal2 :: (forall wX wY. a wX wY -> b wX wY) -> Sealed2 a -> Sealed2 b #

unsealFlipped :: (forall wX wY. a wX wY -> b) -> FlippedSeal a wZ -> b #

newtype Poly a #

`Poly` is similar to `Sealed`, but the type argument is universally quantified instead of being existentially quantified.

Constructors

Poly |
Fields unPoly :: forall wX. a wX

newtype Stepped f a wX #

`Stepped` is a type level composition operator. For example, ``Stepped` (`Sealed` p)` is equivalent to `\x -> `Sealed` (p x)`

Constructors

Stepped |
Fields unStepped :: f (a wX)

newtype FreeLeft p #

`FreeLeft` p is `forall x . exists y . p x y` In other words the caller is free to specify the left witness, and then the right witness is an existential. Note that the order of the type constructors is important for ensuring that `y` is dependent on the `x` that is supplied. This is why `Stepped` is needed, rather than writing the more obvious `Sealed` (`Poly` p) which would notionally have the same quantification of the type witnesses.

Constructors

FLInternal (Poly (Stepped Sealed p)) |

Instances

Gap FreeLeft # |
Methods emptyGap :: (forall wX. p wX wX) -> FreeLeft p # freeGap :: (forall wX wY. p wX wY) -> FreeLeft p # joinGap :: (forall wX wY wZ. p wX wY -> q wY wZ -> r wX wZ) -> FreeLeft p -> FreeLeft q -> FreeLeft r #

newtype FreeRight p #

`FreeLeft` p is `forall y . exists x . p x y` In other words the caller is free to specify the right witness, and then the left witness is an existential. Note that the order of the type constructors is important for ensuring that `x` is dependent on the `y` that is supplied.

Constructors

FRInternal (Poly (FlippedSeal p)) |

Instances

Gap FreeRight # |
Methods emptyGap :: (forall wX. p wX wX) -> FreeRight p # freeGap :: (forall wX wY. p wX wY) -> FreeRight p # joinGap :: (forall wX wY wZ. p wX wY -> q wY wZ -> r wX wZ) -> FreeRight p -> FreeRight q -> FreeRight r #

unFreeLeft :: FreeLeft p -> Sealed (p wX) #

Unwrap a `FreeLeft` value

unFreeRight :: FreeRight p -> FlippedSeal p wX #

Unwrap a `FreeRight` value

class Gap w where #

`Gap` abstracts over `FreeLeft` and `FreeRight` for code constructing these values

Minimal complete definition

emptyGap, freeGap, joinGap

Methods

emptyGap :: (forall wX. p wX wX) -> w p #

An empty `Gap`, e.g. `NilFL` or `NilRL`

freeGap :: (forall wX wY. p wX wY) -> w p #

A `Gap` constructed from a completely polymorphic value, for example the constructors for primitive patches

joinGap :: (forall wX wY wZ. p wX wY -> q wY wZ -> r wX wZ) -> w p -> w q -> w r #

Compose two `Gap` values together in series, e.g. 'joinGap (+>+)' or 'joinGap (:>:)'

Instances

Gap FreeRight # |
Methods emptyGap :: (forall wX. p wX wX) -> FreeRight p # freeGap :: (forall wX wY. p wX wY) -> FreeRight p # joinGap :: (forall wX wY wZ. p wX wY -> q wY wZ -> r wX wZ) -> FreeRight p -> FreeRight q -> FreeRight r #
Gap FreeLeft # |
Methods emptyGap :: (forall wX. p wX wX) -> FreeLeft p # freeGap :: (forall wX wY. p wX wY) -> FreeLeft p # joinGap :: (forall wX wY wZ. p wX wY -> q wY wZ -> r wX wZ) -> FreeLeft p -> FreeLeft q -> FreeLeft r #