Skip to content

Commit

Permalink
Add Show instance for ParserResult (fixes #95).
Browse files Browse the repository at this point in the history
  • Loading branch information
pcapriotti committed Jul 30, 2014
1 parent 3b375db commit 19eed17
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

- Added low-level function to handle parse results (pull request \#94).

- `ParserResult` now has a `Show` instance (see issue \#95).

- Fixed bugs
* \#93 - Formatting problem for several sub-parsers

Expand Down
11 changes: 11 additions & 0 deletions Options/Applicative/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -236,14 +236,25 @@ instance Monoid Completer where
newtype CompletionResult = CompletionResult
{ execCompletion :: String -> IO String }

instance Show CompletionResult where
showsPrec p _ = showParen (p > 10) $
showString "CompletionResult _"

newtype ParserFailure = ParserFailure
{ execFailure :: String -> (String, ExitCode) }

instance Show ParserFailure where
showsPrec p (ParserFailure f)
= showParen (p > 10)
$ showString "ParserFailure "
. showsPrec 11 (f "<program>")

-- | Result of 'execParserPure'.
data ParserResult a
= Success a
| Failure ParserFailure
| CompletionInvoked CompletionResult
deriving Show

type Args = [String]

Expand Down

0 comments on commit 19eed17

Please sign in to comment.