Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add instance Out for Text since it is in ghc now #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions GenericPretty.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Name: GenericPretty
-- The package version. See the Haskell package versioning policy
-- (http://www.haskell.org/haskellwiki/Package_versioning_policy) for
-- standards guiding when and how versions should be incremented.
Version: 1.2.2
Version: 1.2.3

-- A short (one-line) description of the package.
Synopsis: A generic, derivable, haskell pretty printer.
Expand Down Expand Up @@ -86,7 +86,7 @@ Library
Exposed-modules: Text.PrettyPrint.GenericPretty

-- Packages needed in order to build this package.
Build-depends: base >= 3 && < 5, ghc-prim, pretty
Build-depends: base >= 3 && < 5, ghc-prim, pretty, text

-- Modules not exported by this package.
-- Other-modules:
Expand Down
4 changes: 2 additions & 2 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ If you have cabal, you can simply do:
Otherwise, the steps are:
0. Make sure you have a version of ghc >= 7.4 installed and that you can
use the 'runhaskell' command from the command line.
1. Download and unpack "GenericPretty-1.2.2.tar.gz"
1. Download and unpack "GenericPretty-1.2.3.tar.gz"
2. Move to the correct directory:
$ cd GenericPretty-1.2.2
$ cd GenericPretty-1.2.3
3. Run the following haskell commands to install the library globally:
$ runhaskell Setup configure
$ runhaskell Setup build
Expand Down
9 changes: 7 additions & 2 deletions Text/PrettyPrint/GenericPretty.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ module Text.PrettyPrint.GenericPretty
-- Avoid name clash with Prelude.<> exported by post-SMP versions of base.
import Prelude hiding ( (<>) )
#endif
import Data.Char
import Data.List
import Data.Text (Text, unpack)
import GHC.Generics
import Data.Char
import Text.PrettyPrint

-- | The class 'Out' is the equivalent of 'Prelude.Show'
Expand Down Expand Up @@ -407,6 +408,10 @@ instance Out Bool where
doc False = text "False"
docPrec _ = doc

instance Out Text where
doc = doc . unpack
docPrec n = docPrec n . unpack

instance Out a => Out (Maybe a) where
docPrec n Nothing = text "Nothing"
docPrec n (Just x)
Expand Down Expand Up @@ -457,4 +462,4 @@ instance (Out a, Out b, Out c, Out d, Out e, Out f, Out g)
doc (a, b, c, d, e, f, g) =
parens (sep [ doc a <> comma, doc b <> comma, doc c <> comma,
doc d <> comma, doc e <> comma, doc f <> comma, doc g])
docPrec _ = doc
docPrec _ = doc