summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexanderThiemann <>2016-05-22 10:54:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2016-05-22 10:54:00 (GMT)
commit67d56f46d802ab42c412fa80b5ec20d00dda8c8e (patch)
treef6aa7acdc0231feed41d7f71d380bd6fc96dcb74
parent98ab8d03a222dc4b04c1649c8f3d57932452a418 (diff)
version 0.3.1.00.3.1.0
-rw-r--r--LICENSE2
-rw-r--r--README.md2
-rw-r--r--hvect.cabal4
-rw-r--r--src/Data/HVect.hs25
-rw-r--r--test/Data/HVectTest.hs2
5 files changed, 20 insertions, 15 deletions
diff --git a/LICENSE b/LICENSE
index 1f5cd8f..4cda4d8 100644
--- a/LICENSE
+++ b/LICENSE
@@ -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
diff --git a/README.md b/README.md
index c02360d..216a744 100644
--- a/README.md
+++ b/README.md
@@ -30,4 +30,4 @@ Simple strict heterogeneous lists
### 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>
diff --git a/hvect.cabal b/hvect.cabal
index bbc8d60..d0458e9 100644
--- a/hvect.cabal
+++ b/hvect.cabal
@@ -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: MIT
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
diff --git a/src/Data/HVect.hs b/src/Data/HVect.hs
index 853a610..abbf887 100644
--- a/src/Data/HVect.hs
+++ b/src/Data/HVect.hs
@@ -15,9 +15,10 @@ module Data.HVect
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 @@ module Data.HVect
, (:<)
) where
-import Data.Proxy
import Prelude hiding (reverse, uncurry, curry, head, null, (!!), length, tail)
-- | Heterogeneous vector
@@ -98,6 +98,10 @@ type family NotInList (x :: *) (xs :: [*]) :: Bool where
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 HNil = True
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 :: Int -> AnySNat
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 @@ type family (m :: Nat) :- (n :: Nat) :: Nat where
(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 <++>
diff --git a/test/Data/HVectTest.hs b/test/Data/HVectTest.hs
index 0087ebe..e04c3e2 100644
--- a/test/Data/HVectTest.hs
+++ b/test/Data/HVectTest.hs
@@ -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