handle-like 0.0.0.11 → 0.0.0.12
raw patch · 3 files changed
+19/−5 lines, 3 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
+ Data.HandleLike.Class: Critical :: Priority
+ Data.HandleLike.Class: High :: Priority
+ Data.HandleLike.Class: Low :: Priority
+ Data.HandleLike.Class: Moderate :: Priority
+ Data.HandleLike.Class: data Priority
+ Data.HandleLike.Class: instance Enum Priority
+ Data.HandleLike.Class: instance IsString Priority
+ Data.HandleLike.Class: instance Read Priority
+ Data.HandleLike.Class: instance Show Priority
- Data.HandleLike: class (Monad (HandleMonad h), Num (DebugLevel h)) => HandleLike h where type family HandleMonad h type family DebugLevel h type instance DebugLevel h = Int hlGetByte h = do { [b] <- unpack `liftM` hlGet h 1; return b } hlGetLine h = do { b <- hlGetByte h; case b of { 10 -> return "" _ -> cons b `liftM` hlGetLine h } } hlGetContent = flip hlGet 1 hlFlush _ = return () hlDebug _ _ _ = return () hlError _ msg = error $ unpack msg
+ Data.HandleLike: class (Monad (HandleMonad h), IsString (DebugLevel h)) => HandleLike h where type family HandleMonad h type family DebugLevel h type instance DebugLevel h = Priority hlGetByte h = do { [b] <- unpack `liftM` hlGet h 1; return b } hlGetLine h = do { b <- hlGetByte h; case b of { 10 -> return "" _ -> cons b `liftM` hlGetLine h } } hlGetContent = flip hlGet 1 hlFlush _ = return () hlDebug _ _ _ = return () hlError _ msg = error $ unpack msg
- Data.HandleLike.Class: class (Monad (HandleMonad h), Num (DebugLevel h)) => HandleLike h where type family HandleMonad h type family DebugLevel h type instance DebugLevel h = Int hlGetByte h = do { [b] <- unpack `liftM` hlGet h 1; return b } hlGetLine h = do { b <- hlGetByte h; case b of { 10 -> return "" _ -> cons b `liftM` hlGetLine h } } hlGetContent = flip hlGet 1 hlFlush _ = return () hlDebug _ _ _ = return () hlError _ msg = error $ unpack msg
+ Data.HandleLike.Class: class (Monad (HandleMonad h), IsString (DebugLevel h)) => HandleLike h where type family HandleMonad h type family DebugLevel h type instance DebugLevel h = Priority hlGetByte h = do { [b] <- unpack `liftM` hlGet h 1; return b } hlGetLine h = do { b <- hlGetByte h; case b of { 10 -> return "" _ -> cons b `liftM` hlGetLine h } } hlGetContent = flip hlGet 1 hlFlush _ = return () hlDebug _ _ _ = return () hlError _ msg = error $ unpack msg
Files
- handle-like.cabal +2/−2
- src/Data/HandleLike/Class.hs +16/−3
- src/Data/HandleLike/Instance/Handle.hs +1/−0
handle-like.cabal view
@@ -2,7 +2,7 @@ build-type: Simple name: handle-like-version: 0.0.0.11+version: 0.0.0.12 stability: Experimental author: Yoshikuni Jujo <PAF01143@nifty.ne.jp> maintainer: Yoshikuni Jujo <PAF01143@nifty.ne.jp>@@ -38,7 +38,7 @@ source-repository this type: git location: git://github.com/YoshikuniJujo/forest- tag: handle-like-0.0.0.11+ tag: handle-like-0.0.0.12 library hs-source-dirs: src
src/Data/HandleLike/Class.hs view
@@ -1,13 +1,17 @@ {-# LANGUAGE OverloadedStrings, TypeFamilies, FlexibleContexts #-} -module Data.HandleLike.Class (HandleLike(..), hlPutStrLn) where+module Data.HandleLike.Class (+ HandleLike(..),+ Priority(..),+ hlPutStrLn ) where import Control.Monad import Data.Word import qualified Data.ByteString as BS import qualified Data.ByteString.Char8 as BSC+import Data.String -class (Monad (HandleMonad h), Num (DebugLevel h)) =>+class (Monad (HandleMonad h), IsString (DebugLevel h)) => HandleLike h where type HandleMonad h type DebugLevel h@@ -21,7 +25,7 @@ hlDebug :: h -> DebugLevel h -> BS.ByteString -> HandleMonad h () hlError :: h -> BS.ByteString -> HandleMonad h a - type DebugLevel h = Int+ type DebugLevel h = Priority hlGetByte h = do [b] <- BS.unpack `liftM` hlGet h 1; return b hlGetLine h = do b <- hlGetByte h@@ -35,3 +39,12 @@ hlPutStrLn :: HandleLike h => h -> BS.ByteString -> HandleMonad h () hlPutStrLn h = hlPut h . (`BS.append` "\n")++data Priority = Low | Moderate | High | Critical deriving (Show, Read, Enum)++instance IsString Priority where+ fromString s = case takeWhile (/= ':') s of+ "low" -> Low+ "high" -> High+ "critical" -> Critical+ _ -> Moderate
src/Data/HandleLike/Instance/Handle.hs view
@@ -16,6 +16,7 @@ -- hlGetByte h = do [b] <- BS.unpack <$> BS.hGet h 1; return b hlGetLine = (chopCR `liftM`) . BS.hGetLine -- hlGetContent = flip BS.hGet 1+ hlDebug _ Low = const $ return () hlDebug _ _ = BS.hPutStr stderr hlFlush = hFlush hlClose = hClose