summaryrefslogtreecommitdiff
path: root/KeyRing.hs
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2014-04-22 17:01:03 -0400
committerjoe <joe@jerkface.net>2014-04-22 17:01:03 -0400
commit1257ddd6813fc75df11631d653a97eb45035188e (patch)
treea60c4c442d4d72eb2f8423e5192ca24a99b5ed76 /KeyRing.hs
parent2421f2a09a089f6d10b8e35b4cecd7d264a0c117 (diff)
fixed error and action reporting
Diffstat (limited to 'KeyRing.hs')
-rw-r--r--KeyRing.hs18
1 files changed, 18 insertions, 0 deletions
diff --git a/KeyRing.hs b/KeyRing.hs
index 78fb40c..532acb8 100644
--- a/KeyRing.hs
+++ b/KeyRing.hs
@@ -10,6 +10,8 @@ module KeyRing
10 , KikiResult(..) 10 , KikiResult(..)
11 , KikiCondition(..) 11 , KikiCondition(..)
12 , KikiReportAction(..) 12 , KikiReportAction(..)
13 , errorString
14 , reportString
13 , KeyRingRuntime(..) 15 , KeyRingRuntime(..)
14 , InputFile(..) 16 , InputFile(..)
15 , FileType(..) 17 , FileType(..)
@@ -394,6 +396,22 @@ data KikiReportAction =
394 | HostsDiff ByteString 396 | HostsDiff ByteString
395 deriving Show 397 deriving Show
396 398
399uncamel :: String -> String
400uncamel str = unwords $ firstWord ++ (toLower .: otherWords) ++ args
401 where
402 (.:) = fmap . fmap
403 ( firstWord ,
404 otherWords ) = splitAt 1 ws
405 ws = camel >>= groupBy (\_ c -> isLower c)
406 ( camel, args) = splitAt 1 $ words str
407
408reportString :: KikiReportAction -> String
409reportString x = uncamel $ show x
410
411errorString :: KikiCondition a -> String
412errorString (KikiSuccess {}) = "success"
413errorString e = uncamel . show $ fmap (const ()) e
414
397data KikiResult a = KikiResult 415data KikiResult a = KikiResult
398 { kikiCondition :: KikiCondition a 416 { kikiCondition :: KikiCondition a
399 , kikiReport :: [ (FilePath, KikiReportAction) ] 417 , kikiReport :: [ (FilePath, KikiReportAction) ]