Support the new GHC 7.10 base library

This commit is contained in:
rnhmjoj 2015-04-11 20:29:16 +02:00
parent 2ef3e66b48
commit ae5069b3ad
2 changed files with 18 additions and 25 deletions

View File

@ -1,5 +1,5 @@
name: rosa
version: 0.1.3.0
version: 0.2.0.0
synopsis: Query the namecoin blockchain
description:
@ -12,7 +12,7 @@ license: MIT
license-file: LICENSE
author: Rnhmjoj
maintainer: micheleguerinirocco@me.com
copyright: (C) Michele Guerini Rocco 2014
copyright: (C) Michele Guerini Rocco 2015
category: Utility
build-type: Simple
extra-source-files: README.md, LICENSE
@ -28,8 +28,8 @@ executable rosa
hs-source-dirs: src
default-language: Haskell2010
other-extensions: RecordWildCards, OverloadedStrings
build-depends: base ==4.7.*, aeson ==0.8.*, text ==1.2.*,
vector ==0.10.*, unordered-containers ==0.2.*,
wreq ==0.3.*, lens >=4.4, bytestring ==0.10.*,
argparser ==0.3.*, process ==1.2.*
build-depends: base >=4.8 && <5.0 , aeson, text,
vector, unordered-containers,
wreq, lens >=4.4, bytestring,
argparser, process
ghc-options: -O2

View File

@ -1,16 +1,15 @@
{-# LANGUAGE RecordWildCards, OverloadedStrings #-}
import Json
import Control.Lens
import Network.Wreq (get, responseBody)
import Data.Aeson (decode, toJSON)
import Data.Maybe (fromJust)
import Data.HashMap.Strict (delete)
import Control.Lens
import Control.Applicative
import Data.ByteString.Lazy.Char8 (pack)
import System.Console.ArgParser
import System.Process
import qualified Data.ByteString.Lazy.Char8 as C
import Json
data ProgArgs = ProgArgs
{ name :: String
@ -20,7 +19,6 @@ data ProgArgs = ProgArgs
, raw :: Bool
} deriving (Show)
parser :: ParserSpec ProgArgs
parser = ProgArgs
`parsedBy` reqPos "name" `Descr` "Namecoin name id"
@ -30,38 +28,33 @@ parser = ProgArgs
`andBy` boolFlag "block" `Descr` "Show blockchain data (require local connecton)"
`andBy` boolFlag "raw" `Descr` "Print raw JSON data"
interface :: IO (CmdLnInterface ProgArgs)
interface =
(`setAppDescr` "Query the namecoin blockchain") <$>
(`setAppEpilog` "Stat rosa pristina nomine, nomina nuda tenemus.") <$>
mkApp parser
main :: IO ()
main = interface >>= flip runApp exec
exec :: ProgArgs -> IO ()
exec ProgArgs{..} = do
exec ProgArgs{..} =
if dnschain
then handleDnschain url name raw
else handleLocal name block
handleLocal :: String -> Bool -> IO ()
handleLocal name block = do
out <- readProcess "namecoind" ["name_show", name] ""
case decode (C.pack out) of
case decode (pack out) of
Just res -> do
pprint $ reparse (res |: "value")
if block then pprint extra else return ()
where
reparse = fromJust . decode . C.pack
extra = toJSON $ delete "value" res
reparse = fromJust . decode . pack
extra = toJSON (delete "value" res)
Nothing -> putStrLn "Error parsing data"
handleDnschain :: String -> String -> Bool -> IO ()
handleDnschain url name raw = do
req <- get (url ++ name)