haskell - Parsing "enum" options with optparse-applicative -


how implement parser example grep --help:

 --binary-files=type   assume binary files type;                        type 'binary', 'text', or 'without-match' 

assuming have

data binaryfiles = binary | text | withoutmatch 

how write parser? option auto seems kludge since read supposed "inverse" show, , i'd keep derived instance show binaryfiles.

use str instead of auto:

binfile :: readm binaryfiles binfile = str >>= \s -> case s of     "binary"        -> return binary     "text"          -> return text     "without-match" -> return withoutmatch     _ -> readererror "accepted binary file types 'binary', 'text', , 'without-match'." 

Comments

Popular posts from this blog

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

php - How to remove letter in front of the word laravel -

minify - Minimizing css files -