Data.Type.Coercion
| License | BSD-style (see the LICENSE file in the distribution) |
|---|---|
| Maintainer | libraries@haskell.org |
| Stability | experimental |
| Portability | not portable |
| Safe Haskell | None |
| Language | Haskell2010 |
data Coercion a b where Source
Представительское равенство. Если Coercion a b населен некоторым завершающим значением, то тип a имеет то же базовое представление, что и тип b.
Чтобы использовать это равенство на практике, выполните сопоставление с образцом по Coercion a b для получения экземпляра Coercible a b, а затем используйте coerce для его применения.
Since: base-4.7.0.0
Экземпляры
| Category (Coercion :: k -> k -> Type) | Since: base-4.7.0.0 |
| TestCoercion (Coercion a :: k -> Type) | Since: base-4.7.0.0 |
Определено в Data.Type.Coercion | |
| Coercible a b => Bounded (Coercion a b) | Since: base-4.7.0.0 |
| Coercible a b => Enum (Coercion a b) | Since: base-4.7.0.0 |
Определено в Data.Type.Coercion Методыsucc :: Coercion a b -> Coercion a b Source pred :: Coercion a b -> Coercion a b Source toEnum :: Int -> Coercion a b Source fromEnum :: Coercion a b -> Int Source enumFrom :: Coercion a b -> [Coercion a b] Source enumFromThen :: Coercion a b -> Coercion a b -> [Coercion a b] Source enumFromTo :: Coercion a b -> Coercion a b -> [Coercion a b] Source enumFromThenTo :: Coercion a b -> Coercion a b -> Coercion a b -> [Coercion a b] Source | |
| Eq (Coercion a b) | Since: base-4.7.0.0 |
| (Coercible a b, Data a, Data b) => Data (Coercion a b) | Since: base-4.7.0.0 |
Определено в Data.Data Методыgfoldl :: (forall d b0. Data d => c (d -> b0) -> d -> c b0) -> (forall g. g -> c g) -> Coercion a b -> c (Coercion a b) Исходный код gunfold :: (forall b0 r. Data b0 => c (b0 -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Coercion a b) Исходный код toConstr :: Coercion a b -> Constr Исходный код dataTypeOf :: Coercion a b -> DataType Исходный код dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Coercion a b)) Исходный код dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Coercion a b)) Исходный код gmapT :: (forall b0. Data b0 => b0 -> b0) -> Coercion a b -> Coercion a b Исходный код gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Coercion a b -> r Исходный код gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Coercion a b -> r Исходный код gmapQ :: (forall d. Data d => d -> u) -> Coercion a b -> [u] Исходный код gmapQi :: Int -> (forall d. Data d => d -> u) -> Coercion a b -> u Исходный код gmapM :: Monad m => (forall d. Data d => d -> m d) -> Coercion a b -> m (Coercion a b) Исходный код gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Coercion a b -> m (Coercion a b) Исходный код gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Coercion a b -> m (Coercion a b) Исходный код | |
| Ord (Coercion a b) | С момента: base-4.7.0.0 |
Определено в Data.Type.Coercion Методыcompare :: Coercion a b -> Coercion a b -> Ordering Исходный код (<) :: Coercion a b -> Coercion a b -> Bool Исходный код (<=) :: Coercion a b -> Coercion a b -> Bool Исходный код (>) :: Coercion a b -> Coercion a b -> Bool Исходный код (>=) :: Coercion a b -> Coercion a b -> Bool Исходный код max :: Coercion a b -> Coercion a b -> Coercion a b Исходный код min :: Coercion a b -> Coercion a b -> Coercion a b Исходный код | |
| Coercible a b => Read (Coercion a b) | С момента: base-4.7.0.0 |
coerceWith :: Coercion a b -> a -> b Источник
Безопасный приведение типов, используя репрезентативное равенство
gcoerceWith :: Coercion a b -> (Coercible a b => r) -> r Источник
Обобщённая форма безопасного приведения типов, используя репрезентативное равенство
С момента: base-4.10.0.0
sym :: Coercion a b -> Coercion b a Источник
Симметрия репрезентативного равенства
trans :: Coercion a b -> Coercion b c -> Coercion a c Источник
Транзитивность репрезентативного равенства
repr :: (a :~: b) -> Coercion a b Источник
Преобразование пропозиционального (номинального) равенства в репрезентативное равенство
class TestCoercion f where Источник
Этот класс содержит типы, где вы можете узнать равенство двух типов из информации, содержащейся в терминах. Как правило, только типы-сингултоны должны принадлежать к этому классу.
Методы
testCoercion :: f a -> f b -> Maybe (Coercion a b) Источник
Условно доказать репрезентативное равенство a и b.
Экземпляры
| TestCoercion (Coercion a :: k -> Тип) | С момента: base-4.7.0.0 |
Определено в Data.Type.Coercion | |
| TestCoercion ((:~:) a :: k -> Тип) | С момента: base-4.7.0.0 |
Определено в Data.Type.Coercion | |
| TestCoercion ((:~~:) a :: k -> Тип) | С момента: base-4.10.0.0 |
Определено в Data.Type.Coercion | |
© The University of Glasgow and others
Licensed under a BSD-style license (see top of the page).
https://downloads.haskell.org/~ghc/8.10.2/docs/html/libraries/base-4.14.1.0/Data-Type-Coercion.html