packages feed

vector-heterogenous 0.1.1 → 0.1.2

raw patch · 3 files changed

+24/−3 lines, 3 files

Files

src/Data/Vector/Heterogenous.hs view
@@ -17,6 +17,7 @@ module Data.Vector.Heterogenous     ( HVector(..)     , vec+    , View (..)          -- * Construction helpers     , ValidHVector(..)
src/Data/Vector/Heterogenous/HList.hs view
@@ -11,6 +11,7 @@ {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE PolyKinds #-} {-# LANGUAGE UndecidableInstances #-}+{-# LANGUAGE DeriveDataTypeable #-}  module Data.Vector.Heterogenous.HList     ( @@ -22,6 +23,9 @@     , HTake1 (..)     , HDrop1 (..)     +    -- ** Typeable+    , TypeList(..)+         -- * Downcasting     , ConstraintBox (..)     , Downcast (..)@@ -58,7 +62,7 @@     )     where --- import Data.Semigroup+import Data.Dynamic import Data.Monoid import GHC.TypeLits import Unsafe.Coerce@@ -91,7 +95,6 @@              EQ -> compare xs ys              LT -> LT              GT -> GT-                                       instance Monoid (HList '[]) where     mempty = HNil@@ -99,6 +102,23 @@ instance (Monoid x, Monoid (HList xs)) => Monoid (HList (x ': xs)) where     mempty = mempty:::mempty     (x:::xs) `mappend` (y:::ys) = (x `mappend` y):::(xs `mappend` ys)++-- | Typeable is scary and I don't understand what's going on.  Hopefully this is correct :)++{-# NOINLINE hlistTyCon #-}+hlistTyCon :: [TypeRep] -> TyCon+hlistTyCon xs = mkTyCon3 "vector-heterogenous" "Data.Vector.Heterogenous.HList" ("HList '"++show xs)++instance (TypeList (HList xs)) => Typeable (HList xs) where+    typeOf _ = mkTyConApp (hlistTyCon $ typeList (undefined::HList xs)) []+    +class TypeList t where+    typeList :: t -> [TypeRep]+    +instance TypeList (HList '[]) where+    typeList _ = []+instance (TypeList (HList xs), Typeable x) => TypeList (HList (x ': xs)) where+    typeList _ = (typeOf (undefined::x)):(typeList (undefined::HList xs))  -- | Used only for the HList class to determine its length 
vector-heterogenous.cabal view
@@ -1,5 +1,5 @@ Name:                vector-heterogenous-Version:             0.1.1+Version:             0.1.2 Synopsis:            A type-safe library for vectors whose elements can be of any type, or any type satisfying some constraints Description:          Category:            Data, Data Structures