Skip to content

Commit be18330

Browse files
committed
Documentation, exports and minor stuff
1 parent 6ab5884 commit be18330

File tree

14 files changed

+83
-75
lines changed

14 files changed

+83
-75
lines changed

library/Neovim.hs

+9-9
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,6 @@ module Neovim (
5454

5555
ask,
5656
asks,
57-
put,
58-
get,
59-
gets,
60-
modify,
6157

6258
-- ** Creating a stateful plugin
6359
-- $statefulplugin
@@ -69,8 +65,6 @@ module Neovim (
6965
waitErr,
7066
waitErr',
7167
err,
72-
Doc,
73-
Pretty(..),
7468
errOnInvalidResult,
7569
NeovimException(..),
7670
-- ** Generated functions for neovim interaction
@@ -85,6 +79,11 @@ module Neovim (
8579
unlessM,
8680
docToObject,
8781
docFromObject,
82+
Doc,
83+
AnsiStyle,
84+
Pretty(..),
85+
putDoc,
86+
exceptionToDoc,
8887
Priority(..),
8988
module Control.Monad,
9089
module Control.Applicative,
@@ -106,10 +105,12 @@ import Neovim.API.String
106105
import Neovim.API.TH (autocmd, command, command',
107106
function, function')
108107
import Neovim.Classes (Dictionary, NvimObject (..),
108+
Doc, AnsiStyle, Pretty(..),
109109
docFromObject, docToObject, (+:))
110110
import Neovim.Config (NeovimConfig (..))
111111
import Neovim.Context (Neovim,
112-
NeovimException (ErrorMessage),
112+
NeovimException(..),
113+
exceptionToDoc,
113114
ask, asks, err,
114115
errOnInvalidResult, get, gets,
115116
modify, put)
@@ -128,8 +129,7 @@ import Neovim.RPC.FunctionCall (wait, wait', waitErr, waitErr')
128129
import Neovim.Util (unlessM, whenM,
129130
withCustomEnvironment)
130131
import System.Log.Logger (Priority (..))
131-
import Data.Text.Prettyprint.Doc (Doc, Pretty (..))
132-
132+
import Data.Text.Prettyprint.Doc.Render.Terminal (putDoc)
133133
-- Installation {{{1
134134
{- $installation
135135

library/Neovim/API/Parser.hs

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import qualified Data.ByteString as B
2424
import Data.Map (Map)
2525
import qualified Data.Map as Map
2626
import Data.MessagePack
27-
import Data.Monoid
2827
import Data.Serialize
2928
import Neovim.Compat.Megaparsec as P
3029
import System.IO (hClose)

library/Neovim/API/TH.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ data ArgType = StringyType
309309

310310

311311
-- | Given a value of type 'Type', test whether it can be classified according
312-
-- to the constructors of 'ArgType'.
312+
-- to the constructors of "ArgType".
313313
classifyArgType :: Type -> Q ArgType
314314
classifyArgType t = do
315315
set <- genStringTypesSet

library/Neovim/Classes.hs

+29-28
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,10 @@ import Data.Int (Int16, Int32, Int64,
4848
import qualified Data.Map.Strict as SMap
4949
import Data.MessagePack
5050
import Data.Monoid
51-
import Data.String (IsString (..))
5251
import Data.Text as Text (Text)
5352
import Data.Text.Prettyprint.Doc (Doc, Pretty (..),
5453
defaultLayoutOptions,
55-
layoutPretty,
56-
lparen, rparen,
54+
layoutPretty, viaShow,
5755
(<+>))
5856
import qualified Data.Text.Prettyprint.Doc as P
5957
import Data.Text.Prettyprint.Doc.Render.Terminal (AnsiStyle,
@@ -76,6 +74,9 @@ import Prelude
7674
infixr 5 +:
7775

7876
-- | Convenient operator to create a list of 'Object' from normal values.
77+
-- @
78+
-- values +: of :+ different :+ types :+ can +: be +: combined +: this +: way +: []
79+
-- @
7980
(+:) :: (NvimObject o) => o -> [Object] -> [Object]
8081
o +: os = toObject o : os
8182

@@ -157,7 +158,7 @@ instance NvimObject Double where
157158
fromObject (ObjectInt o) = return $ fromIntegral o
158159
fromObject (ObjectUInt o) = return $ fromIntegral o
159160
fromObject o = throwError $ "Expected ObjectDouble, but got"
160-
<+> pretty (show o)
161+
<+> viaShow o
161162

162163

163164
instance NvimObject Integer where
@@ -167,7 +168,7 @@ instance NvimObject Integer where
167168
fromObject (ObjectUInt o) = return $ toInteger o
168169
fromObject (ObjectDouble o) = return $ round o
169170
fromObject (ObjectFloat o) = return $ round o
170-
fromObject o = throwError $ "Expected ObjectInt, but got" <+> pretty (show o)
171+
fromObject o = throwError $ "Expected ObjectInt, but got" <+> viaShow o
171172

172173

173174
instance NvimObject Int64 where
@@ -177,7 +178,7 @@ instance NvimObject Int64 where
177178
fromObject (ObjectUInt o) = return $ fromIntegral o
178179
fromObject (ObjectDouble o) = return $ round o
179180
fromObject (ObjectFloat o) = return $ round o
180-
fromObject o = throwError $ "Expected any Integer value, but got" <+> pretty (show o)
181+
fromObject o = throwError $ "Expected any Integer value, but got" <+> viaShow o
181182

182183

183184
instance NvimObject Int32 where
@@ -187,7 +188,7 @@ instance NvimObject Int32 where
187188
fromObject (ObjectUInt i) = return $ fromIntegral i
188189
fromObject (ObjectDouble o) = return $ round o
189190
fromObject (ObjectFloat o) = return $ round o
190-
fromObject o = throwError $ "Expected any Integer value, but got" <+> pretty (show o)
191+
fromObject o = throwError $ "Expected any Integer value, but got" <+> viaShow o
191192

192193

193194
instance NvimObject Int16 where
@@ -197,7 +198,7 @@ instance NvimObject Int16 where
197198
fromObject (ObjectUInt i) = return $ fromIntegral i
198199
fromObject (ObjectDouble o) = return $ round o
199200
fromObject (ObjectFloat o) = return $ round o
200-
fromObject o = throwError $ "Expected any Integer value, but got" <+> pretty (show o)
201+
fromObject o = throwError $ "Expected any Integer value, but got" <+> viaShow o
201202

202203

203204
instance NvimObject Int8 where
@@ -207,7 +208,7 @@ instance NvimObject Int8 where
207208
fromObject (ObjectUInt i) = return $ fromIntegral i
208209
fromObject (ObjectDouble o) = return $ round o
209210
fromObject (ObjectFloat o) = return $ round o
210-
fromObject o = throwError $ "Expected any Integer value, but got" <+> pretty (show o)
211+
fromObject o = throwError $ "Expected any Integer value, but got" <+> viaShow o
211212

212213

213214
instance NvimObject Word where
@@ -217,7 +218,7 @@ instance NvimObject Word where
217218
fromObject (ObjectUInt i) = return $ fromIntegral i
218219
fromObject (ObjectDouble o) = return $ round o
219220
fromObject (ObjectFloat o) = return $ round o
220-
fromObject o = throwError $ "Expected any Integer value, but got" <+> pretty (show o)
221+
fromObject o = throwError $ "Expected any Integer value, but got" <+> viaShow o
221222

222223

223224
instance NvimObject Word64 where
@@ -227,7 +228,7 @@ instance NvimObject Word64 where
227228
fromObject (ObjectUInt i) = return $ fromIntegral i
228229
fromObject (ObjectDouble o) = return $ round o
229230
fromObject (ObjectFloat o) = return $ round o
230-
fromObject o = throwError $ "Expected any Integer value, but got" <+> pretty (show o)
231+
fromObject o = throwError $ "Expected any Integer value, but got" <+> viaShow o
231232

232233

233234
instance NvimObject Word32 where
@@ -237,7 +238,7 @@ instance NvimObject Word32 where
237238
fromObject (ObjectUInt i) = return $ fromIntegral i
238239
fromObject (ObjectDouble o) = return $ round o
239240
fromObject (ObjectFloat o) = return $ round o
240-
fromObject o = throwError $ "Expected any Integer value, but got" <+> pretty (show o)
241+
fromObject o = throwError $ "Expected any Integer value, but got" <+> viaShow o
241242

242243

243244
instance NvimObject Word16 where
@@ -247,7 +248,7 @@ instance NvimObject Word16 where
247248
fromObject (ObjectUInt i) = return $ fromIntegral i
248249
fromObject (ObjectDouble o) = return $ round o
249250
fromObject (ObjectFloat o) = return $ round o
250-
fromObject o = throwError $ "Expected any Integer value, but got" <+> pretty (show o)
251+
fromObject o = throwError $ "Expected any Integer value, but got" <+> viaShow o
251252

252253

253254
instance NvimObject Word8 where
@@ -257,7 +258,7 @@ instance NvimObject Word8 where
257258
fromObject (ObjectUInt i) = return $ fromIntegral i
258259
fromObject (ObjectDouble o) = return $ round o
259260
fromObject (ObjectFloat o) = return $ round o
260-
fromObject o = throwError $ "Expected any Integer value, but got" <+> pretty (show o)
261+
fromObject o = throwError $ "Expected any Integer value, but got" <+> viaShow o
261262

262263

263264
instance NvimObject Int where
@@ -267,22 +268,22 @@ instance NvimObject Int where
267268
fromObject (ObjectUInt i) = return $ fromIntegral i
268269
fromObject (ObjectDouble o) = return $ round o
269270
fromObject (ObjectFloat o) = return $ round o
270-
fromObject o = throwError $ "Expected any Integer value, but got" <+> pretty (show o)
271+
fromObject o = throwError $ "Expected any Integer value, but got" <+> viaShow o
271272

272273

273274
instance {-# OVERLAPPING #-} NvimObject [Char] where
274275
toObject = ObjectBinary . UTF8.fromString
275276

276277
fromObject (ObjectBinary o) = return $ UTF8.toString o
277278
fromObject (ObjectString o) = return $ UTF8.toString o
278-
fromObject o = throwError $ "Expected ObjectString, but got" <+> pretty (show o)
279+
fromObject o = throwError $ "Expected ObjectString, but got" <+> viaShow o
279280

280281

281282
instance {-# OVERLAPPABLE #-} NvimObject o => NvimObject [o] where
282283
toObject = ObjectArray . map toObject
283284

284285
fromObject (ObjectArray os) = mapM fromObject os
285-
fromObject o = throwError $ "Expected ObjectArray, but got" <+> pretty (show o)
286+
fromObject o = throwError $ "Expected ObjectArray, but got" <+> viaShow o
286287

287288

288289
instance NvimObject o => NvimObject (Maybe o) where
@@ -320,23 +321,23 @@ instance (Ord key, NvimObject key, NvimObject val)
320321
. (fromObject *** fromObject))
321322
. SMap.toList) om
322323

323-
fromObject o = throwError $ "Expected ObjectMap, but got" <+> pretty (show o)
324+
fromObject o = throwError $ "Expected ObjectMap, but got" <+> viaShow o
324325

325326

326327
instance NvimObject Text where
327328
toObject = ObjectBinary . encodeUtf8
328329

329330
fromObject (ObjectBinary o) = return $ decodeUtf8 o
330331
fromObject (ObjectString o) = return $ decodeUtf8 o
331-
fromObject o = throwError $ "Expected ObjectBinary, but got" <+> pretty (show o)
332+
fromObject o = throwError $ "Expected ObjectBinary, but got" <+> viaShow o
332333

333334

334335
instance NvimObject ByteString where
335336
toObject = ObjectBinary
336337

337338
fromObject (ObjectBinary o) = return o
338339
fromObject (ObjectString o) = return o
339-
fromObject o = throwError $ "Expected ObjectBinary, but got" <+> pretty (show o)
340+
fromObject o = throwError $ "Expected ObjectBinary, but got" <+> viaShow o
340341

341342

342343
instance NvimObject Object where
@@ -353,7 +354,7 @@ instance (NvimObject o1, NvimObject o2) => NvimObject (o1, o2) where
353354
fromObject (ObjectArray [o1, o2]) = (,)
354355
<$> fromObject o1
355356
<*> fromObject o2
356-
fromObject o = throwError $ "Expected ObjectArray, but got" <+> pretty (show o)
357+
fromObject o = throwError $ "Expected ObjectArray, but got" <+> viaShow o
357358

358359
instance (NvimObject o1, NvimObject o2, NvimObject o3) => NvimObject (o1, o2, o3) where
359360
toObject (o1, o2, o3) = ObjectArray $ [toObject o1, toObject o2, toObject o3]
@@ -362,7 +363,7 @@ instance (NvimObject o1, NvimObject o2, NvimObject o3) => NvimObject (o1, o2, o3
362363
<$> fromObject o1
363364
<*> fromObject o2
364365
<*> fromObject o3
365-
fromObject o = throwError $ "Expected ObjectArray, but got" <+> pretty (show o)
366+
fromObject o = throwError $ "Expected ObjectArray, but got" <+> viaShow o
366367

367368

368369
instance (NvimObject o1, NvimObject o2, NvimObject o3, NvimObject o4) => NvimObject (o1, o2, o3, o4) where
@@ -373,7 +374,7 @@ instance (NvimObject o1, NvimObject o2, NvimObject o3, NvimObject o4) => NvimObj
373374
<*> fromObject o2
374375
<*> fromObject o3
375376
<*> fromObject o4
376-
fromObject o = throwError $ "Expected ObjectArray, but got" <+> pretty (show o)
377+
fromObject o = throwError $ "Expected ObjectArray, but got" <+> viaShow o
377378

378379

379380
instance (NvimObject o1, NvimObject o2, NvimObject o3, NvimObject o4, NvimObject o5) => NvimObject (o1, o2, o3, o4, o5) where
@@ -385,7 +386,7 @@ instance (NvimObject o1, NvimObject o2, NvimObject o3, NvimObject o4, NvimObject
385386
<*> fromObject o3
386387
<*> fromObject o4
387388
<*> fromObject o5
388-
fromObject o = throwError $ "Expected ObjectArray, but got" <+> pretty (show o)
389+
fromObject o = throwError $ "Expected ObjectArray, but got" <+> viaShow o
389390

390391

391392
instance (NvimObject o1, NvimObject o2, NvimObject o3, NvimObject o4, NvimObject o5, NvimObject o6) => NvimObject (o1, o2, o3, o4, o5, o6) where
@@ -398,7 +399,7 @@ instance (NvimObject o1, NvimObject o2, NvimObject o3, NvimObject o4, NvimObject
398399
<*> fromObject o4
399400
<*> fromObject o5
400401
<*> fromObject o6
401-
fromObject o = throwError $ "Expected ObjectArray, but got" <+> pretty (show o)
402+
fromObject o = throwError $ "Expected ObjectArray, but got" <+> viaShow o
402403

403404

404405
instance (NvimObject o1, NvimObject o2, NvimObject o3, NvimObject o4, NvimObject o5, NvimObject o6, NvimObject o7) => NvimObject (o1, o2, o3, o4, o5, o6, o7) where
@@ -412,7 +413,7 @@ instance (NvimObject o1, NvimObject o2, NvimObject o3, NvimObject o4, NvimObject
412413
<*> fromObject o5
413414
<*> fromObject o6
414415
<*> fromObject o7
415-
fromObject o = throwError $ "Expected ObjectArray, but got" <+> pretty (show o)
416+
fromObject o = throwError $ "Expected ObjectArray, but got" <+> viaShow o
416417

417418

418419
instance (NvimObject o1, NvimObject o2, NvimObject o3, NvimObject o4, NvimObject o5, NvimObject o6, NvimObject o7, NvimObject o8) => NvimObject (o1, o2, o3, o4, o5, o6, o7, o8) where
@@ -427,7 +428,7 @@ instance (NvimObject o1, NvimObject o2, NvimObject o3, NvimObject o4, NvimObject
427428
<*> fromObject o6
428429
<*> fromObject o7
429430
<*> fromObject o8
430-
fromObject o = throwError $ "Expected ObjectArray, but got" <+> pretty (show o)
431+
fromObject o = throwError $ "Expected ObjectArray, but got" <+> viaShow o
431432

432433

433434
instance (NvimObject o1, NvimObject o2, NvimObject o3, NvimObject o4, NvimObject o5, NvimObject o6, NvimObject o7, NvimObject o8, NvimObject o9) => NvimObject (o1, o2, o3, o4, o5, o6, o7, o8, o9) where
@@ -443,7 +444,7 @@ instance (NvimObject o1, NvimObject o2, NvimObject o3, NvimObject o4, NvimObject
443444
<*> fromObject o7
444445
<*> fromObject o8
445446
<*> fromObject o9
446-
fromObject o = throwError $ "Expected ObjectArray, but got" <+> pretty (show o)
447+
fromObject o = throwError $ "Expected ObjectArray, but got" <+> viaShow o
447448

448449

449450
-- 1}}}

library/Neovim/Context.hs

+1-5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ module Neovim.Context (
1515

1616
Neovim,
1717
NeovimException(..),
18+
exceptionToDoc,
1819
FunctionMap,
1920
FunctionMapEntry,
2021
mkFunctionMap,
@@ -63,9 +64,6 @@ import Control.Monad.Reader
6364
import Control.Monad.State
6465
import Data.MessagePack (Object)
6566

66-
import Data.Text.Prettyprint.Doc (Pretty(..), defaultLayoutOptions, layoutPretty)
67-
import Data.Text.Prettyprint.Doc.Render.Text (renderStrict)
68-
6967

7068
-- | @'throw'@ specialized to a 'Pretty' value.
7169
err :: Doc AnsiStyle -> Neovim env a
@@ -85,8 +83,6 @@ errOnInvalidResult a = a >>= \case
8583

8684
Right x ->
8785
return x
88-
Left o ->
89-
(err . exceptionToDoc) o
9086

9187

9288

library/Neovim/Exceptions.hs

+1-3
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ module Neovim.Exceptions
2020
import Control.Exception (Exception)
2121
import Data.MessagePack (Object (..))
2222
import Data.String (IsString (..))
23-
import Data.Text (Text)
24-
import Data.Text.Prettyprint.Doc (Doc, Pretty (..),
25-
(<+>), viaShow)
23+
import Data.Text.Prettyprint.Doc (Doc, (<+>), viaShow)
2624
import Data.Text.Prettyprint.Doc.Render.Terminal (AnsiStyle)
2725
import Data.Typeable (Typeable)
2826

library/Neovim/Plugin.hs

-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ import Data.Map (Map)
5252
import qualified Data.Map as Map
5353
import Data.Maybe (catMaybes)
5454
import Data.MessagePack
55-
import Data.Text.Prettyprint.Doc (Doc, Pretty (..), viaShow, (<+>))
5655
import Data.Traversable (forM)
5756
import System.Log.Logger
5857
import UnliftIO.Async (Async, async, race)

0 commit comments

Comments
 (0)