data-list-zigzag 0.1.0.0 → 0.1.1.0
raw patch · 2 files changed
+103/−7 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Data.List.ZigZag: instance Data.Functor.Classes.Eq1 Data.List.ZigZag.Diagonal
+ Data.List.ZigZag: instance Data.Functor.Classes.Eq1 Data.List.ZigZag.ZigZag
+ Data.List.ZigZag: instance Data.Functor.Classes.Ord1 Data.List.ZigZag.Diagonal
+ Data.List.ZigZag: instance Data.Functor.Classes.Ord1 Data.List.ZigZag.ZigZag
+ Data.List.ZigZag: instance Data.Functor.Classes.Read1 Data.List.ZigZag.ZigZag
+ Data.List.ZigZag: instance Data.Functor.Classes.Show1 Data.List.ZigZag.Diagonal
+ Data.List.ZigZag: instance Data.Functor.Classes.Show1 Data.List.ZigZag.ZigZag
+ Data.List.ZigZag: instance GHC.Exts.IsList (Data.List.ZigZag.Diagonal a)
+ Data.List.ZigZag: instance GHC.Exts.IsList (Data.List.ZigZag.ZigZag a)
Files
- data-list-zigzag.cabal +2/−2
- src/Data/List/ZigZag.hs +101/−5
data-list-zigzag.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: data-list-zigzag -version: 0.1.0.0 +version: 0.1.1.0 synopsis: A list but with a balanced enumeration of Cartesian product. description: A list but with a balanced enumeration of Cartesian product. homepage: https://github.com/erisco/data-list-zigzag @@ -33,4 +33,4 @@ source-repository this type: git location: https://github.com/erisco/data-list-zigzag - tag: v0.1.0.0 + tag: v0.1.1.0
src/Data/List/ZigZag.hs view
@@ -3,6 +3,7 @@ {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DeriveTraversable #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# LANGUAGE TypeFamilies #-} -- | The feature of this module is 'ZigZag' and its class instances. It -- is an abstract data type and can be constructed \/ deconstructed@@ -45,6 +46,17 @@ ) -- +import Data.Functor.Classes+ ( Eq1(liftEq)+ , Ord1(liftCompare)+ , Read1(liftReadList, liftReadsPrec)+ , readsData+ , readsUnaryWith+ , showsUnaryWith+ , Show1(liftShowList, liftShowsPrec)+ )+--+ import Data.List ( transpose , unzip@@ -81,9 +93,21 @@ import GHC.Base ( Functor(fmap) , (.)+ , ($) ) -- +import GHC.Exts+ ( IsList(Item)+ )+--++import qualified GHC.Exts as IsList+ ( fromList+ , toList+ )+--+ import GHC.Generics ( Generic , Generic1@@ -91,21 +115,35 @@ -- import GHC.Read- ( Read+ ( lexP+ , parens+ , Read(readPrec) ) -- import GHC.Show- ( Show(show)+ ( Show(showsPrec)+ , showParen+ , showString ) -- import Prelude ( Eq- , Ord+ , Ord((>)) ) -- +import Text.ParserCombinators.ReadPrec+ ( prec+ )+--++import Text.Read.Lex+ ( Lexeme(Ident)+ )+--+ newtype Diagonal a = Diagonal { unDiagonal :: [a]@@ -115,6 +153,7 @@ , Applicative , Data , Eq+ , Eq1 , Foldable , Functor , Generic@@ -123,14 +162,22 @@ , MonadPlus , Monoid , Ord+ , Ord1 , Read , Semigroup , Show+ , Show1 , Traversable , Typeable ) -- +instance IsList (Diagonal a) where+ type (Item (Diagonal a)) = a+ fromList = Diagonal+ toList = unDiagonal+--+ -- NOTE: also defined in the "these" package but it has too many -- irrelevant dependencies. data These a b =@@ -178,12 +225,13 @@ deriving ( Data , Eq+ -- , Eq1 , Foldable , Functor , Generic , Generic1 , Ord- , Read+ -- , Ord1 , Traversable , Typeable )@@ -203,6 +251,16 @@ (<*>) = ap -- +instance Eq1 ZigZag where+ liftEq eq (ZigZag xs) (ZigZag ys) = liftEq (liftEq eq) xs ys+--++instance IsList (ZigZag a) where+ type (Item (ZigZag a)) = a+ fromList = fromList+ toList = toList+--+ instance Monad ZigZag where return = ZigZag . return . return (>>=) (ZigZag xs) f =@@ -225,13 +283,51 @@ mappend = (<|>) -- +instance Ord1 ZigZag where+ liftCompare cmp (ZigZag xs) (ZigZag ys) =+ liftCompare (liftCompare cmp) xs ys+ --+--++instance Read a => Read (ZigZag a) where+ readPrec = parens . prec 10 $ do+ Ident "fromDiagonals" <- lexP+ xs <- readPrec+ return (fromDiagonals xs)+--++instance Read1 ZigZag where+ liftReadsPrec rp rl =+ readsData $+ readsUnaryWith+ (liftReadsPrec (liftReadsPrec rp rl) (liftReadList rp rl))+ "fromDiagonals"+ fromDiagonals+--+ instance Semigroup (ZigZag a) where (<>) = mappend -- instance Show a => Show (ZigZag a) where- show xs = "fromDiagonals " ++ show (toDiagonals xs)+ showsPrec p xs =+ showParen (p > 10)+ ( showString "fromDiagonals "+ . showsPrec 10 (toDiagonals xs)+ ) --++instance Show1 ZigZag where+ liftShowsPrec sp sl d m =+ showsUnaryWith+ (liftShowsPrec (liftShowsPrec sp sl) (liftShowList sp sl))+ "fromDiagonals"+ d+ (toDiagonals m)+--++-- liftShowsPrec :: (Int -> [a] -> ShowS) -> ([[a]] -> ShowS) -> Int +-- -> [[a]] -> ShowS -- | Finds the diagonals through a ragged list of lists. --