packages feed

hex 0.1.2 → 0.2.0

raw patch · 2 files changed

+22/−12 lines, 2 filesdep ~base

Dependency ranges changed: base

Files

Data/Hex.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE TypeSynonymInstances #-} ----------------------------------------------------------------------------- -- |@@ -13,7 +14,7 @@ ----------------------------------------------------------------------------- module Data.Hex(Hex(..)) where -import Control.Monad+import Control.Monad (liftM) import qualified Data.ByteString.Char8 as B import qualified Data.ByteString.Lazy.Char8 as L @@ -22,8 +23,10 @@     -- | Convert string into hexadecimal.     hex   :: t -> t     -- | Convert from hexadecimal and fail on invalid input.-    unhex :: Monad m => t -> m t-+    unhex :: t -> Either String t+    -- | Convert from hexadecimal and fail on invalud input.+    unhexM :: MonadFail m => t -> m t+    unhexM = either fail return . unhex  instance Hex String where     hex = Prelude.concatMap w@@ -34,10 +37,10 @@     unhex (a:b:r) = do x <- c a                        y <- c b                        liftM (toEnum ((x * 16) + y) :) $ unhex r-    unhex [_]      = fail "Non-even length"+    unhex [_]      = Left "Non-even length"  -c :: Monad m => Char -> m Int+c :: Char -> Either String Int c '0' = return 0 c '1' = return 1 c '2' = return 2@@ -60,7 +63,7 @@ c 'd' = return 13 c 'e' = return 14 c 'f' = return 15-c _   = fail "Invalid hex digit!"+c _   = Left "Invalid hex digit!"  instance Hex B.ByteString where     hex = B.pack . hex . B.unpack
hex.cabal view
@@ -1,15 +1,22 @@+Cabal-Version:       >= 1.10+ Name:                hex-Version:             0.1.2+Version:             0.2.0 Synopsis:            Convert strings into hexadecimal and back.-Description:         Convert strings into hexadecimal and back.+Description:         Convert strings and bytestrings into hexadecimal and back. License:             BSD3 License-file:        COPYING Copyright:           Taru Karttunen <taruti@taruti.net> Author:              Taru Karttunen Category:            Data Maintainer:          taruti@taruti.net-Build-Depends:       base >= 3 && < 5, bytestring-Exposed-modules:     Data.Hex-Extensions:          TypeSynonymInstances FlexibleInstances-GHC-Options:         -Wall Build-Type:	     Simple+Homepage:            https://github.com/taruti/haskell-hex++library+  Build-Depends:       base >= 4.10 && < 5, bytestring+  Exposed-modules:     Data.Hex+  Default-Extensions:  TypeSynonymInstances+  GHC-Options:         -Wall+  Default-Language:    Haskell2010+