packages feed

handle-like 0.0.0.14 → 0.1.0.0

raw patch · 2 files changed

+24/−5 lines, 2 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Data.HandleLike: DebugHandle :: h -> (Maybe (DebugLevel h)) -> DebugHandle h
+ Data.HandleLike: data DebugHandle h
+ Data.HandleLike: instance Bounded Priority
+ Data.HandleLike: instance HandleLike h => HandleLike (DebugHandle h)
- Data.HandleLike: class (Monad (HandleMonad h), IsString (DebugLevel h), Ord (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 (Monad (HandleMonad h), IsString (DebugLevel h), Ord (DebugLevel h), Bounded (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 view
@@ -2,7 +2,7 @@ build-type:	Simple  name:		handle-like-version:	0.0.0.14+version:	0.1.0.0 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.14+    tag:	handle-like-0.1.0.0  library     hs-source-dirs:	src
src/Data/HandleLike.hs view
@@ -1,6 +1,7 @@ {-# LANGUAGE OverloadedStrings, TypeFamilies, FlexibleContexts #-} -module Data.HandleLike (HandleLike(..), hlPutStrLn) where+module Data.HandleLike (+	HandleLike(..), hlPutStrLn, DebugHandle(..)) where  import Control.Monad import Data.Word@@ -11,7 +12,7 @@ import System.IO  class (Monad (HandleMonad h),-	IsString (DebugLevel h), Ord (DebugLevel h)) =>+	IsString (DebugLevel h), Ord (DebugLevel h), Bounded (DebugLevel h)) => 	HandleLike h where 	type HandleMonad h 	type DebugLevel h@@ -41,7 +42,7 @@ hlPutStrLn h = hlPut h . (`BS.append` "\n")  data Priority = Low | Moderate | High | Critical-	deriving (Show, Read, Eq, Ord, Enum)+	deriving (Show, Read, Eq, Ord, Enum, Bounded)  instance IsString Priority where 	fromString s = case takeWhile (/= ':') s of@@ -67,3 +68,21 @@ 	| BS.null bs = "" 	| BSC.last bs == '\r' = BSC.init bs 	| otherwise = bs++data DebugHandle h = DebugHandle h (Maybe (DebugLevel h))++instance HandleLike h => HandleLike (DebugHandle h) where+	type HandleMonad (DebugHandle h) = HandleMonad h+	type DebugLevel (DebugHandle h) = DebugLevel h+	hlPut (DebugHandle h _) = hlPut h+	hlGet (DebugHandle h _) = hlGet h+	hlGetByte (DebugHandle h _) = hlGetByte h+	hlGetLine (DebugHandle h _) = hlGetLine h+	hlGetContent (DebugHandle h _) = hlGetContent h+	hlFlush (DebugHandle h _) = hlFlush h+	hlClose (DebugHandle h _) = hlClose h+	hlDebug (DebugHandle _ Nothing) _ = const $ return ()+	hlDebug (DebugHandle h (Just dl0)) dl+		| dl >= dl0 = hlDebug h maxBound+		| otherwise = const $ return ()+	hlError (DebugHandle h _) = hlError h