packages feed

bytestring-class (empty) → 0.0.0

raw patch · 4 files changed

+107/−0 lines, 4 filesdep +basedep +bytestringdep +utf8-stringsetup-changed

Dependencies added: base, bytestring, utf8-string

Files

+ Data/ByteString/Class.hs view
@@ -0,0 +1,57 @@+{-# LANGUAGE TypeSynonymInstances #-}+---------------------------------------------------------+--+-- Module        : Data.ByteString.Class+-- Copyright     : Michael Snoyman+-- License       : BSD3+--+-- Maintainer    : Michael Snoyman <michael@snoyman.com>+-- Stability     : Stable+-- Portability   : portable+--+-- Classes for automatic conversion to and from strict and lazy bytestrings.+--+-- Please note: the instance for 'String' uses UTF-8 encoding.+--+---------------------------------------------------------+module Data.ByteString.Class+    ( StrictByteString (..)+    , LazyByteString (..)+    ) where++import qualified Data.ByteString as S+import qualified Data.ByteString.UTF8 as SU+import qualified Data.ByteString.Lazy as L+import qualified Data.ByteString.Lazy.UTF8 as LU++class StrictByteString a where+    toStrictByteString :: a -> S.ByteString+    fromStrictByteString :: S.ByteString -> a++instance StrictByteString S.ByteString where+    toStrictByteString = id+    fromStrictByteString = id++instance StrictByteString L.ByteString where+    toStrictByteString = S.concat . L.toChunks+    fromStrictByteString = L.fromChunks . return++instance StrictByteString String where+    toStrictByteString = SU.fromString+    fromStrictByteString = SU.toString++class LazyByteString a where+    toLazyByteString :: a -> L.ByteString+    fromLazyByteString :: L.ByteString -> a++instance LazyByteString L.ByteString where+    toLazyByteString = id+    fromLazyByteString = id++instance LazyByteString S.ByteString where+    toLazyByteString = fromStrictByteString+    fromLazyByteString = toStrictByteString++instance LazyByteString String where+    toLazyByteString = LU.fromString+    fromLazyByteString = LU.toString
+ LICENSE view
@@ -0,0 +1,25 @@+The following license covers this documentation, and the source code, except+where otherwise indicated.++Copyright 2008, Michael Snoyman. All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++* Redistributions of source code must retain the above copyright notice, this+  list of conditions and the following disclaimer.++* Redistributions in binary form must reproduce the above copyright notice,+  this list of conditions and the following disclaimer in the documentation+  and/or other materials provided with the distribution.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS "AS IS" AND ANY EXPRESS OR+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO+EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT,+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,+OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF+ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ Setup.lhs view
@@ -0,0 +1,7 @@+#!/usr/bin/env runhaskell++> module Main where+> import Distribution.Simple++> main :: IO ()+> main = defaultMain
+ bytestring-class.cabal view
@@ -0,0 +1,18 @@+name:            bytestring-class+version:         0.0.0+license:         BSD3+license-file:    LICENSE+author:          Michael Snoyman <michael@snoyman.com>+maintainer:      Michael Snoyman <michael@snoyman.com>+synopsis:        Classes for automatic conversion to and from strict and lazy bytestrings.+description:     In theory, this allows the design of more data-agnostic+                 APIs.+category:        Data+stability:       stable+cabal-version:   >= 1.2+build-type:      Simple++library+    build-depends:   base, bytestring, utf8-string+    exposed-modules: Data.ByteString.Class+    ghc-options:     -Wall