packages feed

reflection 1.1.6 → 1.1.7

raw patch · 8 files changed

+85/−54 lines, 8 filesdep ~tagged

Dependency ranges changed: tagged

Files

+ CHANGELOG.markdown view
@@ -0,0 +1,30 @@+# 1.1.7+* Fixed an issue caused by changes in GHC 7.7's typechecker by using explicit `ScopedTypeVariables`.++# 1.1.6:+* Relaxed an unnecessary strictness annotation in the fast implementation++# 1.1.5+* Both implementations now work on Hugs; the fast implementation ascends+  from the ranks of completely unportable black magic to being merely+  /mostly/ unportable black magic.++# From 0.5 to 1.1:++* Much faster implementation available that is about 50 /times/ faster than+  0.9 and which runs purely on black magic. This version is now used by+  default. To turn it off install with the `slow` flag. If you encounter a+  problem with the implementation, please contact the author.+* Removed `ReifiedNum`, `reflectNum`, and `reifyIntegral`; `reify` and+  `reflect` are about 3 orders of magnitude faster than the special case+  combinators were.++# 0.5+* Generalized the type signatures in reflect to allow you to pass any type+  with kind `* -> *` wrapped around the desired type as the phantom type+  argument rather than just a `Proxy`.++# 0.4+* Converted from `Data.Tagged` to using `Data.Proxy` for reflection. This+  reduces the need for helper functions and scoped type variables in user+  code.
LICENSE view
@@ -1,4 +1,4 @@-Copyright (c) 2009 Edward Kmett+Copyright (c) 2009-2013 Edward Kmett Copyright (c) 2004 Oleg Kiselyov and Chung-chieh Shan All rights reserved. 
− README
@@ -1,10 +0,0 @@-reflection-==========--This package provides an implementation of the ideas presented in the paper--  Oleg Kiselyov and Chung-Chieh Shan, "Functional Pearl: Implicit Configurations"-  <http://www.cs.rutgers.edu/~ccshan/prepose/prepose.pdf>--However, the API has been modified to use Rank2Types and TypeFamilies and the-implementation has been streamlined to improve performance.
+ README.markdown view
@@ -0,0 +1,15 @@+reflection+==========++[![Build Status](https://secure.travis-ci.org/ekmett/reflection.png?branch=master)](http://travis-ci.org/ekmett/reflecton)++This package provides an implementation of the ideas presented in [Functional Pearl: Implicit Configurations](http://www.cs.rutgers.edu/~ccshan/prepose/prepose.pdf) by Oleg Kiselyov and Chung-Chieh Shan. However, the API has been implemented in a much more efficient manner.++Contact Information+-------------------++Contributions and bug reports are welcome!++Please feel free to contact me through github or on the #haskell IRC channel on irc.freenode.net.++-Edward Kmett
examples/Constraints.hs view
@@ -44,9 +44,34 @@   mappend a b        = Lift $ mappend_ (reflect a) (lower a) (lower b)   mempty = a where a = Lift $ mempty_ (reflect a) +data ClassProxy (p :: * -> Constraint) = ClassProxy++given :: ClassProxy c -> p s -> a -> Lift c a s+given _ _ = Lift++eq :: ClassProxy Eq+eq = ClassProxy++ord :: ClassProxy Ord+ord = ClassProxy++monoid :: ClassProxy Monoid+monoid = ClassProxy+ instance ReifiableConstraint Eq where   data Def Eq a = Eq { eq_ :: a -> a -> Bool }   reifiedIns = Sub Dict  instance Reifies s (Def Eq a) => Eq (Lift Eq a s) where   a == b = eq_ (reflect a) (lower a) (lower b)++instance ReifiableConstraint Ord where+  data Def Ord a = Ord { compare_ :: a -> a -> Ordering }+  reifiedIns = Sub Dict++instance Reifies s (Def Ord a) => Eq (Lift Ord a s) where+  a == b = compare a b == EQ++instance Reifies s (Def Ord a) => Ord (Lift Ord a s) where+  compare a b = compare_ (reflect a) (lower a) (lower b)+
examples/Monoid.hs view
@@ -1,18 +1,20 @@-{-# LANGUAGE Rank2Types, TypeFamilies, FlexibleContexts, UndecidableInstances #-}+{-# LANGUAGE Rank2Types, FlexibleContexts, UndecidableInstances #-} import Data.Reflection -- from reflection import Data.Monoid     -- from base import Data.Proxy      -- from tagged --- | Values in our dynamically constructed monoid over 'a'+-- | Values in our dynamically-constructed 'Monoid' over 'a' newtype M a s = M { runM :: a } deriving (Eq,Ord) --- | A dictionary describing the contents of a monoid+-- | A dictionary describing a 'Monoid' data Monoid_ a = Monoid_ { mappend_ :: a -> a -> a, mempty_ :: a }  instance Reifies s (Monoid_ a) => Monoid (M a s) where   mappend a b        = M $ mappend_ (reflect a) (runM a) (runM b)   mempty = a where a = M $ mempty_ (reflect a) +-- Construct a 'Monoid' instance out of a binary operation and unit that you have in scope!+-- -- > ghci> withMonoid (+) 0 $ mempty <> M 2 -- > 2 withMonoid :: (a -> a -> a) -> a -> (forall s. Reifies s (Monoid_ a) => M a s) -> a
fast/Data/Reflection.hs view
@@ -1,11 +1,12 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE FunctionalDependencies #-}+{-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE Rank2Types #-} ---------------------------------------------------------------------------- -- | -- Module     : Data.Reflection--- Copyright  : 2009-2012 Edward Kmett,+-- Copyright  : 2009-2013 Edward Kmett, --              2012 Elliott Hird, --              2004 Oleg Kiselyov and Chung-chieh Shan -- License    : BSD3@@ -56,5 +57,5 @@ newtype Magic a r = Magic (forall s. Reifies s a => Proxy s -> r)  -- | Reify a value at the type level, to be recovered with 'reflect'.-reify :: a -> (forall s. Reifies s a => Proxy s -> r) -> r-reify a k = unsafeCoerce (Magic k) (const a) Proxy+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
reflection.cabal view
@@ -1,5 +1,5 @@ name:           reflection-version:        1.1.6+version:        1.1.7 license:        BSD3 license-file:   LICENSE author:         Edward A. Kmett, Elliott Hird, Oleg Kiselyov and Chung-chieh Shan@@ -9,7 +9,7 @@ bug-reports:    http://github.com/ekmett/reflection/issues category:       Data, Reflection, Dependent Types synopsis:       Reifies arbitrary terms into types that can be reflected back into terms-copyright:      2009-2012 Edward A. Kmett,+copyright:      2009-2013 Edward A. Kmett,                 2012 Elliott Hird,                 2004 Oleg Kiselyov and Chung-chieh Shan build-type:     Simple@@ -21,45 +21,13 @@   .   The original paper can be obtained from   <http://www.cs.rutgers.edu/~ccshan/prepose/prepose.pdf>.-  .-  /Changes in 1.1.6/:-  .-  * Relaxed an unnecessary strictness annotation in the fast implementation-  .-  /Changes in 1.1.5/:-  .-  * Both implementations now work on Hugs; the fast implementation ascends-    from the ranks of completely unportable black magic to being merely-    /mostly/ unportable black magic.-  .-  /Changes from 0.5 to 1.1/:-  .-  * Much faster implementation available that is about 50 /times/ faster than-    0.9 and which runs purely on black magic. This version is now used by-    default. To turn it off install with the @slow@ flag. If you encounter a-    problem with the implementation, please contact the author.-  .-  * Removed @ReifiedNum@, @reflectNum@, and @reifyIntegral@; @reify@ and-    @reflect@ are about 3 orders of magnitude faster than the special case-    combinators were.-  .-  /Changes in 0.5/:-  .-  * Generalized the type signatures in reflect to allow you to pass any type-    with kind @* -> *@ wrapped around the desired type as the phantom type-    argument rather than just a @Proxy@.-  .-  /Changes in 0.4/:-  .-  * Converted from `Data.Tagged` to using `Data.Proxy` for reflection. This-    reduces the need for helper functions and scoped type variables in user-    code.  extra-source-files:   examples/Monoid.hs   examples/Constraints.hs   examples/Benchmark.hs-  README+  CHANGELOG.markdown+  README.markdown   slow/Data/Reflection.hs   fast/Data/Reflection.hs   .travis.yml@@ -80,7 +48,7 @@    build-depends:     base >= 2 && < 5,-    tagged >= 0.2.3 && < 0.5+    tagged >= 0.4.4 && < 0.5    default-language: Haskell98