packages feed

ascii 0.0.4.1 → 0.0.5

raw patch · 7 files changed

+369/−340 lines, 7 filesdep ~basedep ~blaze-builderdep ~bytestringsetup-changednew-uploaderPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependency ranges changed: base, blaze-builder, bytestring, case-insensitive, hashable, text

API changes (from Hackage documentation)

- Data.Ascii: instance Data Ascii
- Data.Ascii: instance Eq Ascii
- Data.Ascii: instance FoldCase Ascii
- Data.Ascii: instance Hashable Ascii
- Data.Ascii: instance IsString Ascii
- Data.Ascii: instance Monoid Ascii
- Data.Ascii: instance Monoid AsciiBuilder
- Data.Ascii: instance Ord Ascii
- Data.Ascii: instance Read Ascii
- Data.Ascii: instance Show Ascii
- Data.Ascii: instance Typeable Ascii
+ Data.Ascii.Blaze: AsciiBuilder :: (Builder) -> AsciiBuilder
+ Data.Ascii.Blaze: fromAsciiBuilder :: AsciiBuilder -> Ascii
+ Data.Ascii.Blaze: instance GHC.Base.Monoid Data.Ascii.Blaze.AsciiBuilder
+ Data.Ascii.Blaze: instance GHC.Base.Semigroup Data.Ascii.Blaze.AsciiBuilder
+ Data.Ascii.Blaze: newtype AsciiBuilder
+ Data.Ascii.Blaze: toAsciiBuilder :: Ascii -> AsciiBuilder
+ Data.Ascii.Blaze: toBuilder :: AsciiBuilder -> Builder
+ Data.Ascii.Blaze: unsafeFromBuilder :: Builder -> AsciiBuilder
+ Data.Ascii.ByteString: Ascii :: ByteString -> Ascii
+ Data.Ascii.ByteString: ciToByteString :: CIAscii -> ByteString
+ Data.Ascii.ByteString: fromByteString :: ByteString -> Maybe Ascii
+ Data.Ascii.ByteString: fromCIAscii :: CIAscii -> Ascii
+ Data.Ascii.ByteString: fromChars :: String -> Maybe Ascii
+ Data.Ascii.ByteString: fromText :: Text -> Maybe Ascii
+ Data.Ascii.ByteString: instance Data.CaseInsensitive.Internal.FoldCase Data.Ascii.ByteString.Ascii
+ Data.Ascii.ByteString: instance Data.Data.Data Data.Ascii.ByteString.Ascii
+ Data.Ascii.ByteString: instance Data.Hashable.Class.Hashable Data.Ascii.ByteString.Ascii
+ Data.Ascii.ByteString: instance Data.String.IsString Data.Ascii.ByteString.Ascii
+ Data.Ascii.ByteString: instance GHC.Base.Monoid Data.Ascii.ByteString.Ascii
+ Data.Ascii.ByteString: instance GHC.Base.Semigroup Data.Ascii.ByteString.Ascii
+ Data.Ascii.ByteString: instance GHC.Classes.Eq Data.Ascii.ByteString.Ascii
+ Data.Ascii.ByteString: instance GHC.Classes.Ord Data.Ascii.ByteString.Ascii
+ Data.Ascii.ByteString: instance GHC.Read.Read Data.Ascii.ByteString.Ascii
+ Data.Ascii.ByteString: instance GHC.Show.Show Data.Ascii.ByteString.Ascii
+ Data.Ascii.ByteString: newtype Ascii
+ Data.Ascii.ByteString: toByteString :: Ascii -> ByteString
+ Data.Ascii.ByteString: toCIAscii :: Ascii -> CIAscii
+ Data.Ascii.ByteString: toString :: Ascii -> String
+ Data.Ascii.ByteString: toText :: Ascii -> Text
+ Data.Ascii.ByteString: type CIAscii = CI Ascii
+ Data.Ascii.ByteString: unsafeFromByteString :: ByteString -> Ascii
+ Data.Ascii.ByteString: unsafeFromString :: String -> Ascii
+ Data.Ascii.ByteString: unsafeFromText :: Text -> Ascii
+ Data.Ascii.Word8: ascii :: Char -> Word8
+ Data.Ascii.Word8: fromChar :: Char -> Maybe Word8
+ Data.Ascii.Word8: fromDigit :: Num a => Word8 -> Maybe a
+ Data.Ascii.Word8: fromHexDigit :: Num a => Word8 -> Maybe a
+ Data.Ascii.Word8: fromLowAF :: Num a => Word8 -> a
+ Data.Ascii.Word8: fromLowHexDigit :: Num a => Word8 -> Maybe a
+ Data.Ascii.Word8: fromOctDigit :: Num a => Word8 -> Maybe a
+ Data.Ascii.Word8: fromUpAF :: Num a => Word8 -> a
+ Data.Ascii.Word8: fromUpHexDigit :: Num a => Word8 -> Maybe a
+ Data.Ascii.Word8: isAlpha :: Word8 -> Bool
+ Data.Ascii.Word8: isAlphaNum :: Word8 -> Bool
+ Data.Ascii.Word8: isAscii :: Word8 -> Bool
+ Data.Ascii.Word8: isControl :: Word8 -> Bool
+ Data.Ascii.Word8: isDigit :: Word8 -> Bool
+ Data.Ascii.Word8: isHexDigit :: Word8 -> Bool
+ Data.Ascii.Word8: isLowAF :: Word8 -> Bool
+ Data.Ascii.Word8: isLowHexDigit :: Word8 -> Bool
+ Data.Ascii.Word8: isLower :: Word8 -> Bool
+ Data.Ascii.Word8: isOctDigit :: Word8 -> Bool
+ Data.Ascii.Word8: isPrintable :: Word8 -> Bool
+ Data.Ascii.Word8: isSpaceOrTab :: Word8 -> Bool
+ Data.Ascii.Word8: isUpAF :: Word8 -> Bool
+ Data.Ascii.Word8: isUpHexDigit :: Word8 -> Bool
+ Data.Ascii.Word8: isUpper :: Word8 -> Bool
+ Data.Ascii.Word8: isWhiteSpace :: Word8 -> Bool
+ Data.Ascii.Word8: toChar :: Word8 -> Char
+ Data.Ascii.Word8: toLower :: Word8 -> Word8
+ Data.Ascii.Word8: toUpper :: Word8 -> Word8
+ Data.Ascii.Word8: unsafeFromDigit :: Num a => Word8 -> a
+ Data.Ascii.Word8: unsafeFromHexDigit :: Num a => Word8 -> a
+ Data.Ascii.Word8: unsafeFromLowHexDigit :: Num a => Word8 -> a
+ Data.Ascii.Word8: unsafeFromOctDigit :: Num a => Word8 -> a
+ Data.Ascii.Word8: unsafeFromUpHexDigit :: Num a => Word8 -> a

