summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorclinton <>2018-01-14 11:05:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2018-01-14 11:05:00 (GMT)
commita5dd91f24bb30bccc0ad6acb658836cdfe7bac60 (patch)
tree2c602184bc201148b6cdf4ebc4895313df8f3d18
parent73ec45d8375d65a08a77630ac09045145934afef (diff)
version 0.1.0.1HEAD0.1.0.1master
-rw-r--r--io-string-like.cabal6
-rw-r--r--src/System/IO/StringLike/Impl.hs34
2 files changed, 10 insertions, 30 deletions
diff --git a/io-string-like.cabal b/io-string-like.cabal
index b4a3400..f34c78b 100644
--- a/io-string-like.cabal
+++ b/io-string-like.cabal
@@ -2,14 +2,14 @@
--
-- see: https://github.com/sol/hpack
--
--- hash: 6d2238ec61b205b3bc42dee2863a5ec675ee3ea54b2cf1a906749d83ff7e4704
+-- hash: b851dfc4cd9f6bbbde0424b61d304741d6b63c230fd74572b2a43bbcc494d3f7
name: io-string-like
-version: 0.1.0.0
+version: 0.1.0.1
synopsis: Classes to handle Prelude style IO functions for different datatypes
description: The functions in the Prelude such as "getContents", "putStr" only work for plain Strings.
.
- There are similar functions in "ByteString" for reading and writing, as well as "Text".
+ There are similar functions in "ByteString" for reading and writing, as well as \"Text\".
.
This requires one to import the appropriate functions, usually qualified, for the particular datatype one is using. Changing the datatype at the very least involves changing import statements across your program.
.
diff --git a/src/System/IO/StringLike/Impl.hs b/src/System/IO/StringLike/Impl.hs
index c6a026d..4914323 100644
--- a/src/System/IO/StringLike/Impl.hs
+++ b/src/System/IO/StringLike/Impl.hs
@@ -84,23 +84,9 @@ import qualified Data.Text.Lazy.Builder as TB
--------------------------
{-|
-'CanGetContents' if effectively the following type synonym, for the common case of
-an ordinary 'Handle' in the 'IO' monad like so.
-
-> type CanGetContents t = CanGetContentsClass IO Handle t
-
-The reason why it's defined as a class with a catch all instance instead is so
-modules which use 'CanGetContents' do not have to include the language pragma "FleixbleContexts".
-
-However, this approach requires this module to use the pragma "UndecidableInstances",
-but I figure it's better to add more complexity to the library than to clients.
-
-'CanGet', 'CanGetLine', 'CanPutStr', 'CanPutStrLn' all are similar synonyms with
-the same explanation for their definition so I won't repeat myself.
+Type synonym, for the common case of an ordinary 'Handle' in the 'IO'.
-}
---type CanGetContents t = CanGetContentsClass IO Handle t
-class CanGetContentsClass IO Handle t => CanGetContents t
-instance CanGetContentsClass IO Handle t => CanGetContents t
+type CanGetContents t = CanGetContentsClass IO Handle t
class Monad m => CanGetContentsClass m handleT t where
{-| Generalised 'System.IO.hGetContents' -}
@@ -121,10 +107,8 @@ instance (m ~ IO, CanGetContentsClass m Handle t) => CanGetContentsClass m FileP
-- CanGetLine class --
----------------------
-{-| Effective type synonym for 'CanGetLineClass'. See 'CanGetContents' for more details. -}
---type CanGetLine t = CanGetLineClass IO Handle t
-class CanGetLineClass IO Handle t => CanGetLine t
-instance CanGetLineClass IO Handle t => CanGetLine t
+{-| Type synonym for 'CanGetLineClass'. See 'CanGetContents' for more details. -}
+type CanGetLine t = CanGetLineClass IO Handle t
class CanGetContentsClass m handleT t => CanGetLineClass m handleT t where
{-| Generalised 'System.IO.hGetLine' -}
@@ -139,10 +123,8 @@ getLine = hGetLine IO.stdin
-- CanPutStr class --
------------------
-{-| Effective type synonym for 'CanPutStrClass'. See 'CanGetContents' for more details. -}
---type CanPutStr t = CanPutStrClass IO Handle t
-class CanPutStrClass IO Handle t => CanPutStr t
-instance CanPutStrClass IO Handle t => CanPutStr t
+{-| Type synonym for 'CanPutStrClass'. See 'CanGetContents' for more details. -}
+type CanPutStr t = CanPutStrClass IO Handle t
class Monad m => CanPutStrClass m handleT t where
{-| Generalised 'System.IO.hPutStr' -}
@@ -170,9 +152,7 @@ instance (m ~ IO, CanPutStrClass m Handle t) => CanPutStrClass m FilePath t wher
-------------------------
{-| Effective type synonym for 'CanPutStrLnClass'. See 'CanGetContents' for more details. -}
---type CanPutStrLn t = CanPutStrLnClass IO Handle t
-class CanPutStrLnClass IO Handle t => CanPutStrLn t
-instance CanPutStrLnClass IO Handle t => CanPutStrLn t
+type CanPutStrLn t = CanPutStrLnClass IO Handle t
class CanPutStrClass m handleT t => CanPutStrLnClass m handleT t where
{-| Generalised 'System.IO.hPutStrLn' -}