sext 0.1.0.2 → 0.1.1
raw patch · 3 files changed
+28/−16 lines, 3 filesdep ~basedep ~template-haskellPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: base, template-haskell
API changes (from Hackage documentation)
+ Data.Sext: data family Sext (i :: Nat) a;
+ Data.Sext: }
+ Data.Sext.Class: data family Sext (i :: Nat) a;
+ Data.Sext.Class: type family Elem a;
+ Data.Sext.Class: }
- Data.Sext: append :: (Sextable a) => Sext m a -> Sext n a -> Sext (m + n) a
+ Data.Sext: append :: forall a m n. (Sextable a) => Sext m a -> Sext n a -> Sext (m + n) a
- Data.Sext: class Sextable a
+ Data.Sext: class Sextable a where data Sext (i :: Nat) a where {
- Data.Sext: create :: (Sextable a, KnownNat i) => a -> Maybe (Sext i a)
+ Data.Sext: create :: forall a i. (Sextable a, KnownNat i) => a -> Maybe (Sext i a)
- Data.Sext: createLeft :: (Sextable a, KnownNat i) => Elem a -> a -> Sext i a
+ Data.Sext: createLeft :: forall a i. (Sextable a, KnownNat i) => Elem a -> a -> Sext i a
- Data.Sext: createRight :: (Sextable a, KnownNat i) => Elem a -> a -> Sext i a
+ Data.Sext: createRight :: forall a i. (Sextable a, KnownNat i) => Elem a -> a -> Sext i a
- Data.Sext: drop :: (Sextable a, KnownNat m, KnownNat n, n <= m) => Sext m a -> Sext n a
+ Data.Sext: drop :: forall a m n. (Sextable a, KnownNat m, KnownNat n, n <= m) => Sext m a -> Sext n a
- Data.Sext: length :: KnownNat m => Sext m a -> Int
+ Data.Sext: length :: forall a m. KnownNat m => Sext m a -> Int
- Data.Sext: padLeft :: (Sextable a, KnownNat m, KnownNat (n - m), n ~ ((n - m) + m), m <= n) => Elem a -> Sext m a -> Sext n a
+ Data.Sext: padLeft :: forall a m n. (Sextable a, KnownNat m, KnownNat (n - m), n ~ ((n - m) + m), m <= n) => Elem a -> Sext m a -> Sext n a
- Data.Sext: padRight :: (Sextable a, KnownNat m, KnownNat (n - m), n ~ (m + (n - m)), m <= n) => Elem a -> Sext m a -> Sext n a
+ Data.Sext: padRight :: forall a m n. (Sextable a, KnownNat m, KnownNat (n - m), n ~ (m + (n - m)), m <= n) => Elem a -> Sext m a -> Sext n a
- Data.Sext: replicate :: (Sextable a, KnownNat i) => Elem a -> Sext i a
+ Data.Sext: replicate :: forall a i. (Sextable a, KnownNat i) => Elem a -> Sext i a
- Data.Sext: take :: (Sextable a, KnownNat m, KnownNat n, n <= m) => Sext m a -> Sext n a
+ Data.Sext: take :: forall a m n. (Sextable a, KnownNat m, KnownNat n, n <= m) => Sext m a -> Sext n a
- Data.Sext.Class: class Sextable a where data family Sext (i :: Nat) a type family Elem a
+ Data.Sext.Class: class Sextable a where data Sext (i :: Nat) a type Elem a where {
Files
- sext.cabal +11/−13
- src/Data/Sext.hs +13/−3
- src/Data/Sext/Class.hs +4/−0
sext.cabal view
@@ -1,5 +1,5 @@ name: sext-version: 0.1.0.2+version: 0.1.1 cabal-version: >=1.10 build-type: Simple license: BSD3@@ -9,27 +9,23 @@ homepage: http://github.com/dzhus/sext/ synopsis: Lists, Texts and ByteStrings with type-encoded length description:- Sext (/s/tatic t/ext/) provides type-level safety for- basic operations on string-like types (finite- lists of elements). Use it when you need static- guarantee on lengths of strings produced in your- code.+ Sext (/s/tatic t/ext/) provides type-level safety for basic operations on string-like types (finite lists of elements). Use it when you need static guarantee on lengths of strings produced in your code. category: Data, Text, Type System author: Dmitry Dzhus-tested-with: GHC ==7.8.3 GHC ==7.10.2+tested-with: GHC ==7.10.3 GHC ==8.0.1 source-repository head type: git location: http://github.com/dzhus/sext -flag text- description:- Build interface for Text- flag bytestring description: Build interface for ByteString +flag text+ description:+ Build interface for Text+ library if flag(bytestring)@@ -46,9 +42,11 @@ Data.Sext.Class Data.Sext.TH build-depends:- base >=4.7 && <4.9,- template-haskell >=2.9 && <2.11+ base >=4.7 && <5,+ template-haskell >=2.9 && <2.12 default-language: Haskell2010 hs-source-dirs: src+ other-modules:+ Paths_sext ghc-options: -Wall
src/Data/Sext.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE InstanceSigs #-}@@ -6,6 +7,10 @@ {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-} +#if __GLASGOW_HASKELL__ >= 800+{-# OPTIONS_GHC -Wno-redundant-constraints #-}+#endif+ {-| Sext (/s/tatic t/ext/) provides type-level safety for basic operations@@ -63,6 +68,7 @@ , length -- * Sextable class+ , Sext , Sextable(C.unsafeCreate, C.unwrap) ) @@ -141,7 +147,7 @@ -- | Append two Sexts together. ----- >>> append "foo" "bar" :: Sext 6 String+-- >>> append $(sext "foo") $(sext "bar") :: Sext 6 String -- "foobar" append :: forall a m n. (Sextable a) => Sext m a -> Sext n a -> Sext (m + n) a@@ -160,6 +166,10 @@ t = fromIntegral $ natVal (Proxy :: Proxy i) +-- | Map a Sext to a Sext of the same length.+--+-- >>> map toUpper $(sext "Hello") :: Sext 5 String+-- "HELLO" map :: Sextable a => (Elem a -> Elem a) -> Sext m a -> Sext m a map f s =@@ -168,7 +178,7 @@ -- | Reduce Sext length, preferring elements on the left. ----- >>> take "Foobar" :: Sext 3 String+-- >>> take $(sext "Foobar") :: Sext 3 String -- "Foo" take :: forall a m n. (Sextable a, KnownNat m, KnownNat n, n <= m) =>@@ -181,7 +191,7 @@ -- | Reduce Sext length, preferring elements on the right. ----- >>> drop "Foobar" :: Sext 2 String+-- >>> drop $(sext "Foobar") :: Sext 2 String -- "ar" drop :: forall a m n. (Sextable a, KnownNat m, KnownNat n, n <= m) =>
src/Data/Sext/Class.hs view
@@ -26,7 +26,11 @@ import qualified Data.Text as T #endif +#if MIN_VERSION_base(4,9,0)+import GHC.TypeLits hiding (Text)+#else import GHC.TypeLits+#endif -- | Class of types which can be assigned a type-level length.