Files

Data/Ascii.hs view
@@ -1,279 +1,61 @@-{-# LANGUAGE CPP, DeriveDataTypeable, GeneralizedNewtypeDeriving #-}
-module Data.Ascii
-    ( -- * Datatypes
-      Ascii
-    , CIAscii
-    , AsciiBuilder
-      -- * Construction
-      -- ** Safe
-    , fromByteString
-    , fromChars
-    , fromText
-      -- ** Unsafe
-    , unsafeFromByteString
-    , unsafeFromString
-    , unsafeFromText
-      -- * Extraction
-    , toByteString
-    , toString
-    , toText
-      -- * Case insensitive
-    , toCIAscii
-    , fromCIAscii
-    , ciToByteString
-      -- * Builder
-    , toAsciiBuilder
-    , fromAsciiBuilder
-    , unsafeFromBuilder
-    , toBuilder
-      -- * Character-level functions and predicates
-    , fromChar
-    , toChar
-    , ascii
-    , isAscii
-    , isControl
-    , isPrintable
-    , isWhiteSpace
-    , isSpaceOrTab
-    , isLower
-    , isUpper
-    , toLower
-    , toUpper
-    , isAlpha
-    , isDigit
-    , isAlphaNum
-    , fromDigit
-    , unsafeFromDigit
-    , fromOctDigit
-    , unsafeFromOctDigit
-    , isUpHexDigit
-    , fromUpHexDigit
-    , unsafeFromUpHexDigit
-    , isLowHexDigit
-    , fromLowHexDigit
-    , unsafeFromLowHexDigit
-    , isHexDigit
-    , fromHexDigit
-    , unsafeFromHexDigit
-    ) where
-
-import Data.Word (Word8)
-import Data.ByteString (ByteString)
-import qualified Data.ByteString as S
-import qualified Data.ByteString.Char8 as S8
-import qualified Data.Char as C
-import Data.String (IsString (..))
-import Data.Data (Data)
-import Data.Hashable (Hashable)
-import Data.Typeable (Typeable)
-import Data.Text (Text)
-import qualified Data.Text as T
-import qualified Data.Text.Encoding as TE
-import qualified Blaze.ByteString.Builder as Blaze
-import Data.Monoid (Monoid)
-import Data.CaseInsensitive (FoldCase, CI, mk, original)
-
-newtype Ascii = Ascii ByteString
-    deriving (Show, Eq, Read, Ord, Data, Typeable, IsString, FoldCase, Hashable, Monoid)
-
-type CIAscii = CI Ascii
-
-fromByteString :: ByteString -> Maybe Ascii
-fromByteString bs
-    | S.all (< 128) bs = Just $ Ascii bs
-    | otherwise = Nothing
-
--- | Renamed to avoid clash with 'fromString'
-fromChars :: String -> Maybe Ascii
-fromChars s
-    | all C.isAscii s = Just $ Ascii $ S8.pack s
-    | otherwise = Nothing
-
-fromText :: Text -> Maybe Ascii
-fromText t
-    | T.all C.isAscii t = Just $ Ascii $ TE.encodeUtf8 t
-    | otherwise = Nothing
-
-unsafeFromByteString :: ByteString -> Ascii
-unsafeFromByteString = Ascii
-
-unsafeFromString :: String -> Ascii
-unsafeFromString = Ascii . S8.pack
-
-unsafeFromText :: Text -> Ascii
-unsafeFromText = Ascii . TE.encodeUtf8
-
-toCIAscii :: Ascii -> CIAscii
-toCIAscii = mk
-
-fromCIAscii :: CIAscii -> Ascii
-fromCIAscii = original
-
-toByteString :: Ascii -> ByteString
-toByteString (Ascii bs) = bs
-
-toString :: Ascii -> String
-toString (Ascii bs) = S8.unpack bs
-
-toText :: Ascii -> Text
-toText (Ascii bs) = TE.decodeASCII bs
-
-ciToByteString :: CIAscii -> ByteString
-ciToByteString = toByteString . original
-
-toAsciiBuilder :: Ascii -> AsciiBuilder
-toAsciiBuilder (Ascii bs) = AsciiBuilder $ Blaze.fromByteString bs
-
-fromAsciiBuilder :: AsciiBuilder -> Ascii
-fromAsciiBuilder (AsciiBuilder b) = Ascii $ Blaze.toByteString b
-
-newtype AsciiBuilder = AsciiBuilder (Blaze.Builder)
-    deriving Monoid
-
-unsafeFromBuilder :: Blaze.Builder -> AsciiBuilder
-unsafeFromBuilder = AsciiBuilder
-
-toBuilder :: AsciiBuilder -> Blaze.Builder
-toBuilder (AsciiBuilder b) = b
-
-fromChar :: Char -> Maybe Word8
-fromChar c = if i < 128 then Just (fromIntegral i) else Nothing
-  where i = C.ord c
-
-toChar :: Word8 -> Char
-toChar = C.chr . fromIntegral
-
--- | Unsafe version of 'fromChar'
-ascii :: Char -> Word8
-ascii = fromIntegral . C.ord
-{-# INLINE ascii #-}
-
-isAscii :: Word8 -> Bool
-isAscii = (< 128)
-
-isControl :: Word8 -> Bool
-isControl w = w < 32 || w == 127
-
-isPrintable :: Word8 -> Bool
-isPrintable w = w >= 32 && w < 127
-
-isWhiteSpace :: Word8 -> Bool
-isWhiteSpace w = w == ascii ' ' || w >= 9 && w <= 13
-
-isSpaceOrTab :: Word8 -> Bool
-isSpaceOrTab w = w == ascii ' ' || w == ascii '\t'
-
-isLower :: Word8 -> Bool
-isLower w = w >= ascii 'a' && w <= ascii 'z'
-
-isUpper :: Word8 -> Bool
-isUpper w = w >= ascii 'A' && w <= ascii 'Z'
-
-toLower :: Word8 -> Word8
-toLower w | isUpper w = w + 32
-          | otherwise = w
-
-toUpper :: Word8 -> Word8
-toUpper w | isLower w = w - 32
-          | otherwise = w
-
-isAlpha :: Word8 -> Bool
-isAlpha w = isUpper w || isLower w
-
-isDigit :: Word8 -> Bool
-isDigit w = w >= ascii '0' && w <= ascii '9'
-
-isAlphaNum :: Word8 -> Bool
-isAlphaNum w = isDigit w || isAlpha w
-
-fromDigit :: Num a => Word8 -> Maybe a
-fromDigit w | isDigit w = Just $ unsafeFromDigit w
-            | otherwise = Nothing
-#if __GLASGOW_HASKELL__ >= 700
-{-# INLINABLE fromDigit #-}
-#endif
-
-unsafeFromDigit :: Num a => Word8 -> a
-unsafeFromDigit w = fromIntegral (w - ascii '0')
-{-# INLINE unsafeFromDigit #-}
-
-isOctDigit :: Word8 -> Bool
-isOctDigit w = w >= ascii '0' && w <= ascii '7'
-
-fromOctDigit :: Num a => Word8 -> Maybe a
-fromOctDigit w | isOctDigit w = Just $ unsafeFromOctDigit w
-               | otherwise    = Nothing
-#if __GLASGOW_HASKELL__ >= 700
-{-# INLINABLE fromOctDigit #-}
-#endif
-
-unsafeFromOctDigit :: Num a => Word8 -> a
-unsafeFromOctDigit = unsafeFromDigit
-{-# INLINE unsafeFromOctDigit #-}
-
-isLowAF :: Word8 -> Bool
-isLowAF w = w >= ascii 'a' && w <= ascii 'f'
-{-# INLINE isLowAF #-}
-
-fromLowAF :: Num a => Word8 -> a
-fromLowAF w = fromIntegral (w - ascii 'a' + 10)
-{-# INLINE fromLowAF #-}
-
-isLowHexDigit :: Word8 -> Bool
-isLowHexDigit w = isDigit w || isLowAF w
-
-fromLowHexDigit :: Num a => Word8 -> Maybe a
-fromLowHexDigit w | isDigit w = Just $ unsafeFromDigit w
-                  | isLowAF w = Just $ fromLowAF w
-                  | otherwise = Nothing
-#if __GLASGOW_HASKELL__ >= 700
-{-# INLINABLE fromLowHexDigit #-}
-#endif
-
-unsafeFromLowHexDigit :: Num a => Word8 -> a
-unsafeFromLowHexDigit w | w < ascii 'a' = unsafeFromDigit w
-                        | otherwise     = fromLowAF w
-{-# INLINE unsafeFromLowHexDigit #-}
-
-isUpAF :: Word8 -> Bool
-isUpAF w = w >= ascii 'A' && w <= ascii 'F'
-{-# INLINE isUpAF #-}
-
-fromUpAF :: Num a => Word8 -> a
-fromUpAF w = fromIntegral (w - ascii 'A' + 10)
-{-# INLINE fromUpAF #-}
-
-isUpHexDigit :: Word8 -> Bool
-isUpHexDigit w = isDigit w || isUpAF w
-
-fromUpHexDigit :: Num a => Word8 -> Maybe a
-fromUpHexDigit w | isDigit w = Just $ unsafeFromDigit w
-                 | isUpAF w  = Just $ fromUpAF w
-                 | otherwise = Nothing
-#if __GLASGOW_HASKELL__ >= 700
-{-# INLINABLE fromUpHexDigit #-}
-#endif
-
-unsafeFromUpHexDigit :: Num a => Word8 -> a
-unsafeFromUpHexDigit w | w < ascii 'A' = unsafeFromDigit w
-                       | otherwise     = fromUpAF w
-{-# INLINE unsafeFromUpHexDigit #-}
-
-isHexDigit :: Word8 -> Bool
-isHexDigit w = isDigit w || isUpAF w || isLowAF w
-
-fromHexDigit :: Num a => Word8 -> Maybe a
-fromHexDigit w | isDigit w = Just $ unsafeFromDigit w
-               | isUpAF w  = Just $ fromUpAF w
-               | isLowAF w = Just $ fromLowAF w
-               | otherwise = Nothing
-#if __GLASGOW_HASKELL__ >= 700
-{-# INLINABLE fromHexDigit #-}
-#endif
-
-unsafeFromHexDigit :: Num a => Word8 -> a
-unsafeFromHexDigit w | w < ascii 'A' = unsafeFromDigit w
-                     | w < ascii 'a' = fromUpAF w
-                     | otherwise     = fromLowAF w
-{-# INLINE unsafeFromHexDigit #-}
-
+module Data.Ascii+    ( -- * Datatypes+      Ascii+    , CIAscii+    , AsciiBuilder+      -- * Construction+      -- ** Safe+    , fromByteString+    , fromChars+    , fromText+      -- ** Unsafe+    , unsafeFromByteString+    , unsafeFromString+    , unsafeFromText+      -- * Extraction+    , toByteString+    , toString+    , toText+      -- * Case insensitive+    , toCIAscii+    , fromCIAscii+    , ciToByteString+      -- * Builder+    , toAsciiBuilder+    , fromAsciiBuilder+    , unsafeFromBuilder+    , toBuilder+      -- * Character-level functions and predicates+    , fromChar+    , toChar+    , ascii+    , isAscii+    , isControl+    , isPrintable+    , isWhiteSpace+    , isSpaceOrTab+    , isLower+    , isUpper+    , toLower+    , toUpper+    , isAlpha+    , isDigit+    , isAlphaNum+    , fromDigit+    , unsafeFromDigit+    , fromOctDigit+    , unsafeFromOctDigit+    , isUpHexDigit+    , fromUpHexDigit+    , unsafeFromUpHexDigit+    , isLowHexDigit+    , fromLowHexDigit+    , unsafeFromLowHexDigit+    , isHexDigit+    , fromHexDigit+    , unsafeFromHexDigit+    ) where++import Data.Ascii.Blaze+import Data.Ascii.ByteString+import Data.Ascii.Word8
+ Data/Ascii/Blaze.hs view
@@ -0,0 +1,23 @@+{-# LANGUAGE GeneralizedNewtypeDeriving #-}++module Data.Ascii.Blaze where++import Data.Ascii.ByteString++-- blaze-builder+import qualified Blaze.ByteString.Builder as Blaze++newtype AsciiBuilder = AsciiBuilder (Blaze.Builder)+    deriving (Semigroup, Monoid)++unsafeFromBuilder :: Blaze.Builder -> AsciiBuilder+unsafeFromBuilder = AsciiBuilder++toBuilder :: AsciiBuilder -> Blaze.Builder+toBuilder (AsciiBuilder b) = b++toAsciiBuilder :: Ascii -> AsciiBuilder+toAsciiBuilder (Ascii bs) = AsciiBuilder $ Blaze.fromByteString bs++fromAsciiBuilder :: AsciiBuilder -> Ascii+fromAsciiBuilder (AsciiBuilder b) = Ascii $ Blaze.toByteString b
+ Data/Ascii/ByteString.hs view
@@ -0,0 +1,73 @@+{-# LANGUAGE DeriveDataTypeable, GeneralizedNewtypeDeriving #-}++module Data.Ascii.ByteString where++-- base+import Data.Data (Data)+import Data.Typeable (Typeable)+import Data.String (IsString (..))+import qualified Data.Char as C++-- bytestring+import qualified Data.ByteString as S+import qualified Data.ByteString.Char8 as S8+import Data.ByteString (ByteString)++-- case-insensitive+import Data.CaseInsensitive (FoldCase, CI, mk, original)++-- hashable+import Data.Hashable (Hashable)++-- text+import Data.Text (Text)+import qualified Data.Text as T+import qualified Data.Text.Encoding as TE++newtype Ascii = Ascii ByteString+    deriving (Show, Eq, Read, Ord, Data, Typeable, IsString, FoldCase, Hashable, Semigroup, Monoid)++type CIAscii = CI Ascii++fromByteString :: ByteString -> Maybe Ascii+fromByteString bs+    | S.all (< 128) bs = Just $ Ascii bs+    | otherwise = Nothing++-- | Renamed to avoid clash with 'fromString'+fromChars :: String -> Maybe Ascii+fromChars s+    | all C.isAscii s = Just $ Ascii $ S8.pack s+    | otherwise = Nothing++fromText :: Text -> Maybe Ascii+fromText t+    | T.all C.isAscii t = Just $ Ascii $ TE.encodeUtf8 t+    | otherwise = Nothing++unsafeFromByteString :: ByteString -> Ascii+unsafeFromByteString = Ascii++unsafeFromString :: String -> Ascii+unsafeFromString = Ascii . S8.pack++unsafeFromText :: Text -> Ascii+unsafeFromText = Ascii . TE.encodeUtf8++toCIAscii :: Ascii -> CIAscii+toCIAscii = mk++fromCIAscii :: CIAscii -> Ascii+fromCIAscii = original++toByteString :: Ascii -> ByteString+toByteString (Ascii bs) = bs++toString :: Ascii -> String+toString (Ascii bs) = S8.unpack bs++toText :: Ascii -> Text+toText (Ascii bs) = TE.decodeUtf8 bs++ciToByteString :: CIAscii -> ByteString+ciToByteString = toByteString . original
+ Data/Ascii/Word8.hs view
@@ -0,0 +1,148 @@+{-# LANGUAGE CPP #-}++module Data.Ascii.Word8 where++-- base+import Data.Word (Word8)+import qualified Data.Char as C++fromChar :: Char -> Maybe Word8+fromChar c = if i < 128 then Just (fromIntegral i) else Nothing+  where i = C.ord c++toChar :: Word8 -> Char+toChar = C.chr . fromIntegral++-- | Unsafe version of 'fromChar'+ascii :: Char -> Word8+ascii = fromIntegral . C.ord+{-# INLINE ascii #-}++isAscii :: Word8 -> Bool+isAscii = (< 128)++isControl :: Word8 -> Bool+isControl w = w < 32 || w == 127++isPrintable :: Word8 -> Bool+isPrintable w = w >= 32 && w < 127++isWhiteSpace :: Word8 -> Bool+isWhiteSpace w = w == ascii ' ' || w >= 9 && w <= 13++isSpaceOrTab :: Word8 -> Bool+isSpaceOrTab w = w == ascii ' ' || w == ascii '\t'++isLower :: Word8 -> Bool+isLower w = w >= ascii 'a' && w <= ascii 'z'++isUpper :: Word8 -> Bool+isUpper w = w >= ascii 'A' && w <= ascii 'Z'++toLower :: Word8 -> Word8+toLower w | isUpper w = w + 32+          | otherwise = w++toUpper :: Word8 -> Word8+toUpper w | isLower w = w - 32+          | otherwise = w++isAlpha :: Word8 -> Bool+isAlpha w = isUpper w || isLower w++isDigit :: Word8 -> Bool+isDigit w = w >= ascii '0' && w <= ascii '9'++isAlphaNum :: Word8 -> Bool+isAlphaNum w = isDigit w || isAlpha w++fromDigit :: Num a => Word8 -> Maybe a+fromDigit w | isDigit w = Just $ unsafeFromDigit w+            | otherwise = Nothing+#if __GLASGOW_HASKELL__ >= 700+{-# INLINABLE fromDigit #-}+#endif++unsafeFromDigit :: Num a => Word8 -> a+unsafeFromDigit w = fromIntegral (w - ascii '0')+{-# INLINE unsafeFromDigit #-}++isOctDigit :: Word8 -> Bool+isOctDigit w = w >= ascii '0' && w <= ascii '7'++fromOctDigit :: Num a => Word8 -> Maybe a+fromOctDigit w | isOctDigit w = Just $ unsafeFromOctDigit w+               | otherwise    = Nothing+#if __GLASGOW_HASKELL__ >= 700+{-# INLINABLE fromOctDigit #-}+#endif++unsafeFromOctDigit :: Num a => Word8 -> a+unsafeFromOctDigit = unsafeFromDigit+{-# INLINE unsafeFromOctDigit #-}++isLowAF :: Word8 -> Bool+isLowAF w = w >= ascii 'a' && w <= ascii 'f'+{-# INLINE isLowAF #-}++fromLowAF :: Num a => Word8 -> a+fromLowAF w = fromIntegral (w - ascii 'a' + 10)+{-# INLINE fromLowAF #-}++isLowHexDigit :: Word8 -> Bool+isLowHexDigit w = isDigit w || isLowAF w++fromLowHexDigit :: Num a => Word8 -> Maybe a+fromLowHexDigit w | isDigit w = Just $ unsafeFromDigit w+                  | isLowAF w = Just $ fromLowAF w+                  | otherwise = Nothing+#if __GLASGOW_HASKELL__ >= 700+{-# INLINABLE fromLowHexDigit #-}+#endif++unsafeFromLowHexDigit :: Num a => Word8 -> a+unsafeFromLowHexDigit w | w < ascii 'a' = unsafeFromDigit w+                        | otherwise     = fromLowAF w+{-# INLINE unsafeFromLowHexDigit #-}++isUpAF :: Word8 -> Bool+isUpAF w = w >= ascii 'A' && w <= ascii 'F'+{-# INLINE isUpAF #-}++fromUpAF :: Num a => Word8 -> a+fromUpAF w = fromIntegral (w - ascii 'A' + 10)+{-# INLINE fromUpAF #-}++isUpHexDigit :: Word8 -> Bool+isUpHexDigit w = isDigit w || isUpAF w++fromUpHexDigit :: Num a => Word8 -> Maybe a+fromUpHexDigit w | isDigit w = Just $ unsafeFromDigit w+                 | isUpAF w  = Just $ fromUpAF w+                 | otherwise = Nothing+#if __GLASGOW_HASKELL__ >= 700+{-# INLINABLE fromUpHexDigit #-}+#endif++unsafeFromUpHexDigit :: Num a => Word8 -> a+unsafeFromUpHexDigit w | w < ascii 'A' = unsafeFromDigit w+                       | otherwise     = fromUpAF w+{-# INLINE unsafeFromUpHexDigit #-}++isHexDigit :: Word8 -> Bool+isHexDigit w = isDigit w || isUpAF w || isLowAF w++fromHexDigit :: Num a => Word8 -> Maybe a+fromHexDigit w | isDigit w = Just $ unsafeFromDigit w+               | isUpAF w  = Just $ fromUpAF w+               | isLowAF w = Just $ fromLowAF w+               | otherwise = Nothing+#if __GLASGOW_HASKELL__ >= 700+{-# INLINABLE fromHexDigit #-}+#endif++unsafeFromHexDigit :: Num a => Word8 -> a+unsafeFromHexDigit w | w < ascii 'A' = unsafeFromDigit w+                     | w < ascii 'a' = fromUpAF w+                     | otherwise     = fromLowAF w+{-# INLINE unsafeFromHexDigit #-}
LICENSE view
@@ -1,30 +1,30 @@-Copyright Michael Snoyman 2011
-
-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.
-
-    * Neither the name of Michael Snoyman nor the names of other
-      contributors may be used to endorse or promote products derived
-      from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"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
-OWNER OR CONTRIBUTORS 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.
+Copyright Michael Snoyman 2011, Typeclass Consulting LLC 2018++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.++    * Neither the name of Michael Snoyman nor the names of other+      contributors may be used to endorse or promote products derived+      from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"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+OWNER OR CONTRIBUTORS 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.hs view
@@ -1,3 +1,3 @@-#!/usr/bin/env runhaskell
-import Distribution.Simple
-main = defaultMain
+#!/usr/bin/env runhaskell+import Distribution.Simple+main = defaultMain
ascii.cabal view
@@ -1,28 +1,31 @@-Name:                ascii
-Version:             0.0.4.1
-Synopsis:            Type-safe, bytestring-based ASCII values. (deprecated)
-Description:         Type-safe, bytestring-based ASCII values.
-License:             BSD3
-License-file:        LICENSE
-Author:              Michael Snoyman
-Maintainer:          michael@snoyman.com
-Stability:           Stable
-Category:            Data
-Homepage:            https://github.com/snoyberg/ascii
-Bug-Reports:         https://github.com/snoyberg/ascii/issues
-Build-type:          Simple
-Cabal-version:       >= 1.6
-
-Source-Repository head
-    Type:     git
-    Location: git://github.com/snoyberg/ascii.git
-
-Library
-  Exposed-modules:     Data.Ascii
-  Build-depends:       base             >= 4             && < 5
-                     , bytestring       >= 0.9           && < 0.10
-                     , text             >= 0.11          && < 0.12
-                     , blaze-builder    >= 0.2.1.4       && < 0.4
-                     , case-insensitive >= 0.2           && < 0.5
-                     , hashable         >= 1.0           && < 1.2
-  Ghc-options:         -Wall
+Name:                ascii+Version:             0.0.5+Synopsis:            Type-safe, bytestring-based ASCII values.+Description:         Type-safe, bytestring-based ASCII values.+License:             BSD3+License-file:        LICENSE+Author:              Michael Snoyman+Maintainer:          Chris Martin, Julie Moronuki+Stability:           Stable+Category:            Data+Homepage:            https://github.com/typeclasses/ascii+Bug-Reports:         https://github.com/typeclasses/ascii/issues+Build-type:          Simple+Cabal-version:       >= 1.6++Source-Repository head+    Type:     git+    Location: git://github.com/typeclasses/ascii.git++Library+  Exposed-modules:     Data.Ascii+                     , Data.Ascii.Blaze+                     , Data.Ascii.ByteString+                     , Data.Ascii.Word8+  Build-depends:       base             >= 4             && < 5+                     , bytestring       >= 0.9           && < 0.11+                     , text             >= 0.11          && < 1.3+                     , blaze-builder    >= 0.2.1.4       && < 0.5+                     , case-insensitive >= 0.2           && < 1.3+                     , hashable         >= 1.0           && < 1.3+  Ghc-options:         -Wall