packages feed

nicify 1.1 → 1.2

raw patch · 4 files changed

+26/−138 lines, 4 filesdep +nicify-libdep −nicifydep −parsecdep −transformers

Dependencies added: nicify-lib

Dependencies removed: nicify, parsec, transformers

Files

nicify.cabal view
@@ -1,35 +1,25 @@ Name:           nicify-Version:        1.1-Synopsis:       Pretty print the standard output of show for algebraic datatypes-Description:    Pretty print the standard output of show for algebraic datatypes+Version:        1.2+Synopsis:       Pretty print the standard output of default `Show` instances.+Description:    Pretty print the standard output of `show` for algebraic datatypes                  License:        MIT License-File:   LICENSE-Author:         Julian Fleischer <julian.fleischer@fu-berlin.de>-Maintainer:     Julian Fleischer <julian.fleischer@fu-berlin.de>+Author:         Julian Fleischer+Maintainer:     julian@scravy.de Build-Type:     Simple-Cabal-Version:  >= 1.8+Cabal-Version:  >= 1.10 Category:       Text, Tools, Utilities Stability:      stable  Source-Repository head-    type: darcs-    location: http://hub.darcs.net/scravy/nicify--Library-    Exposed-Modules:    Text.Nicify-    Build-Depends:      base >= 4 && < 5-                        , parsec >= 3-                        , transformers >= 0.3-    Hs-Source-Dirs:     src+    type: git+    location: https://github.com/scravy/nicify  Executable nicify-    Build-Depends:      base >= 4 && < 5-                        , nicify-                        , parsec >= 3-                        , transformers >= 0.3+    Build-Depends:      base ==4.*+                        , nicify-lib -    Hs-Source-Dirs:     src     Main-Is:            nicify.hs-    +    Default-Language:   Haskell2010     
+ nicify.hs view
@@ -0,0 +1,15 @@+import Text.Nicify+import System.Environment (getArgs)++main = do+    args <- getArgs+    main' args++main' [] = interact nicify++main' (x:[]) = do+    contents <- readFile x+    putStr (nicify contents)++main' (x:xs) = main' [x] >> main' xs+
− src/Text/Nicify.hs
@@ -1,102 +0,0 @@-{-# LANGUAGE Haskell2010-    , DeriveDataTypeable- #-}-{-# OPTIONS-    -Wall-    -fno-warn-unused-do-bind-    -fno-warn-name-shadowing- #-}--module Text.Nicify (-    nicify,-    X (..),-    parseX,-    printX,-    printX'-  ) where---import Data.Data-import Data.Functor.Identity-import Text.Parsec---data X = XString String-       | XCurly [X]-       | XBrackets [X]-       | XAnything String-       | XSep-    deriving (Show, Read, Eq, Data, Typeable)---nicify :: String -> String-nicify = printX . parseX--type Parser a = ParsecT String () Identity a--parseX :: String -> [X]-parseX = either (const []) id . runParser (many rData) () "-"--printX :: [X] -> String-printX = printX' ""--printX' :: String -> [X] -> String-printX' indent = (indent ++) . concatMap (prettify indent)--prettify :: String -> X -> String-prettify indent x = case x of-    XAnything s -> s-    XString s -> '\"' : foldr stringify "\"" s-    XSep -> ",\n" ++ indent-    XCurly [] -> "{}"-    XBrackets [] -> "[]"-    XCurly x -> "{\n" ++ indent' ++ foldr (++) ('\n' : indent ++ "}") (map (prettify indent') x)-    XBrackets x -> "[\n" ++ indent' ++ foldr (++) ('\n' : indent ++ "]") (map (prettify indent') x)-  where-    indent' = indent ++ "    "-    stringify c cs = case c of-        '\"' -> "\\\"" ++ cs-        '\\' -> "\\\\" ++ cs-        char -> char : cs--rData, rSep, rAnything, rCurly, rBrackets, rString :: Parser X--rData = rString <|> rCurly <|> rBrackets <|> rSep <|> rAnything--rSep = do-    char ','-    spaces-    return XSep--rAnything = do-    str <- many1 (noneOf "\"{}[],")-    return $ XAnything str--rCurly = do-    char '{'-    str <- many rData-    char '}'-    return $ XCurly str--rBrackets = do-    char '['-    str <- many rData-    char ']'-    return $ XBrackets str--rString = do-    char '\"'-    str <- many (noneOf "\\\"" <|> escape)-    char '\"'-    return $ XString str--escape :: Parser Char-escape = do-    char '\\'-    c <- anyChar-    case c of-        'n' -> return '\n'-        'r' -> return '\r'-        't' -> return '\t'-        any -> return any-
− src/nicify.hs
@@ -1,15 +0,0 @@-import Text.Nicify-import System.Environment (getArgs)--main = do-    args <- getArgs-    main' args--main' [] = interact nicify--main' (x:[]) = do-    contents <- readFile x-    putStr (nicify contents)--main' (x:xs) = main' [x] >> main' xs-