├── .travis.yml ├── LICENSE ├── README.md ├── constraints ├── ghci-pretty.cabal └── src └── Text └── Show └── Pretty └── Colored.hs /.travis.yml: -------------------------------------------------------------------------------- 1 | language: haskell 2 | ghc: 3 | - 7.6 4 | - 7.8 5 | 6 | install: 7 | - cabal install happy && cabal install --only-dependencies --enable-tests 8 | 9 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014, Lars Kuhtz 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Build Status](https://travis-ci.org/larskuhtz/ghci-pretty.svg?branch=master)](https://travis-ci.org/larskuhtz/ghci-pretty) 2 | 3 | A tiny package that combines the [ipprint](https://hackage.haskell.org/package/ipprint) 4 | package and the [hscolour](https://hackage.haskell.org/package/hscolour) 5 | package to provide colored pretty-printing in ghci. 6 | 7 | Here is all the code from this package: 8 | 9 | ```.haskell 10 | module IPPrint.Colored 11 | ( cpprint 12 | ) where 13 | 14 | import IPPrint 15 | import Language.Haskell.HsColour 16 | import Language.Haskell.HsColour.Colourise 17 | import Language.Haskell.HsColour.Output 18 | 19 | cpprint :: Show a => a -> IO () 20 | cpprint = putStrLn . hscolour (TTYg XTerm256Compatible) defaultColourPrefs False False "" False . pshow 21 | ``` 22 | 23 | Usage 24 | ===== 25 | 26 | ```.haskell 27 | cabal update 28 | cabal install ghci-pretty 29 | ``` 30 | 31 | Add the following lines to your `ghci.conf` file: 32 | 33 | ```.haskell 34 | -- Pretty printing of it 35 | import IPPrint.Colored 36 | :set -interactive-print=IPPrint.Colored.cpprint 37 | :def cp (\_ -> return ":set -interactive-print=IPPrint.Colored.cpprint") 38 | :def ncp (\_ -> return ":set -interactive-print=print") 39 | ``` 40 | 41 | Now you can enable colored pretty-printing in ghci with the commmand 42 | 43 | ```.haskell 44 | :cp 45 | ``` 46 | 47 | The following command turns colored pretty-printing off again 48 | 49 | ```.haskell 50 | :ncp 51 | ``` 52 | -------------------------------------------------------------------------------- /constraints: -------------------------------------------------------------------------------- 1 | constraints: Extra ==1.46.3, 2 | HUnit ==1.2.5.2, 3 | QuickCheck ==2.7.6, 4 | Unixutils ==1.52, 5 | array ==0.5.0.0, 6 | base ==4.7.0.1, 7 | binary ==0.7.1.0, 8 | bytestring ==0.10.4.0, 9 | bzlib ==0.5.0.4, 10 | cereal ==0.4.0.1, 11 | containers ==0.5.5.1, 12 | crypto-api ==0.13.2, 13 | deepseq ==1.3.0.2, 14 | directory ==1.2.1.0, 15 | entropy ==0.3.2, 16 | filepath ==1.3.0.2, 17 | ghc-prim ==0.3.1.0, 18 | ghci-pretty ==0.0.1, 19 | haskell-src ==1.0.1.6, 20 | hscolour ==1.20.3, 21 | integer-gmp ==0.5.1.0, 22 | ipprint ==0.5, 23 | mtl ==2.2.1, 24 | network-uri ==2.6.0.1, 25 | old-locale ==1.0.0.6, 26 | old-time ==1.1.0.2, 27 | parsec ==3.1.7, 28 | pretty ==1.1.1.1, 29 | primitive ==0.5.3.0, 30 | process ==1.2.0.0, 31 | pureMD5 ==2.1.2.1, 32 | random ==1.0.1.1, 33 | regex-base ==0.93.2, 34 | regex-compat ==0.95.1, 35 | regex-posix ==0.95.2, 36 | regex-tdfa ==1.2.0, 37 | rts ==1.0, 38 | syb ==0.4.2, 39 | tagged ==0.7.2, 40 | template-haskell ==2.9.0.0, 41 | text ==1.1.1.3, 42 | tf-random ==0.5, 43 | time ==1.4.2, 44 | transformers ==0.4.1.0, 45 | unix ==2.7.0.1, 46 | zlib ==0.5.4.1 47 | -------------------------------------------------------------------------------- /ghci-pretty.cabal: -------------------------------------------------------------------------------- 1 | Name: ghci-pretty 2 | Version: 0.1.0 3 | Synopsis: colored pretty-printing within ghci 4 | description: 5 | A tiny package that combines the ipprint package and 6 | the hscolour package to provide colored pretty-printing 7 | in ghci. 8 | . 9 | /Usage/ 10 | . 11 | Add the following lines to your @ghci.conf@ file: 12 | . 13 | > -- Pretty printing of it 14 | > :set -package ghci-pretty 15 | > import Text.Show.Pretty.Colored 16 | > :set -interactive-print=cpprint 17 | > :def cp (\_ -> return ":set -interactive-print=cpprint") 18 | > :def ncp (\_ -> return ":set -interactive-print=print") 19 | . 20 | Now you can enable colored pretty-printing in ghci with the commmand 21 | . 22 | > :cp 23 | . 24 | The following command turns colored pretty-printing off again 25 | . 26 | > :ncp 27 | 28 | Homepage: https://github.com/larskuhtz/ghci-pretty 29 | License: MIT 30 | License-file: LICENSE 31 | Author: Lars Kuhtz 32 | Maintainer: Lars Kuhtz 33 | Copyright: Copyright (c) 2014 Lars Kuhtz 34 | Category: Development 35 | Build-type: Simple 36 | Cabal-version: >= 1.16 37 | 38 | extra-doc-files: 39 | README.md 40 | 41 | extra-source-files: 42 | constraints 43 | 44 | source-repository head 45 | type: git 46 | location: https://github.com/larskuhtz/ghci-pretty 47 | 48 | Library 49 | default-language: Haskell2010 50 | hs-source-dirs: src 51 | 52 | exposed-modules: 53 | Text.Show.Pretty.Colored 54 | 55 | build-depends: 56 | base == 4.*, 57 | pretty-show >= 0.5, 58 | hscolour >= 1.20 59 | 60 | ghc-options: -Wall 61 | 62 | -------------------------------------------------------------------------------- /src/Text/Show/Pretty/Colored.hs: -------------------------------------------------------------------------------- 1 | -- | 2 | -- Module: IPPrint.Colored 3 | -- Copyright: Copyright © 2014 Lars Kuhtz 4 | -- License: MIT 5 | -- Maintainer: Lars Kuhtz 6 | -- Stability: experimental 7 | -- 8 | -- This module combines the ipprint package and 9 | -- the hscolour package to provide colored pretty-printing 10 | -- in ghci. 11 | -- 12 | -- /Usage/ 13 | -- 14 | -- Add the following lines to your @ghci.conf@ file: 15 | -- 16 | -- > -- Pretty printing of it 17 | -- > :set -package ghci-pretty 18 | -- > import Text.Show.Pretty.Colored 19 | -- > :set -interactive-print=cpprint 20 | -- > :def cp (\_ -> return ":set -interactive-print=cpprint" 21 | -- > :def ncp (\_ -> return ":set -interactive-print=print") 22 | -- 23 | -- Now you can enable colored pretty-printing in ghci with the commmand 24 | -- 25 | -- > :cp 26 | -- 27 | -- The following command turns colored pretty-printing off again 28 | -- 29 | -- > :ncp 30 | -- 31 | module Text.Show.Pretty.Colored 32 | ( cpprint 33 | ) where 34 | 35 | import Text.Show.Pretty 36 | import Language.Haskell.HsColour 37 | import Language.Haskell.HsColour.Colourise 38 | import Language.Haskell.HsColour.Output 39 | 40 | cpprint :: Show a => a -> IO () 41 | cpprint x = do 42 | putStrLn . hscolour (TTYg XTerm256Compatible) defaultColourPrefs False False "" False . ppShow $ x 43 | 44 | --------------------------------------------------------------------------------