diff options
Diffstat (limited to 'KeyRing.hs')
-rw-r--r-- | KeyRing.hs | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -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 | ||
399 | uncamel :: String -> String | ||
400 | uncamel 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 | |||
408 | reportString :: KikiReportAction -> String | ||
409 | reportString x = uncamel $ show x | ||
410 | |||
411 | errorString :: KikiCondition a -> String | ||
412 | errorString (KikiSuccess {}) = "success" | ||
413 | errorString e = uncamel . show $ fmap (const ()) e | ||
414 | |||
397 | data KikiResult a = KikiResult | 415 | data KikiResult a = KikiResult |
398 | { kikiCondition :: KikiCondition a | 416 | { kikiCondition :: KikiCondition a |
399 | , kikiReport :: [ (FilePath, KikiReportAction) ] | 417 | , kikiReport :: [ (FilePath, KikiReportAction) ] |