packages feed

hvect 0.3.0.0 → 0.3.1.0

raw patch · 5 files changed

+20/−15 lines, 5 files

Files

LICENSE view
@@ -1,5 +1,5 @@ Copyright (c) 2014 - 2015 Tim Baumann <tim@timbaumann.info>-Copyright (c) 2014 - 2015 Alexander Thiemann <mail@athiemann.net>+Copyright (c) 2014 - 2016 Alexander Thiemann <mail@athiemann.net>  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the
README.md view
@@ -30,4 +30,4 @@ ### License  Released under the MIT license.-(c) 2014 - 2015 Alexander Thiemann <mail@athiemann.net>, Tim Baumann <tim@timbaumann.info>+(c) 2014 - 2016 Alexander Thiemann <mail@athiemann.net>, Tim Baumann <tim@timbaumann.info>
hvect.cabal view
@@ -1,5 +1,5 @@ name:                hvect-version:             0.3.0.0+version:             0.3.1.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@@ -8,7 +8,7 @@ license-file:        LICENSE author:              Alexander Thiemann <mail@athiemann.net>, Tim Baumann <tim@timbaumann.info> maintainer:          Alexander Thiemann <mail@athiemann.net>-copyright:           (c) 2014 - 2015 Alexander Thiemann <mail@athiemann.net>, Tim Baumann <tim@timbaumann.info>+copyright:           (c) 2014 - 2016 Alexander Thiemann <mail@athiemann.net>, Tim Baumann <tim@timbaumann.info> category:            Data build-type:          Simple cabal-version:       >=1.10
src/Data/HVect.hs view
@@ -15,9 +15,10 @@     HVect (..)   , empty, null, head, tail   , singleton-  , length, HVectLen (..)-  , findFirst, InList (..), ListContains (..), NotInList(..)-  , (!!), HVectIdx (..)+  , length, HVectLen+  , findFirst, InList, ListContains, NotInList+  , MaybeToList+  , (!!), HVectIdx   , HVectElim   , Append, (<++>)   , ReverseLoop, Reverse, reverse@@ -31,7 +32,6 @@   , (:<)   ) where -import Data.Proxy import Prelude hiding (reverse, uncurry, curry, head, null, (!!), length, tail)  -- | Heterogeneous vector@@ -98,6 +98,10 @@  type ListContains n x ts = (SNatRep n, InList x ts ~ n, HVectIdx n ts ~ x) +type family MaybeToList (a :: Maybe *) :: [*] where+    MaybeToList ('Just r) = '[r]+    MaybeToList 'Nothing = '[]+ -- | Find first element in 'HVect' of type x findFirst :: forall x ts n. (ListContains n x ts) => HVect ts -> x findFirst vect = idx !! vect@@ -116,14 +120,14 @@ null _ = False  head :: HVect (t ': ts) -> t-head (a :&: as) = a+head (a :&: _) = a  tail :: HVect (t ': ts) -> HVect ts-tail (a :&: as) = as+tail (_ :&: as) = as  length :: HVect as -> SNat (HVectLen as) length HNil = SZero-length (a :&: as) = SSucc (length as)+length (_ :&: as) = SSucc (length as)  sNatToInt :: SNat n -> Int sNatToInt SZero = 0@@ -133,7 +137,7 @@ intToSNat 0 = AnySNat SZero intToSNat n =     case intToSNat (n - 1) of-      AnySNat n -> AnySNat (SSucc n)+      AnySNat m -> AnySNat (SSucc m)  data Nat where     Zero :: Nat@@ -164,8 +168,9 @@     (Succ m) :- (Succ n) = m :- n  (!!) :: SNat n -> HVect as -> HVectIdx n as-SZero !! (a :&: as) = a-(SSucc s) !! (a :&: as) = s !! as+SZero !! (a :&: _) = a+(SSucc s) !! (_ :&: as) = s !! as+_ !! _ = error "HVect !!: This should never happen"  infixr 5 :&: infixr 5 <++>
test/Data/HVectTest.hs view
@@ -1,4 +1,4 @@-{-# OPTIONS_GHC -F -pgmF htfpp #-}+{-# OPTIONS_GHC -fno-warn-type-defaults -F -pgmF htfpp #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE DataKinds #-} module Data.HVectTest (htf_thisModulesTests) where