summaryrefslogtreecommitdiff
path: root/src/Trivstream/Options/Utils.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Trivstream/Options/Utils.hs')
-rw-r--r--src/Trivstream/Options/Utils.hs32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/Trivstream/Options/Utils.hs b/src/Trivstream/Options/Utils.hs
new file mode 100644
index 0000000..30694d8
--- /dev/null
+++ b/src/Trivstream/Options/Utils.hs
@@ -0,0 +1,32 @@
1{-# LANGUAGE StandaloneDeriving #-}
2
3module Trivstream.Options.Utils
4 ( rCI
5 ) where
6
7import Options.Applicative
8
9import Data.Char
10import Data.Maybe
11
12import Network.Socket
13
14
15deriving instance Enum Family
16deriving instance Bounded Family
17
18
19rCI :: (Show a, Read a) => ReadM a
20rCI = eitherReader rRep'
21 where
22 rRep' str = case mapMaybe readMaybe $ cases str of
23 [] -> Left $ "Could not parse `" ++ str ++ "'"
24 [x] -> Right x
25 xs -> Left $ "Ambiguous parse for `" ++ str ++ "': " ++ show xs
26 cases [] = [[]]
27 cases (c:cs) = [(c':cs') | c' <- [toLower c, c, toUpper c], cs' <- cases cs]
28
29rFamily :: ReadM Family
30rFamily = undefined
31 where
32 families = filter isSupportedFamily [minBound..maxBound]