packages feed

reflection 1.1.7 → 1.2.0.1

raw patch · 3 files changed

+43/−2 lines, 3 filesdep ~tagged

Dependency ranges changed: tagged

Files

CHANGELOG.markdown view
@@ -1,3 +1,6 @@+# 1.2+* Added `Given` and give.+ # 1.1.7 * Fixed an issue caused by changes in GHC 7.7's typechecker by using explicit `ScopedTypeVariables`. 
fast/Data/Reflection.hs view
@@ -34,11 +34,18 @@ -- Proxy@, so all of the information needed to reconstruct your value -- has been moved to the type level.  This enables it to be used when -- constructing instances (see @examples/Monoid.hs@).+--+-- In addition, a simpler API is offered for working with singleton+-- values such as a system configuration, etc. ------------------------------------------------------------------------------- module Data.Reflection     (+    -- * Reflection       Reifies(..)     , reify+    -- * Given+    , Given(..)+    , give     ) where  import Data.Proxy@@ -49,6 +56,10 @@ import Unsafe.Coerce #endif +------------------------------------------------------------------------------+-- Reifies+------------------------------------------------------------------------------+ class Reifies s a | s -> a where   -- | Recover a value inside a 'reify' context, given a proxy for its   -- reified type.@@ -59,3 +70,26 @@ -- | Reify a value at the type level, to be recovered with 'reflect'. reify :: forall a r. a -> (forall s. Reifies s a => Proxy s -> r) -> r reify a k = unsafeCoerce (Magic k :: Magic a r) (const a) Proxy+{-# INLINE reify #-}++------------------------------------------------------------------------------+-- Given+------------------------------------------------------------------------------++-- | This is a version of 'Reifies' that allows for only a single value.+--+-- This is easier to work with than 'Reifies' and permits extended defaulting,+-- but it only offers a single reflected value of a given type at a time.+class Given a where+  -- | Recover the value of a given type previously encoded with 'give'.+  given :: a++newtype Gift a r = Gift (Given a => r)++-- | Reify a value into an instance to be recovered with 'given'.+--+-- You should only 'give' a single value for each type. If multiple instances+-- are in scope, then the behavior is implementation defined.+give :: forall a r. a -> (Given a => r) -> r+give a k = unsafeCoerce (Gift k :: Gift a r) a+{-# INLINE give #-}
reflection.cabal view
@@ -1,5 +1,5 @@ name:           reflection-version:        1.1.7+version:        1.2.0.1 license:        BSD3 license-file:   LICENSE author:         Edward A. Kmett, Elliott Hird, Oleg Kiselyov and Chung-chieh Shan@@ -32,6 +32,10 @@   fast/Data/Reflection.hs   .travis.yml +-- If you enable this flag, we use a more portable much much slower implementation.+-- Moreover, the 'Given' API is broken, so this is currently an unsupported configuration.+--+-- If you feel the need to turn on this flag for any reason, please email the maintainer! flag slow   default: False   manual: False@@ -48,7 +52,7 @@    build-depends:     base >= 2 && < 5,-    tagged >= 0.4.4 && < 0.5+    tagged >= 0.4.4 && < 1    default-language: Haskell98