lens-4.12.3: Lenses, Folds and Traversals

Copyright(C) 2015 Edward Kmett and Eric Mertens
LicenseBSD-style (see the file LICENSE)
MaintainerEdward Kmett <ekmett@gmail.com>
Stabilityexperimental
Portabilitynon-portable
Safe HaskellTrustworthy
LanguageHaskell98

Control.Lens.Internal.Coerce

Description

This module provides a shim around coerce that defaults to unsafeCoerce on GHC < 7.8

Synopsis

Documentation

coerce :: Coercible * a b => a -> b

The function coerce allows you to safely convert between values of types that have the same representation with no run-time overhead. In the simplest case you can use it instead of a newtype constructor, to go from the newtype's concrete type to the abstract type. But it also works in more complicated settings, e.g. converting a list of newtypes to a list of concrete types.

coerce' :: forall a b. Coercible a b => b -> a Source