From 054088883d62800ef0cd92c9885f58a82ee71d3d Mon Sep 17 00:00:00 2001
From: Julien Moutinho <julm@autogeree.net>
Date: Thu, 11 Jul 2019 10:54:57 +0000
Subject: [PATCH] parser: add OnHandle

---
 Symantic/CLI/Parser.hs | 30 ++++++++++++++++++++++++++++--
 symantic-cli.cabal     |  2 +-
 2 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/Symantic/CLI/Parser.hs b/Symantic/CLI/Parser.hs
index ca72655..f42678e 100644
--- a/Symantic/CLI/Parser.hs
+++ b/Symantic/CLI/Parser.hs
@@ -261,6 +261,8 @@ instance Outputable Bool
 instance Outputable Int
 instance Outputable Integer
 instance Outputable Natural
+instance Outputable Char where
+	output c = IO.putStr [c]
 instance Outputable String where
 	output = IO.putStr
 instance Outputable Text.Text where
@@ -273,8 +275,31 @@ instance Outputable (Doc.AnsiText (Doc.Plain TLB.Builder)) where
 		TLB.toLazyText .
 		Doc.runPlain .
 		Doc.runAnsiText
-instance Outputable (IO.Handle, Doc.AnsiText (Doc.Plain TLB.Builder)) where
-	output (h,d) =
+
+-- ** Type 'OnHandle'
+data OnHandle a = OnHandle IO.Handle a
+instance IOType a => IOType (OnHandle a) where
+	ioType = ioType @a
+instance Outputable (OnHandle ()) where
+	output _ = return ()
+instance Outputable (OnHandle Bool) where
+	output (OnHandle h a) = IO.hPrint h a
+instance Outputable (OnHandle Int) where
+	output (OnHandle h a) = IO.hPrint h a
+instance Outputable (OnHandle Integer) where
+	output (OnHandle h a) = IO.hPrint h a
+instance Outputable (OnHandle Natural) where
+	output (OnHandle h a) = IO.hPrint h a
+instance Outputable (OnHandle Char) where
+	output (OnHandle h c) = IO.hPutStr h [c]
+instance Outputable (OnHandle String) where
+	output (OnHandle h a) = IO.hPutStr h a
+instance Outputable (OnHandle Text.Text) where
+	output (OnHandle h a) = Text.hPutStr h a
+instance Outputable (OnHandle TL.Text) where
+	output (OnHandle h a) = TL.hPutStr h a
+instance Outputable (OnHandle (Doc.AnsiText (Doc.Plain TLB.Builder))) where
+	output (OnHandle h d) =
 		TL.hPutStr h $
 		TLB.toLazyText $
 		Doc.runPlain $
@@ -289,6 +314,7 @@ class IOType a where
 
 instance IOType ()
 instance IOType Bool
+instance IOType Char
 instance IOType Int
 instance IOType Integer
 instance IOType Natural
diff --git a/symantic-cli.cabal b/symantic-cli.cabal
index 0fd472d..af0cfd5 100644
--- a/symantic-cli.cabal
+++ b/symantic-cli.cabal
@@ -2,7 +2,7 @@ name: symantic-cli
 -- PVP:  +-+------- breaking API changes
 --       | | +----- non-breaking API additions
 --       | | | +--- code changes with no API change
-version: 2.3.0.20190710
+version: 2.3.1.20190711
 category: System, CLI, Options, Parsing
 synopsis: Symantics for parsing and documenting a CLI
 description:
-- 
2.47.2