packages feed

classy-prelude (empty) → 0.1.0.0

raw patch · 17 files changed

+850/−0 lines, 17 filesdep +basedep +bytestringdep +containerssetup-changed

Dependencies added: base, bytestring, containers, hashable, system-filepath, text, transformers, unordered-containers, vector

Files

+ ClassyPrelude.hs view
@@ -0,0 +1,201 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE FunctionalDependencies #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE TypeFamilies #-}+module ClassyPrelude+    ( -- * Standard+      -- ** Operators+      (Prelude.$)+    , (Prelude.+)+    , (Prelude.-)+    , (Prelude.*)+    , (Prelude./)+    , (Prelude.&&)+    , (Prelude.||)+    , (Prelude..)+      -- ** Functions+    , Prelude.not+    , Prelude.otherwise+    , Prelude.fst+    , Prelude.snd+    , Prelude.id+    , Prelude.maybe+    , Prelude.either+    , Prelude.flip+    , Prelude.const+    , Prelude.error+    , Prelude.zip+    , Prelude.unzip+    , Prelude.zipWith+    , Prelude.or+    , Data.Text.IO.putStrLn+    , Prelude.elem+    , Prelude.odd+    , Prelude.even+    , Prelude.uncurry+      -- ** Type classes+    , Prelude.Ord (..)+    , Prelude.Eq (..)+    , Prelude.Enum (..)+    , Prelude.Show+    , Prelude.Functor (..)+    , Prelude.Monad (..)+    , (Control.Monad.=<<)+      -- ** Data types+    , Prelude.Maybe (..)+    , Prelude.Ordering (..)+    , Prelude.Bool (..)+    , Prelude.Char+    , Prelude.IO+    , Prelude.Either (..)+    , Prelude.Integral (..)+      -- * Re-exports+      -- ** Packed reps+    , ByteString+    , LByteString+    , Text+    , LText+      -- ** Containers+    , Map+    , HashMap+    , LHashMap+    , Set+    , HashSet+    , Vector+      -- ** Numbers+    , Word8+    , Word64+    , Int64+    , Prelude.Int+    , Word+      -- ** Monoids+    , Monoid (..)+    , concat+    , (++)+      -- ** Arrow+    , Control.Arrow.first+    , Control.Arrow.second+    , (Control.Arrow.***)+    , (Control.Arrow.&&&)+      -- ** Maybe+    , Data.Maybe.mapMaybe+    , Data.Maybe.catMaybes+    , Data.Maybe.fromMaybe+      -- ** Either+    , Data.Either.partitionEithers+      -- ** Applicative+    , Control.Applicative.Applicative (..)+    , (Control.Applicative.<$>)+      -- ** Monad+    , (Control.Monad.>=>)+      -- ** Transformers+    , Control.Monad.Trans.Class.lift+    , Control.Monad.IO.Class.MonadIO+    , Control.Monad.IO.Class.liftIO+      -- ** Exceptions+    , Control.Exception.Exception (..)+    , Control.Exception.SomeException+    , Control.Exception.throwIO+      -- ** Files+    , F.FilePath+    , (F.</>)+    , (F.<.>)+    , F.hasExtension+    , F.basename+    , F.filename+      -- * Non-standard+      -- ** List-like classes+    , map+    , concatMap+    , filter+    , length+    , singleton+    , null+    , pack+    , unpack+    , fromList+    , toList+    , mapM+    , mapM_+    , empty+    , stripPrefix+    , break+    , span+    , dropWhile+    , takeWhile+    , any+    , all+    , splitAt+    , fold+      -- ** Map-like+    , lookup+    , insert+    , delete+      -- ** Set-like+    , member+      -- ** Text-like+    , show+      -- ** Files+    , readFile+    , writeFile+      -- ** Print+    , Prelude.print+    ) where++import qualified Prelude+import Prelude (Char, (.))++import ClassyPrelude.Classes+import ClassyPrelude.List ()+import ClassyPrelude.ByteString+import ClassyPrelude.LByteString+import ClassyPrelude.Text+import ClassyPrelude.LText+import ClassyPrelude.Map+import ClassyPrelude.Set+import ClassyPrelude.FilePath ()+import ClassyPrelude.Vector+import ClassyPrelude.HashMap+import ClassyPrelude.LHashMap+import ClassyPrelude.HashSet++import Data.Monoid (Monoid (..))+import qualified Control.Arrow+import qualified Control.Applicative+import qualified Control.Monad+import qualified Control.Exception++import qualified Filesystem.Path.CurrentOS as F++import Data.Word (Word8, Word64, Word)+import Data.Int (Int64)++import qualified Data.Text.IO++import qualified Data.Maybe+import qualified Data.Either++import qualified Control.Monad.Trans.Class+import qualified Control.Monad.IO.Class++concat :: Monoid w => [w] -> w+concat = mconcat++infixr 5  +++(++) :: Monoid w => w -> w -> w+(++) = mappend++show :: (Prelude.Show a, CanPack c Prelude.Char) => a -> c+show = pack . Prelude.show++fromList :: CanPack c i => [i] -> c+fromList = pack++toList :: CanPack c i => c -> [i]+toList = unpack++-- Misc instances+instance CanPack (Prelude.Maybe a) a where+    pack = Data.Maybe.listToMaybe+    unpack = Data.Maybe.maybeToList
+ ClassyPrelude/ByteString.hs view
@@ -0,0 +1,48 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE FunctionalDependencies #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE TypeFamilies #-}+module ClassyPrelude.ByteString+    ( ByteString+    ) where++import qualified Prelude+import Prelude ((.))+import ClassyPrelude.Classes+import qualified Data.ByteString as S+import Data.ByteString (ByteString)+import Control.Monad.IO.Class (MonadIO, liftIO)+import qualified Filesystem.Path.CurrentOS as F+import Data.Word (Word8)++instance (co ~ ByteString, i ~ Word8, o ~ Word8) => CanMapFunc ByteString co i o where+    mapFunc = S.map+instance (co ~ ByteString, i ~ Word8, o ~ ByteString) => CanConcatMapFunc ByteString co i o where+    concatMapFunc = S.concatMap+instance CanFilterFunc ByteString Word8 where+    filterFunc = S.filter+instance CanLength ByteString Prelude.Int where+    length = S.length+instance CanSingleton ByteString Word8 where+    singleton = S.singleton+instance CanNull ByteString where+    null = S.null+instance CanPack ByteString Word8 where+    pack = S.pack+    unpack = S.unpack+instance CanEmpty ByteString where+    empty = S.empty+instance MonadIO m => CanReadFile (m ByteString) where+    readFile = liftIO . S.readFile . F.encodeString+instance CanWriteFileFunc ByteString where+    writeFileFunc fp = liftIO . S.writeFile (F.encodeString fp)+instance CanBreak ByteString Word8 where+    break = S.break+    span = S.span+    dropWhile = S.dropWhile+    takeWhile = S.takeWhile+instance CanAny ByteString Word8 where+    any = S.any+    all = S.all+instance CanSplitAt ByteString Prelude.Int where+    splitAt = S.splitAt
+ ClassyPrelude/Classes.hs view
@@ -0,0 +1,110 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE FunctionalDependencies #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE TypeFamilies #-}+module ClassyPrelude.Classes where++import qualified Prelude+import qualified Filesystem.Path.CurrentOS as F+import Control.Monad.IO.Class (MonadIO)++class CanMap f i o where+    map :: (i -> o) -> f+class CanMapFunc ci co i o where+    mapFunc :: (i -> o) -> ci -> co+instance CanMapFunc ci co i o => CanMap (ci -> co) i o where+    map = mapFunc++class CanConcatMap f i o where+    concatMap :: (i -> o) -> f+class CanConcatMapFunc ci co i o where+    concatMapFunc :: (i -> o) -> ci -> co+instance CanConcatMapFunc ci co i o => CanConcatMap (ci -> co) i o where+    concatMap = concatMapFunc++class CanFilter f a where+    filter :: (a -> Prelude.Bool) -> f+class CanFilterFunc c i | c -> i where+    filterFunc :: (i -> Prelude.Bool) -> c -> c+instance (b ~ c, CanFilterFunc b a) => CanFilter (b -> c) a where+    filter = filterFunc++class CanLength c i | c -> i where+    length :: c -> i++class CanSingleton c i | c -> i where+    singleton :: i -> c++class CanNull c where+    null :: c -> Prelude.Bool++class CanPack c i | c -> i where+    pack :: [i] -> c+    unpack :: c -> [i]++class CanMapM f i o m where+    mapM :: (i -> m o) -> f+class CanMapMFunc ci co i o m where+    mapMFunc :: (i -> m o) -> ci -> m co+instance CanMapMFunc ci co i o m => CanMapM (ci -> m co) i o m where+    mapM = mapMFunc++class CanMapM_ f i o m where+    mapM_ :: (i -> m o) -> f+class CanMapM_Func ci i o m where+    mapM_Func :: (i -> m o) -> ci -> m ()+instance CanMapM_Func ci i o m => CanMapM_ (ci -> m ()) i o m where+    mapM_ = mapM_Func++class CanLookup c k v | c -> k v where+    lookup :: k -> c -> Prelude.Maybe v++class CanEmpty c where+    empty :: c++class CanInsert f where+    insert :: f+class CanInsertVal c k v | c -> k v where+    insertVal :: k -> v -> c -> c+instance (CanInsertVal c' k v, c ~ c') => CanInsert (k -> v -> c -> c') where+    insert = insertVal++class CanDelete c k | c -> k where+    delete :: k -> c -> c++class CanMember c k | c -> k where+    member :: k -> c -> Prelude.Bool++class CanReadFile a where+    readFile :: F.FilePath -> a++class CanWriteFile a where+    writeFile :: F.FilePath -> a+class CanWriteFileFunc a where+    writeFileFunc :: MonadIO m => F.FilePath -> a -> m ()+instance (MonadIO m, b ~ (), CanWriteFileFunc a) => CanWriteFile (a -> m b) where+    writeFile = writeFileFunc++class CanStripPrefix a where+    stripPrefix :: a -> a -> Prelude.Maybe a++class CanBreak c i | c -> i where+    break :: (i -> Prelude.Bool) -> c -> (c, c)+    span :: (i -> Prelude.Bool) -> c -> (c, c)+    dropWhile :: (i -> Prelude.Bool) -> c -> c+    takeWhile :: (i -> Prelude.Bool) -> c -> c++class CanAny c i | c -> i where+    any :: (i -> Prelude.Bool) -> c -> Prelude.Bool+    all :: (i -> Prelude.Bool) -> c -> Prelude.Bool++class CanSplitAt c i | c -> i where+    splitAt :: i -> c -> (c, c)++class CanFold accum a f where+    -- | Strict left fold.+    fold :: (accum -> a -> accum) -> accum -> f+class CanFoldFunc c accum a | c -> a where+    foldFunc :: (accum -> a -> accum) -> accum -> c -> accum+instance (accum ~ accum', CanFoldFunc c accum a) => CanFold accum a (c -> accum') where+    fold = foldFunc
+ ClassyPrelude/FilePath.hs view
@@ -0,0 +1,16 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE FunctionalDependencies #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE TypeFamilies #-}+module ClassyPrelude.FilePath () where++import qualified Prelude+import Prelude ((.), Char)+import ClassyPrelude.Classes+import qualified Filesystem.Path.CurrentOS as F++instance CanPack F.FilePath Prelude.Char where+    pack = F.decodeString+    unpack = F.encodeString+instance CanStripPrefix F.FilePath where+    stripPrefix = F.stripPrefix
+ ClassyPrelude/HashMap.hs view
@@ -0,0 +1,38 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE FunctionalDependencies #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE TypeFamilies #-}+module ClassyPrelude.HashMap+    ( HashMap+    ) where++import qualified Prelude+import Prelude ((.), Char)+import ClassyPrelude.Classes+import Data.HashMap.Strict (HashMap)+import qualified Data.HashMap.Strict as Map+import Data.Hashable (Hashable)++type Map = HashMap++instance CanMapFunc (Map k v1) (Map k v2) v1 v2 where+    mapFunc = Map.map+instance Hashable k => CanFilterFunc (Map k v) (k, v) where+    filterFunc = Map.filterWithKey . Prelude.curry+instance CanLength (Map k v) Prelude.Int where+    length = Map.size+instance (Prelude.Eq k, Hashable k, v' ~ v) => CanSingleton (v' -> Map k v) k where+    singleton = Map.singleton+instance CanNull (Map k v) where+    null = Map.null+instance (Prelude.Eq k, Hashable k) => CanPack (Map k v) (k, v) where+    pack = Map.fromList+    unpack = Map.toList+instance (Prelude.Eq k, Hashable k) => CanLookup (Map k v) k v where+    lookup = Map.lookup+instance CanEmpty (Map k v) where+    empty = Map.empty+instance (Prelude.Eq k, Hashable k) => CanInsertVal (Map k v) k v where+    insertVal = Map.insert+instance (Prelude.Eq k, Hashable k) => CanDelete (Map k v) k where+    delete = Map.delete
+ ClassyPrelude/HashSet.hs view
@@ -0,0 +1,34 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE FunctionalDependencies #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE TypeFamilies #-}+module ClassyPrelude.HashSet+    ( HashSet+    ) where++import qualified Prelude+import Prelude ((.), Char, Eq)+import ClassyPrelude.Classes+import Data.HashSet (HashSet)+import qualified Data.HashSet as Set+import Data.Hashable (Hashable)++type Set = HashSet++instance (Eq b, Hashable b) => CanMapFunc (Set a) (Set b) a b where+    mapFunc = Set.map+instance CanLength (Set x) Prelude.Int where+    length = Set.size+instance Hashable x => CanSingleton (Set x) x where+    singleton = Set.singleton+instance CanNull (Set x) where+    null = Set.null+instance (Hashable x, Eq x) => CanPack (Set x) x where+    pack = Set.fromList+    unpack = Set.toList+instance CanEmpty (Set x) where+    empty = Set.empty+instance (Eq x, Hashable x, Set x ~ s, x ~ x') => CanInsert (x' -> s -> Set x) where+    insert = Set.insert+instance (Eq x, Hashable x) => CanMember (Set x) x where+    member = Set.member
+ ClassyPrelude/LByteString.hs view
@@ -0,0 +1,50 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE FunctionalDependencies #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE TypeFamilies #-}+module ClassyPrelude.LByteString+    ( LByteString+    ) where++import qualified Prelude+import Prelude ((.))+import ClassyPrelude.Classes+import qualified Data.ByteString.Lazy as L+import Control.Monad.IO.Class (MonadIO, liftIO)+import qualified Filesystem.Path.CurrentOS as F+import Data.Word (Word8)+import Data.Int (Int64)++type LByteString = L.ByteString++instance (co ~ LByteString, i ~ Word8, o ~ Word8) => CanMapFunc LByteString co i o where+    mapFunc = L.map+instance (co ~ LByteString, i ~ Word8, o ~ LByteString) => CanConcatMapFunc LByteString co i o where+    concatMapFunc = L.concatMap+instance CanFilterFunc LByteString Word8 where+    filterFunc = L.filter+instance CanLength LByteString Int64 where+    length = L.length+instance CanSingleton LByteString Word8 where+    singleton = L.singleton+instance CanNull LByteString where+    null = L.null+instance CanPack LByteString Word8 where+    pack = L.pack+    unpack = L.unpack+instance CanEmpty LByteString where+    empty = L.empty+instance MonadIO m => CanReadFile (m LByteString) where+    readFile = liftIO . L.readFile . F.encodeString+instance CanWriteFileFunc LByteString where+    writeFileFunc fp = liftIO . L.writeFile (F.encodeString fp)+instance CanBreak LByteString Word8 where+    break = L.break+    span = L.span+    dropWhile = L.dropWhile+    takeWhile = L.takeWhile+instance CanAny LByteString Word8 where+    any = L.any+    all = L.all+instance CanSplitAt LByteString Int64 where+    splitAt = L.splitAt
+ ClassyPrelude/LHashMap.hs view
@@ -0,0 +1,38 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE FunctionalDependencies #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE TypeFamilies #-}+module ClassyPrelude.LHashMap+    ( LHashMap+    ) where++import qualified Prelude+import Prelude ((.), Char)+import ClassyPrelude.Classes+import qualified Data.HashMap.Lazy as Map+import Data.Hashable (Hashable)++type LHashMap = Map.HashMap+type Map = LHashMap++instance CanMapFunc (Map k v1) (Map k v2) v1 v2 where+    mapFunc = Map.map+instance Hashable k => CanFilterFunc (Map k v) (k, v) where+    filterFunc = Map.filterWithKey . Prelude.curry+instance CanLength (Map k v) Prelude.Int where+    length = Map.size+instance (Prelude.Eq k, Hashable k, v' ~ v) => CanSingleton (v' -> Map k v) k where+    singleton = Map.singleton+instance CanNull (Map k v) where+    null = Map.null+instance (Prelude.Eq k, Hashable k) => CanPack (Map k v) (k, v) where+    pack = Map.fromList+    unpack = Map.toList+instance (Prelude.Eq k, Hashable k) => CanLookup (Map k v) k v where+    lookup = Map.lookup+instance CanEmpty (Map k v) where+    empty = Map.empty+instance (Prelude.Eq k, Hashable k) => CanInsertVal (Map k v) k v where+    insertVal = Map.insert+instance (Prelude.Eq k, Hashable k) => CanDelete (Map k v) k where+    delete = Map.delete
+ ClassyPrelude/LText.hs view
@@ -0,0 +1,43 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE FunctionalDependencies #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE TypeFamilies #-}+module ClassyPrelude.LText+    ( LText+    ) where++import qualified Prelude+import Prelude ((.), Char)+import ClassyPrelude.Classes+import qualified Data.Text.Lazy as TL+import Data.Int (Int64)++type LText = TL.Text++instance (co ~ LText, i ~ Char, o ~ Char) => CanMapFunc LText co i o where+    mapFunc = TL.map+instance (co ~ LText, i ~ Char, o ~ LText) => CanConcatMapFunc LText co i o where+    concatMapFunc = TL.concatMap+instance CanFilterFunc LText Char where+    filterFunc = TL.filter+instance CanSingleton LText Prelude.Char where+    singleton = TL.singleton+instance CanNull LText where+    null = TL.null+instance CanPack LText Prelude.Char where+    pack = TL.pack+    unpack = TL.unpack+instance CanEmpty LText where+    empty = TL.empty+instance CanStripPrefix LText where+    stripPrefix = TL.stripPrefix+instance CanBreak LText Prelude.Char where+    break = TL.break+    span = TL.span+    dropWhile = TL.dropWhile+    takeWhile = TL.takeWhile+instance CanAny LText Prelude.Char where+    any = TL.any+    all = TL.all+instance CanSplitAt LText Int64 where+    splitAt = TL.splitAt
+ ClassyPrelude/List.hs view
@@ -0,0 +1,54 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE FunctionalDependencies #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE TypeFamilies #-}+module ClassyPrelude.List () where++import qualified Prelude+import Prelude ((.))+import ClassyPrelude.Classes+import qualified Data.List++instance (i ~ a, co ~ [b]) => CanMapFunc [a] co i b where+    mapFunc = Prelude.map+instance (i ~ a, co ~ [b]) => CanConcatMapFunc [a] co i [b] where+    concatMapFunc = Prelude.concatMap+instance CanFilterFunc [a] a where+    filterFunc = Prelude.filter+instance CanLength [a] Prelude.Int where+    length = Prelude.length+instance CanSingleton [a] a where+    singleton = Prelude.return+instance CanNull [a] where+    null = Prelude.null+instance CanPack [a] a where+    pack = Prelude.id+    unpack = Prelude.id+instance Prelude.Monad m => CanMapMFunc [a] [b] a b m where+    mapMFunc = Prelude.mapM+instance Prelude.Monad m => CanMapM_Func [a] a b m where+    mapM_Func = Prelude.mapM_+instance Prelude.Eq k => CanLookup [(k, v)] k v where+    lookup = Prelude.lookup+instance CanEmpty [a] where+    empty = []+instance Prelude.Eq k => CanInsertVal [(k, v)] k v where+    insertVal k v c = (k, v) : delete k c+instance Prelude.Eq k => CanDelete [(k, v)] k where+    delete k = filter ((Prelude./= k) . Prelude.fst)+instance Prelude.Eq x => CanMember [x] x where+    member x = Prelude.any (Prelude.== x)+instance Prelude.Eq a => CanStripPrefix [a] where+    stripPrefix = Data.List.stripPrefix+instance CanBreak [a] a where+    break = Prelude.break+    span = Prelude.span+    dropWhile = Prelude.dropWhile+    takeWhile = Prelude.takeWhile+instance CanAny [a] a where+    any = Prelude.any+    all = Prelude.all+instance CanSplitAt [c] Prelude.Int where+    splitAt = Prelude.splitAt+instance CanFoldFunc [a] accum a where+    foldFunc = Data.List.foldl'
+ ClassyPrelude/Map.hs view
@@ -0,0 +1,35 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE FunctionalDependencies #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE TypeFamilies #-}+module ClassyPrelude.Map+    ( Map+    ) where++import qualified Prelude+import Prelude ((.), Char)+import ClassyPrelude.Classes+import Data.Map (Map)+import qualified Data.Map as Map++instance CanMapFunc (Map k v1) (Map k v2) v1 v2 where+    mapFunc = Map.map+instance Prelude.Ord k => CanFilterFunc (Map k v) (k, v) where+    filterFunc = Map.filterWithKey . Prelude.curry+instance CanLength (Map k v) Prelude.Int where+    length = Map.size+instance (v' ~ v) => CanSingleton (v' -> Map k v) k where+    singleton = Map.singleton+instance CanNull (Map k v) where+    null = Map.null+instance Prelude.Ord k => CanPack (Map k v) (k, v) where+    pack = Map.fromList+    unpack = Map.toList+instance Prelude.Ord k => CanLookup (Map k v) k v where+    lookup = Map.lookup+instance CanEmpty (Map k v) where+    empty = Map.empty+instance Prelude.Ord k => CanInsertVal (Map k v) k v where+    insertVal = Map.insert+instance Prelude.Ord k => CanDelete (Map k v) k where+    delete = Map.delete
+ ClassyPrelude/Set.hs view
@@ -0,0 +1,31 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE FunctionalDependencies #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE TypeFamilies #-}+module ClassyPrelude.Set+    ( Set+    ) where++import qualified Prelude+import Prelude ((.), Char)+import ClassyPrelude.Classes+import Data.Set (Set)+import qualified Data.Set as Set++instance (Prelude.Ord a, Prelude.Ord b) => CanMapFunc (Set a) (Set b) a b where+    mapFunc = Set.map+instance CanLength (Set x) Prelude.Int where+    length = Set.size+instance CanSingleton (Set x) x where+    singleton = Set.singleton+instance CanNull (Set x) where+    null = Set.null+instance Prelude.Ord x => CanPack (Set x) x where+    pack = Set.fromList+    unpack = Set.toList+instance CanEmpty (Set x) where+    empty = Set.empty+instance (Prelude.Ord x, Set x ~ s, x ~ x') => CanInsert (x' -> s -> Set x) where+    insert = Set.insert+instance Prelude.Ord x => CanMember (Set x) x where+    member = Set.member
+ ClassyPrelude/Text.hs view
@@ -0,0 +1,43 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE FunctionalDependencies #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE TypeFamilies #-}+module ClassyPrelude.Text+    ( Text+    ) where++import qualified Prelude+import Prelude ((.), Char)+import ClassyPrelude.Classes+import Data.Text (Text)+import qualified Data.Text as T++instance (co ~ Text, i ~ Char, o ~ Char) => CanMapFunc Text co i o where+    mapFunc = T.map+instance (co ~ Text, i ~ Char, o ~ Text) => CanConcatMapFunc Text co i o where+    concatMapFunc = T.concatMap+instance CanFilterFunc Text Char where+    filterFunc = T.filter+instance CanLength Text Prelude.Int where+    length = T.length+instance CanSingleton Text Prelude.Char where+    singleton = T.singleton+instance CanNull Text where+    null = T.null+instance CanPack Text Prelude.Char where+    pack = T.pack+    unpack = T.unpack+instance CanEmpty Text where+    empty = T.empty+instance CanStripPrefix Text where+    stripPrefix = T.stripPrefix+instance CanBreak Text Prelude.Char where+    break = T.break+    span = T.span+    dropWhile = T.dropWhile+    takeWhile = T.takeWhile+instance CanAny Text Prelude.Char where+    any = T.any+    all = T.all+instance CanSplitAt Text Prelude.Int where+    splitAt = T.splitAt
+ ClassyPrelude/Vector.hs view
@@ -0,0 +1,49 @@+{-# LANGUAGE NoImplicitPrelude #-}+{-# LANGUAGE FunctionalDependencies #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE TypeFamilies #-}+module ClassyPrelude.Vector+    ( Vector+    ) where++import qualified Prelude+import Prelude ((.))+import ClassyPrelude.Classes+import Data.Vector (Vector)+import qualified Data.Vector as V++instance (i ~ a, co ~ Vector b) => CanMapFunc (Vector a) co i b where+    mapFunc = V.map+instance (i ~ a, co ~ Vector b) => CanConcatMapFunc (Vector a) co i (Vector b) where+    concatMapFunc = V.concatMap+instance CanFilterFunc (Vector a) a where+    filterFunc = V.filter+instance CanLength (Vector a) Prelude.Int where+    length = V.length+instance CanSingleton (Vector a) a where+    singleton = V.singleton+instance CanNull (Vector a) where+    null = V.null+instance CanPack (Vector a) a where+    pack = V.fromList+    unpack = V.toList+instance Prelude.Monad m => CanMapMFunc (Vector a) (Vector b) a b m where+    mapMFunc = V.mapM+instance Prelude.Monad m => CanMapM_Func (Vector a) a b m where+    mapM_Func = V.mapM_+instance CanEmpty (Vector a) where+    empty = V.empty+instance Prelude.Eq x => CanMember (Vector x) x where+    member x = V.any (Prelude.== x)+instance CanBreak (Vector a) a where+    break = V.break+    span = V.span+    dropWhile = V.dropWhile+    takeWhile = V.takeWhile+instance CanAny (Vector a) a where+    any = V.any+    all = V.all+instance CanSplitAt (Vector a) Prelude.Int where+    splitAt = V.splitAt+instance CanFoldFunc (Vector a) accum a where+    foldFunc = V.foldl'
+ LICENSE view
@@ -0,0 +1,20 @@+Copyright (c) 2012 Michael Snoyman, http://www.yesodweb.com/++Permission is hereby granted, free of charge, to any person obtaining+a copy of this software and associated documentation files (the+"Software"), to deal in the Software without restriction, including+without limitation the rights to use, copy, modify, merge, publish,+distribute, sublicense, and/or sell copies of the Software, and to+permit persons to whom the Software is furnished to do so, subject to+the following conditions:++The above copyright notice and this permission notice shall be+included in all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ classy-prelude.cabal view
@@ -0,0 +1,38 @@+name:                classy-prelude+version:             0.1.0.0+synopsis:            A typeclass-based Prelude.+description:         Focuses on using common typeclasses when possible, and creating new ones to avoid name clashing. Exposes many recommended datastructures (Map, ByteString, etc) directly without requiring long import lists and qualified modules.+homepage:            https://github.com/snoyberg/classy-prelude+license:             MIT+license-file:        LICENSE+author:              Michael Snoyman+maintainer:          michael@snoyman.com+category:            Control+build-type:          Simple+cabal-version:       >=1.8++library+  exposed-modules:     ClassyPrelude+                       ClassyPrelude.Classes+  other-modules:       ClassyPrelude.List+                       ClassyPrelude.ByteString+                       ClassyPrelude.LByteString+                       ClassyPrelude.Text+                       ClassyPrelude.LText+                       ClassyPrelude.Map+                       ClassyPrelude.Set+                       ClassyPrelude.FilePath+                       ClassyPrelude.Vector+                       ClassyPrelude.HashMap+                       ClassyPrelude.LHashMap+                       ClassyPrelude.HashSet+  build-depends:       base                          >= 4          && < 5+                     , system-filepath               >= 0.4        && < 0.5+                     , transformers+                     , containers+                     , text+                     , bytestring+                     , vector+                     , unordered-containers+                     , hashable+  ghc-options:         -Wall -fno-warn-orphans