packages feed

funnyprint 0.0.2 → 0.0.3

raw patch · 4 files changed

+56/−20 lines, 4 filesdep +textPVP ok

version bump matches the API change (PVP)

Dependencies added: text

API changes (from Hackage documentation)

+ FunnyPrint: escape :: String -> String
+ FunnyPrint: funnyPrintC :: (Show a) => a -> IO ()
+ FunnyPrint: type Colored = Bool

Files

README.md view
@@ -4,7 +4,7 @@  *** -see `FunnyPrint.funnyPrint`.+see `FunnyPrint.funnyPrintC` and `FunnyPrint.funnyPrint`.  Use it as `:set -interactive-print=funnyPrint`. @@ -15,6 +15,19 @@ ### Customize GHCi prompt in right way  see `FunnyPrint.prompt` and `FunnyPrint.prompt2`.++#### Usage example++You may use it like this:++```haskell+:set -package funnyprint++:def color (\_ -> return (":set -interactive-print=FunnyPrint.funnyPrintC\n:set prompt \"" ++ FunnyPrint.prompt "λ " "%s" " ¬\\nλ > " ++ "\"" ++ "\n:set prompt2 \"" ++ FunnyPrint.prompt2 "λ" "" " | " ++ "\""))+:def nocolor (\_ -> return ":set -interactive-print=print\n:set prompt \"%s> \"\n:set prompt2 \"%s| \"")++:color+```  *** 
funnyprint.cabal view
@@ -3,7 +3,7 @@ -- see: https://github.com/sol/hpack  name:           funnyprint-version:        0.0.2+version:        0.0.3 synopsis:       funnyPrint function to colorize GHCi output. description:    see FunnyPrint.funnyPrint. category:       Text@@ -34,6 +34,7 @@       base >= 2 && < 6     , hscolour     , ipprint == 0.6+    , text   exposed-modules:       FunnyPrint   default-language: Haskell2010@@ -48,6 +49,7 @@       base >= 2 && < 6     , hscolour     , ipprint == 0.6+    , text     , funnyprint     , tasty     , tasty-hspec@@ -63,6 +65,7 @@       base >= 2 && < 6     , hscolour     , ipprint == 0.6+    , text     , funnyprint     , criterion   default-language: Haskell2010
library/FunnyPrint.hs view
@@ -1,8 +1,15 @@ -- | funnyPrint function to colorize GHCi output. See @FunnyPrint.funnyPrint@.-module FunnyPrint ( funnyPrint+module FunnyPrint ( Colored+                  , escape+                  , funnyPrint+                  , funnyPrintC                   , prompt-                  , prompt2 ) where+                  , prompt2+                  ) where +import Prelude hiding ( putStrLn )+import Data.Text.IO ( putStrLn )+import Data.Text ( pack ) import IPPrint ( pshow ) import Language.Haskell.HsColour.Output ( TerminalType(..) ) import Language.Haskell.HsColour.Colourise ( Colour(..)@@ -14,10 +21,15 @@                                  , hscolour                                  ) import Language.Haskell.HsColour.ANSI ( highlightOnG-                                      , highlightOff )+                                      , highlightOff+                                      )+-- | Escape quoutes in string.+escape :: String -- ^ handled string+       -> String+escape arg = "'" ++ ((\c -> if c == '\'' then "'\"'\"'" else [c]) =<< arg) ++"'" -terminal :: TerminalType-terminal = XTerm256Compatible+term    :: TerminalType+term    = XTerm256Compatible  black   :: Highlight black   = Foreground Black@@ -46,20 +58,25 @@ bold    :: Highlight bold    = Bold --- | Colorize GHCi. UTF8 support. Smart indentatntion. Use as @:set -interactive-print=funnyPrint@.+type Colored = Bool++-- | UTF8 support. Smart indentatntion. Use as @:set -interactive-print=funnyPrintC@.+funnyPrintC :: (Show a) => a -- ^ printed input+            -> IO ()+funnyPrintC = funnyPrint' True++-- | Colorize GHCi. UTF8 support. Smart indentatntion. Use as @:set -interact funnyPrint :: (Show a) => a -- ^ printed input            -> IO ()-funnyPrint = putStrLn . colorize . con . pshow+funnyPrint = funnyPrint' False++-- | internal helper, use 'funnyPrint' or 'funnyPrintC'+funnyPrint'   :: (Show a) => Colored -- ^ enable colors in prompt+              -> a                   -- ^ printed input+              -> IO ()+funnyPrint' c = putStrLn . pack . if c then colorize . pshow else pshow   where-    con :: String -> String-    con [] = []-    con li@(x:xs) | x == '\"' = '\"':str ++ "\"" ++ (con rest)-                  | x == '\'' = '\'':chr:'\'':(con rest')-                  | otherwise = x:con xs-      where-        (str, rest):_  = reads li :: [(String, String)]-        (chr, rest'):_ = reads li :: [(Char,   String)]-    prefs = TTYg terminal+    prefs = TTYg term     colorize = hscolour prefs colours False False "" False     colours = defaultColourPrefs { conid    = [ yellow, bold ]                                  , conop    = [ yellow ]@@ -71,7 +88,7 @@                                  }  mark   :: Highlight -> String-mark h = highlightOnG terminal [h, bold]+mark h = highlightOnG term [h, bold]  -- | Prompt for GHCi. prompt :: String -- ^ marker
package.yaml view
@@ -7,6 +7,7 @@     - base >= 2 && < 6     - hscolour     - ipprint == 0.6+    - text     - funnyprint     - criterion     ghc-options:@@ -30,6 +31,7 @@   - base >= 2 && < 6   - hscolour   - ipprint == 0.6+  - text   source-dirs: library license: MIT license-file: LICENSE.md@@ -42,6 +44,7 @@     - base >= 2 && < 6     - hscolour     - ipprint == 0.6+    - text     - funnyprint     - tasty     - tasty-hspec@@ -51,4 +54,4 @@     - -with-rtsopts=-N     main: Main.hs     source-dirs: test-suite-version: '0.0.2'+version: '0.0.3'