Skip to content

Commit

Permalink
Cut release, put sinces on every new function
Browse files Browse the repository at this point in the history
  • Loading branch information
kozross committed Jan 22, 2022
1 parent ed2ebdc commit 65195d4
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 20 deletions.
5 changes: 3 additions & 2 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

## WIP

## [1.6.0] - 2022-01-22

- Add instances of `FunctorWithIndex`, `FoldableWithIndex` and
`TraversableWithIndex` for `Vector n a`.
- Drop support for GHC older than 8.10
- Safe construction of vectors from linked lists
- https://github.com/expipiplus1/vector-sized/pull/88
- Safe construction of vectors from linked lists (https://github.com/expipiplus1/vector-sized/pull/88)

Thanks to @sheaf and @kozross

Expand Down
16 changes: 10 additions & 6 deletions src/Data/Vector/Generic/Sized.hs
Original file line number Diff line number Diff line change
Expand Up @@ -326,13 +326,7 @@ instance KnownNat n => Applicative (Vector Boxed.Vector n) where
-- @'join' :: Vector n (Vector n a) -> Vector n a@ gets the /diagonal/ from
-- a square "matrix".
instance KnownNat n => Monad (Vector Boxed.Vector n) where
<<<<<<< HEAD
return = pure
xs >>= f = imap (\i x -> f x `index` i) xs
(>>) = (*>)
=======
xs >>= f = imap (\i x -> f x `index` i) xs
>>>>>>> master

-- | Non-empty sized vectors are lawful comonads.
--
Expand Down Expand Up @@ -659,15 +653,23 @@ singleton a = Vector (VG.singleton a)
-- fromTuple (1,2) :: Vector v 2 Int
-- fromTuple ("hey", "what's", "going", "on") :: Vector v 4 String
-- @
--
-- @since 1.6.0
fromTuple :: forall v a input length.
(VG.Vector v a, IndexedListLiterals input length a, KnownNat length)
=> input -> Vector v length a
fromTuple = Vector . VG.fromListN (fromIntegral $ natVal $ Proxy @length) . ILL.toList

infixr 5 :<

-- | @since 1.6.0
data BuildVector (n :: Nat) a where
-- | @since 1.6.0
Nil :: BuildVector 0 a
-- | @since 1.6.0
(:<) :: a -> BuildVector n a -> BuildVector (1 + n) a

-- | @since 1.6.0
deriving instance Show a => Show (BuildVector n a)

-- | /O(n)/ Construct a vector in a type-safe manner using a sized linked list.
Expand All @@ -676,6 +678,8 @@ deriving instance Show a => Show (BuildVector n a)
-- Build ("not" :< "much" :< Nil) :: Vector v 2 String
-- @
-- Can also be used as a pattern.
--
-- @since 1.6.0
pattern Build :: VG.Vector v a => BuildVector n a -> Vector v n a
pattern Build build <- ( ( \ ( Vector v ) -> unsafeCoerce $ VG.toList v ) -> build )
where
Expand Down
4 changes: 4 additions & 0 deletions src/Data/Vector/Sized.hs
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,8 @@ singleton = V.singleton
-- fromTuple (1,2) :: Vector 2 Int
-- fromTuple ("hey", "what's", "going", "on") :: Vector 4 String
-- @
--
-- @since 1.6.0
fromTuple :: forall input length ty.
(IndexedListLiterals input length ty, KnownNat length)
=> input -> Vector length ty
Expand All @@ -501,6 +503,8 @@ fromTuple = V.fromTuple
-- Build ("not" :< "much" :< Nil) :: Vector 2 String
-- @
-- Can also be used as a pattern.
--
-- @since 1.6.0
pattern Build :: V.BuildVector n a -> Vector n a
pattern Build build = V.Build build

Expand Down
4 changes: 4 additions & 0 deletions src/Data/Vector/Storable/Sized.hs
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,8 @@ singleton = V.singleton
-- fromTuple (1,2) :: Vector 2 Int
-- fromTuple ("hey", "what's", "going", "on") :: Vector 4 String
-- @
--
-- @since 1.6.0
fromTuple :: forall a input length.
(Storable a, IndexedListLiterals input length a, KnownNat length)
=> input -> Vector length a
Expand All @@ -509,6 +511,8 @@ fromTuple = V.fromTuple
-- Build ("not" :< "much" :< Nil) :: Vector 2 String
-- @
-- Can also be used as a pattern.
--
-- @since 1.6.0
pattern Build :: Storable a => V.BuildVector n a -> Vector n a
pattern Build vec = V.Build vec

Expand Down
4 changes: 4 additions & 0 deletions src/Data/Vector/Unboxed/Sized.hs
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,8 @@ singleton = V.singleton
-- fromTuple (1,2) :: Vector 2 Int
-- fromTuple ("hey", "what's", "going", "on") :: Vector 4 String
-- @
--
-- @since 1.6.0
fromTuple :: forall a input length.
(Unbox a, IndexedListLiterals input length a, KnownNat length)
=> input -> Vector length a
Expand All @@ -510,6 +512,8 @@ fromTuple = V.fromTuple
-- Build ("not" :< "much" :< Nil) :: Vector 2 String
-- @
-- Can also be used as a pattern.
--
-- @since 1.6.0
pattern Build :: Unbox a => V.BuildVector n a -> Vector n a
pattern Build vec = V.Build vec

Expand Down
15 changes: 3 additions & 12 deletions vector-sized.cabal
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
cabal-version: 1.12

-- This file has been generated from package.yaml by hpack version 0.34.4.
--
-- see: https://github.com/sol/hpack
--
-- hash: 8cc33c7ff1b35236dcaed143ba951337eb4f12e3c53c616fa15ec2a073c0942b

cabal-version: 3.0
name: vector-sized
version: 1.5.0
version: 1.6.0
synopsis: Size tagged vectors
description: Please see README.md
category: Data
Expand All @@ -16,7 +9,7 @@ bug-reports: https://github.com/expipiplus1/vector-sized/issues
author: Ellie Hermaszewska
maintainer: [email protected]
copyright: 2016 Ellie Hermaszewska
license: BSD3
license: BSD-3-Clause
license-file: LICENSE
build-type: Simple
tested-with: GHC ==8.10.7 || ==9.0.1 || ==9.2.1
Expand All @@ -43,8 +36,6 @@ library
Data.Vector.Storable.Sized
Data.Vector.Unboxed.Mutable.Sized
Data.Vector.Unboxed.Sized
other-modules:
Paths_vector_sized
hs-source-dirs:
src
build-depends:
Expand Down

0 comments on commit 65195d4

Please sign in to comment.