@@ -48,12 +48,10 @@ import Data.Int (Int16, Int32, Int64,
4848import qualified Data.Map.Strict as SMap
4949import Data.MessagePack
5050import Data.Monoid
51- import Data.String (IsString (.. ))
5251import Data.Text as Text (Text )
5352import Data.Text.Prettyprint.Doc (Doc , Pretty (.. ),
5453 defaultLayoutOptions ,
55- layoutPretty ,
56- lparen , rparen ,
54+ layoutPretty , viaShow ,
5755 (<+>) )
5856import qualified Data.Text.Prettyprint.Doc as P
5957import Data.Text.Prettyprint.Doc.Render.Terminal (AnsiStyle ,
@@ -76,6 +74,9 @@ import Prelude
7674infixr 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 ]
8081o +: 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
163164instance 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
173174instance 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
183184instance 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
193194instance 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
203204instance 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
213214instance 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
223224instance 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
233234instance 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
243244instance 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
253254instance 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
263264instance 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
273274instance {-# 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
281282instance {-# 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
288289instance 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
326327instance 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
334335instance 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
342343instance 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
358359instance (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
368369instance (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
379380instance (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
391392instance (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
404405instance (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
418419instance (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
433434instance (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}}}
0 commit comments