packages feed

chalk (empty) → 0.1.0.0

raw patch · 4 files changed

+102/−0 lines, 4 filesdep +basesetup-changed

Dependencies added: base

Files

+ LICENSE view
@@ -0,0 +1,20 @@+Copyright (c) 2015 Joomy Korkut++Permission is hereby granted, free of charge, to any person obtaining+a copy of this software and associated documentation files (the+"Software"), to deal in the Software without restriction, including+without limitation the rights to use, copy, modify, merge, publish,+distribute, sublicense, and/or sell copies of the Software, and to+permit persons to whom the Software is furnished to do so, subject to+the following conditions:++The above copyright notice and this permission notice shall be included+in all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ chalk.cabal view
@@ -0,0 +1,22 @@+name:                chalk+version:             0.1.0.0+synopsis:            Terminal string styling.+-- description:+homepage:            http://github.com/joom/chalk+license:             MIT+license-file:        LICENSE+author:              Joomy Korkut+maintainer:          joomy@cattheory.com+-- copyright:+category:            System+build-type:          Simple+-- extra-source-files:+cabal-version:       >=1.10++library+  exposed-modules:     System.Console.Chalk+  -- other-modules:+  -- other-extensions:+  build-depends:       base >=4.7 && <4.8+  hs-source-dirs:      src+  default-language:    Haskell2010
+ src/System/Console/Chalk.hs view
@@ -0,0 +1,58 @@+{-# LANGUAGE OverloadedStrings #-}++module System.Console.Chalk (+  reset, bold, dim, italic, underline, inverse, hidden,+  strikethrough, black, red, green, yellow, blue,+  magenta, cyan, white, gray, bgBlack, bgRed, bgGreen,+  bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite) where++import Control.Arrow ((***))+import Data.Monoid+import Data.String++-- | Single code number to ANSI code.+tag :: (Monoid m, IsString m) => m -> m+tag x = "\ESC[" <> x <> "m"++-- | Take a code number pair and convert it to a ANSI code pair.+tags+  :: (Monoid t1, Monoid t, IsString t1, IsString t) =>+     (t, t1) -> (t, t1)+tags = tag *** tag++-- | Take a code number pair and a type that fits IsString,+-- and wrap the latter with the ANSI codes.+wrap :: (Monoid m, IsString m) => (m, m) -> m -> m+wrap (l, r) s = cl <> s <> cr+  where (cl, cr) = tags (l, r)++reset, bold, dim, italic, underline, inverse, hidden,+  strikethrough, black, red, green, yellow, blue,+  magenta, cyan, white, gray, bgBlack, bgRed, bgGreen,+  bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite ::+  (Monoid m, IsString m) => m -> m+reset         = wrap ("0", "0")+bold          = wrap ("1", "22")+dim           = wrap ("2", "22")+italic        = wrap ("3", "23")+underline     = wrap ("4", "24")+inverse       = wrap ("7", "27")+hidden        = wrap ("8", "28")+strikethrough = wrap ("9", "29")+black         = wrap ("30", "39")+red           = wrap ("31", "39")+green         = wrap ("32", "39")+yellow        = wrap ("33", "39")+blue          = wrap ("34", "39")+magenta       = wrap ("35", "39")+cyan          = wrap ("36", "39")+white         = wrap ("37", "39")+gray          = wrap ("90", "39")+bgBlack       = wrap ("40", "49")+bgRed         = wrap ("41", "49")+bgGreen       = wrap ("42", "49")+bgYellow      = wrap ("43", "49")+bgBlue        = wrap ("44", "49")+bgMagenta     = wrap ("45", "49")+bgCyan        = wrap ("46", "49")+bgWhite       = wrap ("47", "49")