reflection 1.5.1 → 1.5.1.1
raw patch · 6 files changed
+114/−12 lines, 6 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Data.Reflection: instance Reifies * Z Int
- Data.Reflection: instance Reifies * n Int => Reifies * (D n) Int
- Data.Reflection: instance Reifies * n Int => Reifies * (PD n) Int
- Data.Reflection: instance Reifies * n Int => Reifies * (SD n) Int
+ Data.Reflection: instance KnownNat n => Reifies n Integer
+ Data.Reflection: instance KnownSymbol n => Reifies n String
+ Data.Reflection: instance Reifies Z Int
+ Data.Reflection: instance Reifies n Int => Reifies (D n) Int
+ Data.Reflection: instance Reifies n Int => Reifies (PD n) Int
+ Data.Reflection: instance Reifies n Int => Reifies (SD n) Int
Files
- .travis.yml +55/−0
- CHANGELOG.markdown +4/−0
- README.markdown +1/−1
- fast/Data/Reflection.hs +1/−1
- reflection.cabal +52/−9
- slow/Data/Reflection.hs +1/−1
.travis.yml view
@@ -1,1 +1,56 @@ language: haskell++env:+ - GHCVER=7.4.2+ - GHCVER=7.6.3+ - GHCVER=7.8.3+ - GHCVER=head++matrix:+ allow_failures:+ - env: GHCVER=head++before_install:+ # If $GHCVER is the one travis has, don't bother reinstalling it.+ # We can also have faster builds by installing some libraries with+ # `apt`. If it isn't, install the GHC we want from hvr's PPA along+ # with cabal-1.18.+ - |+ if [ $GHCVER = `ghc --numeric-version` ]; then+ # Try installing some of the build-deps with apt-get for speed.+ travis/cabal-apt-install --enable-tests $MODE+ export CABAL=cabal+ else+ # Install the GHC we want from hvr's PPA+ travis_retry sudo add-apt-repository -y ppa:hvr/ghc+ travis_retry sudo apt-get update+ travis_retry sudo apt-get install cabal-install-1.18 ghc-$GHCVER happy+ export CABAL=cabal-1.18+ export PATH=/opt/ghc/$GHCVER/bin:$PATH+ fi+ # Uncomment whenever hackage is down.+ # - mkdir -p ~/.cabal && cp travis/config ~/.cabal/config && $CABAL update+ - $CABAL update++ # Update happy when building with GHC head+ - |+ if [ $GHCVER = "head" ] || [ $GHCVER = "7.8.3" ]; then+ $CABAL install happy alex+ export PATH=$HOME/.cabal/bin:$PATH+ fi++install:+ - $CABAL install --dependencies-only --enable-tests+ - $CABAL configure --enable-tests $MODE++script:+ - $CABAL build+ - $CABAL test --show-details=always++notifications:+ irc:+ channels:+ - "irc.freenode.org#haskell-lens"+ skip_join: true+ template:+ - "\x0313reflection\x03/\x0306%{branch}\x03 \x0314%{commit}\x03 %{build_url} %{message}"
CHANGELOG.markdown view
@@ -1,3 +1,7 @@+# 1.5.1.1+* Updated the link to the paper.+* More examples.+ # 1.5.1 * We no longer export Show (Q a) for GHC >= 7.4. This was causing random hangs when users tried to somehow run declaration splices from the REPL. * We no longer depend on tagged for GHC >= 7.8, since `Proxy` is now in `base`.
README.markdown view
@@ -3,7 +3,7 @@ [](http://travis-ci.org/ekmett/reflection) -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.+This package provides an implementation of the ideas presented in [Functional Pearl: Implicit Configurations](http://okmij.org/ftp/Haskell/tr-15-04.pdf) by Oleg Kiselyov and Chung-Chieh Shan. However, the API has been implemented in a much more efficient manner. Contact Information -------------------
fast/Data/Reflection.hs view
@@ -34,7 +34,7 @@ -- Pearl: Implicit Configurations paper by Oleg Kiselyov and -- Chung-chieh Shan. ----- <http://www.cs.rutgers.edu/~ccshan/prepose/prepose.pdf>+-- <http://okmij.org/ftp/Haskell/tr-15-04.pdf> -- -- The approach from the paper was modified to work with Data.Proxy -- and to cheat by using knowledge of GHC's internal representations
reflection.cabal view
@@ -1,5 +1,5 @@ name: reflection-version: 1.5.1+version: 1.5.1.1 license: BSD3 license-file: LICENSE author: Edward A. Kmett, Elliott Hird, Oleg Kiselyov and Chung-chieh Shan@@ -15,16 +15,59 @@ build-type: Simple cabal-version: >= 1.10 description:- This package provides an implementation of the ideas presented in the paper- \"Functional Pearl: Implicit Configurations\" by Oleg Kiselyov and- Chung-chieh Shan. However, the API has been streamlined to improve performance.+ This package addresses the /configuration problem/ which is+ propogating configurations that are available at run-time, allowing+ multible configurations to coexist without resorting to mutable+ global variables or 'System.IO.Unsafe.unsafePerformIO'. .- The original paper can be obtained from- <http://www.cs.rutgers.edu/~ccshan/prepose/prepose.pdf>.+ An example is modular arithmetic where the modulus itself can be+ supplied at run-time: .- For a summary of the approach taken by this library, along with more motivating- examples, see Austin Seipp's tutorial at- <https://www.fpcomplete.com/user/thoughtpolice/using-reflection>.+ @+ foo :: Modular s => Modulus s+ foo = 1000 * 1000 * 5 + 2000+ @ + >>> withModulus 1280 foo+ 1040+ .+ given the following setup:+ .+ @+ {-# LANGUAGE ScopedTypeVariables, RankNTypes, ConstraintKinds, FlexibleContexts, UndecidableInstances #-}+ .+ import Data.Proxy (Proxy(Proxy))+ import Data.Reflection (Reifies, reflect, reify)+ @+ .+ and definitions:+ .+ @+ data Modulus s = M { getModulus :: Integer }+ type Modular s = 'Data.Reflection.Reifies' s Integer+ .+ normalize :: forall s. Modular s => Integer -> Modulus s+ normalize n = M (mod n modulus) where+   modulus = 'Data.Reflection.reflect' ('Data.Proxy.Proxy' :: 'Data.Proxy.Proxy' s)+ .+ instance Modular s => Num (Modulus s) where+   M a + M b = normalize (a + b)+   M a * M b = normalize (a * b)+ .+ withModulus :: Integer -> (forall s. Modular s => Modulus s) -> Integer+ withModulus m v = 'Data.Reflection.reify' m (getModulus . asProxyOf v)+   where+   asProxyOf :: f s -> Proxy s -> f s+   asProxyOf = const+ @+ .+ That package is an implementation of the ideas presented in the+ paper \"Functional Pearl: Implicit Configurations\" by Oleg Kiselyov+ and Chung-chieh Shan (<http://okmij.org/ftp/Haskell/tr-15-04.pdf original paper>). However, the API has been streamlined to improve+ performance.+ .+ Austin Seipp's tutorial <https://www.fpcomplete.com/user/thoughtpolice/using-reflection Reflecting values to types and back> provides a summary of the+ approach taken by this library, along with more motivating+ examples. extra-source-files: examples/Monoid.hs
slow/Data/Reflection.hs view
@@ -23,7 +23,7 @@ -- Pearl: Implicit Configurations paper by Oleg Kiselyov and -- Chung-chieh Shan. ----- <http://www.cs.rutgers.edu/~ccshan/prepose/prepose.pdf>+-- <http://okmij.org/ftp/Haskell/tr-15-04.pdf> -- -- The approach from the paper was modified to work with Data.Proxy -- and streamline the API by Edward Kmett and Elliott Hird.