Hello community, here is the log from the commit of package ghc-hvect for openSUSE:Factory checked in at 2016-01-08 15:22:55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/ghc-hvect (Old) and /work/SRC/openSUSE:Factory/.ghc-hvect.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "ghc-hvect" Changes: -------- --- /work/SRC/openSUSE:Factory/ghc-hvect/ghc-hvect.changes 2015-11-10 10:02:24.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.ghc-hvect.new/ghc-hvect.changes 2016-01-08 15:22:57.000000000 +0100 @@ -1,0 +2,5 @@ +Tue Dec 15 18:03:42 UTC 2015 - mimi...@gmail.com + +- update to 0.3.0.0 + +------------------------------------------------------------------- Old: ---- hvect-0.2.0.0.tar.gz New: ---- hvect-0.3.0.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ ghc-hvect.spec ++++++ --- /var/tmp/diff_new_pack.nvrhIQ/_old 2016-01-08 15:22:58.000000000 +0100 +++ /var/tmp/diff_new_pack.nvrhIQ/_new 2016-01-08 15:22:58.000000000 +0100 @@ -20,7 +20,7 @@ %bcond_with tests Name: ghc-hvect -Version: 0.2.0.0 +Version: 0.3.0.0 Release: 0 Summary: Simple strict heterogeneous lists Group: System/Libraries ++++++ hvect-0.2.0.0.tar.gz -> hvect-0.3.0.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hvect-0.2.0.0/README.md new/hvect-0.3.0.0/README.md --- old/hvect-0.2.0.0/README.md 1970-01-01 01:00:00.000000000 +0100 +++ new/hvect-0.3.0.0/README.md 2015-08-23 19:52:10.000000000 +0200 @@ -0,0 +1,33 @@ +hvect +===== + +[![Build Status](https://travis-ci.org/agrafix/hvect.svg)](https://travis-ci.org/agrafix/hvect) +[![Hackage](https://img.shields.io/hackage/v/hvect.svg)](http://hackage.haskell.org/package/hvect) + +## Intro + +Hackage: [hvect](http://hackage.haskell.org/package/hvect) +Stackage: [hvect](https://www.stackage.org/package/hvect) + +Simple strict heterogeneous lists + + +## Install + +* Using cabal: `cabal install hvect` +* Using Stack: `stack install hvect` +* From Source (cabal): `git clone https://github.com/agrafix/hvect.git && cd hvect && cabal install` +* From Source (stack): `git clone https://github.com/agrafix/hvect.git && cd hvect && stack build` + + +## Misc + +### Supported GHC Versions + +* 7.8.4 +* 7.10.2 + +### License + +Released under the MIT license. +(c) 2014 - 2015 Alexander Thiemann <m...@athiemann.net>, Tim Baumann <t...@timbaumann.info> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hvect-0.2.0.0/hvect.cabal new/hvect-0.3.0.0/hvect.cabal --- old/hvect-0.2.0.0/hvect.cabal 2015-07-19 22:41:17.000000000 +0200 +++ new/hvect-0.3.0.0/hvect.cabal 2015-08-23 19:52:10.000000000 +0200 @@ -1,5 +1,5 @@ name: hvect -version: 0.2.0.0 +version: 0.3.0.0 synopsis: Simple strict heterogeneous lists description: Small, concise and simple implementation of heterogeneous lists with useful utility functions homepage: https://github.com/agrafix/hvect @@ -12,10 +12,13 @@ category: Data build-type: Simple cabal-version: >=1.10 +tested-with: GHC==7.8.4, GHC==7.10.2 +extra-source-files: + README.md library exposed-modules: Data.HVect - build-depends: base >=4.6 && <5 + build-depends: base >=4.7 && <5 hs-source-dirs: src default-language: Haskell2010 @@ -31,4 +34,4 @@ source-repository head type: git - location: git://github.com/agrafix/hvect.git + location: https://github.com/agrafix/hvect diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hvect-0.2.0.0/src/Data/HVect.hs new/hvect-0.3.0.0/src/Data/HVect.hs --- old/hvect-0.2.0.0/src/Data/HVect.hs 2015-07-19 22:41:17.000000000 +0200 +++ new/hvect-0.3.0.0/src/Data/HVect.hs 2015-08-23 19:52:10.000000000 +0200 @@ -1,19 +1,22 @@ +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE GADTs #-} +{-# LANGUAGE KindSignatures #-} {-# LANGUAGE PolyKinds #-} -{-# LANGUAGE UndecidableInstances #-} -- for ReverseLoop type family {-# LANGUAGE RankNTypes #-} +{-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-} -{-# LANGUAGE GADTs #-} -{-# LANGUAGE DataKinds #-} -{-# LANGUAGE KindSignatures #-} -{-# LANGUAGE FlexibleInstances #-} - +{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE ConstraintKinds #-} +{-# LANGUAGE UndecidableInstances #-} -- for ReverseLoop type family module Data.HVect ( -- * typesafe strict vector HVect (..) , empty, null, head, tail , singleton , length, HVectLen (..) + , findFirst, InList (..), ListContains (..), NotInList(..) , (!!), HVectIdx (..) , HVectElim , Append, (<++>) @@ -28,6 +31,7 @@ , (:<) ) where +import Data.Proxy import Prelude hiding (reverse, uncurry, curry, head, null, (!!), length, tail) -- | Heterogeneous vector @@ -66,15 +70,40 @@ a :&: as <= b :&: bs = a <= b && as <= bs --- todo: use a closed type family once GHC 7.6 compatibility is dropped -type family HVectElim (ts :: [*]) (a :: *) :: * -type instance HVectElim '[] a = a -type instance HVectElim (t ': ts) a = t -> HVectElim ts a - --- todo: use a closed type family once GHC 7.6 compatibility is dropped -type family Append (as :: [*]) (bs :: [*]) :: [*] -type instance Append '[] bs = bs -type instance Append (a ': as) bs = a ': (Append as bs) +type family HVectElim (ts :: [*]) (a :: *) :: * where + HVectElim '[] a = a + HVectElim (t ': ts) a = t -> HVectElim ts a + +type family Append (as :: [*]) (bs :: [*]) :: [*] where + Append '[] bs = bs + Append (a ': as) bs = a ': (Append as bs) + +type family InList (x :: *) (xs :: [*]) :: Nat where + InList x (x ': ys) = Zero + InList x (y ': ys) = Succ (InList x ys) + +class SNatRep n where + getSNat :: SNat n + +instance SNatRep Zero where + getSNat = SZero + +instance SNatRep n => SNatRep (Succ n) where + getSNat = SSucc getSNat + +type family NotInList (x :: *) (xs :: [*]) :: Bool where + NotInList x (x ': ys) = False + NotInList x (y ': ys) = NotInList x ys + NotInList x '[] = True + +type ListContains n x ts = (SNatRep n, InList x ts ~ n, HVectIdx n ts ~ x) + +-- | Find first element in 'HVect' of type x +findFirst :: forall x ts n. (ListContains n x ts) => HVect ts -> x +findFirst vect = idx !! vect + where + idx :: SNat n + idx = getSNat singleton :: a -> HVect '[a] singleton el = el :&: HNil @@ -117,25 +146,24 @@ data AnySNat where AnySNat :: forall n. SNat n -> AnySNat -type family HVectLen (ts :: [*]) :: Nat -type instance HVectLen '[] = Zero -type instance HVectLen (t ': ts) = Succ (HVectLen ts) - -type family HVectIdx (n :: Nat) (ts :: [*]) :: * -type instance HVectIdx Zero (a ': as) = a -type instance HVectIdx (Succ n) (a ': as) = HVectIdx n as -type instance HVectIdx a '[] = () - -type family (m :: Nat) :< (n :: Nat) :: Bool -type instance m :< Zero = False -type instance Zero :< (Succ n) = True -type instance (Succ m) :< (Succ n) = m :< n - -type family (m :: Nat) :- (n :: Nat) :: Nat -type instance n :- Zero = n -type instance (Succ m) :- (Succ n) = m :- n +type family HVectLen (ts :: [*]) :: Nat where + HVectLen '[] = Zero + HVectLen (t ': ts) = Succ (HVectLen ts) + +type family HVectIdx (n :: Nat) (ts :: [*]) :: * where + HVectIdx Zero (a ': as) = a + HVectIdx (Succ n) (a ': as) = HVectIdx n as + +type family (m :: Nat) :< (n :: Nat) :: Bool where + m :< Zero = False + Zero :< (Succ n) = True + (Succ m) :< (Succ n) = m :< n + +type family (m :: Nat) :- (n :: Nat) :: Nat where + n :- Zero = n + (Succ m) :- (Succ n) = m :- n -(!!) :: ((n :< HVectLen as) ~ True) => SNat n -> HVect as -> HVectIdx n as +(!!) :: SNat n -> HVect as -> HVectIdx n as SZero !! (a :&: as) = a (SSucc s) !! (a :&: as) = s !! as @@ -147,9 +175,9 @@ (<++>) HNil bs = bs (<++>) (a :&: as) bs = a :&: (as <++> bs) -type family ReverseLoop (as :: [*]) (bs :: [*]) :: [*] -type instance ReverseLoop '[] bs = bs -type instance ReverseLoop (a ': as) bs = ReverseLoop as (a ': bs) +type family ReverseLoop (as :: [*]) (bs :: [*]) :: [*] where + ReverseLoop '[] bs = bs + ReverseLoop (a ': as) bs = ReverseLoop as (a ': bs) type Reverse as = ReverseLoop as '[] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hvect-0.2.0.0/test/Data/HVectTest.hs new/hvect-0.3.0.0/test/Data/HVectTest.hs --- old/hvect-0.2.0.0/test/Data/HVectTest.hs 2015-07-19 22:41:17.000000000 +0200 +++ new/hvect-0.3.0.0/test/Data/HVectTest.hs 2015-08-23 19:52:10.000000000 +0200 @@ -72,3 +72,11 @@ do assertEqual "foo" (SZero HV.!! ("foo" :&: "bar" :&: empty)) assertEqual "bar" (SSucc SZero HV.!! ("foo" :&: "bar" :&: empty)) assertEqual "bar" (SSucc (SSucc SZero) HV.!! (True :&: "foo" :&: "bar" :&: empty)) + +test_getFirst :: IO () +test_getFirst = + do assertEqual True (findFirst (intOne :&: True :&: False :&: "foo" :&: empty)) + assertEqual intOne (findFirst (intOne :&: True :&: False :&: "foo" :&: empty)) + where + intOne :: Int + intOne = 1