From dc2ae1ef07b89309479b354d0c82866aeab2ad5b Mon Sep 17 00:00:00 2001 From: rnhmjoj Date: Tue, 12 May 2015 23:09:23 +0200 Subject: [PATCH] Use TH --- namecoin-update.hs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/namecoin-update.hs b/namecoin-update.hs index 3146591..cbe990e 100644 --- a/namecoin-update.hs +++ b/namecoin-update.hs @@ -1,22 +1,20 @@ -{-# Language DeriveGeneric, RecordWildCards #-} +{-# Language TemplateHaskell, RecordWildCards #-} import System.Process import System.Exit -import GHC.Generics import Data.Aeson +import Data.Aeson.TH import Data.ByteString.Lazy.Char8 (pack) readCommand = readProcess "namecoind" ["name_list"] "" updateCommand n v = readProcessWithExitCode "namecoind" ["name_update", n, v] "" -data Name = - Name { name :: String - , value :: String - , address :: String - , expires_in :: Int - } deriving (Show, Generic) +data Name = Name { name :: String + , value :: String + , expires_in :: Int + } -instance FromJSON Name +deriveJSON defaultOptions ''Name updateName :: Name -> IO Int updateName Name{..}