module LogicGrowsOnTrees.Utils.Word_ where
import Data.Word
import System.Console.CmdTheLine
import Text.PrettyPrint
newtype Word_ = Word_ { getWord :: Word } deriving (Eq,Show)
instance ArgVal Word_ where
converter = (parseWord,prettyWord)
where
(parseInt,prettyInt) = converter
parseWord =
either Left (\n →
if n >= (0::Int)
then Right . Word_ . fromIntegral $ n
else Left . text $ "non-negative argument required (not " ++ show n ++ ")"
)
.
parseInt
prettyWord = prettyInt . fromIntegral . getWord
instance ArgVal (Maybe Word_) where
converter = just