@@ -48,12 +48,10 @@ import Data.Int (Int16, Int32, Int64,
48
48
import qualified Data.Map.Strict as SMap
49
49
import Data.MessagePack
50
50
import Data.Monoid
51
- import Data.String (IsString (.. ))
52
51
import Data.Text as Text (Text )
53
52
import Data.Text.Prettyprint.Doc (Doc , Pretty (.. ),
54
53
defaultLayoutOptions ,
55
- layoutPretty ,
56
- lparen , rparen ,
54
+ layoutPretty , viaShow ,
57
55
(<+>) )
58
56
import qualified Data.Text.Prettyprint.Doc as P
59
57
import Data.Text.Prettyprint.Doc.Render.Terminal (AnsiStyle ,
@@ -76,6 +74,9 @@ import Prelude
76
74
infixr 5 +:
77
75
78
76
-- | Convenient operator to create a list of 'Object' from normal values.
77
+ -- @
78
+ -- values +: of :+ different :+ types :+ can +: be +: combined +: this +: way +: []
79
+ -- @
79
80
(+:) :: (NvimObject o ) => o -> [Object ] -> [Object ]
80
81
o +: os = toObject o : os
81
82
@@ -157,7 +158,7 @@ instance NvimObject Double where
157
158
fromObject (ObjectInt o) = return $ fromIntegral o
158
159
fromObject (ObjectUInt o) = return $ fromIntegral o
159
160
fromObject o = throwError $ " Expected ObjectDouble, but got"
160
- <+> pretty ( show o)
161
+ <+> viaShow o
161
162
162
163
163
164
instance NvimObject Integer where
@@ -167,7 +168,7 @@ instance NvimObject Integer where
167
168
fromObject (ObjectUInt o) = return $ toInteger o
168
169
fromObject (ObjectDouble o) = return $ round o
169
170
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
171
172
172
173
173
174
instance NvimObject Int64 where
@@ -177,7 +178,7 @@ instance NvimObject Int64 where
177
178
fromObject (ObjectUInt o) = return $ fromIntegral o
178
179
fromObject (ObjectDouble o) = return $ round o
179
180
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
181
182
182
183
183
184
instance NvimObject Int32 where
@@ -187,7 +188,7 @@ instance NvimObject Int32 where
187
188
fromObject (ObjectUInt i) = return $ fromIntegral i
188
189
fromObject (ObjectDouble o) = return $ round o
189
190
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
191
192
192
193
193
194
instance NvimObject Int16 where
@@ -197,7 +198,7 @@ instance NvimObject Int16 where
197
198
fromObject (ObjectUInt i) = return $ fromIntegral i
198
199
fromObject (ObjectDouble o) = return $ round o
199
200
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
201
202
202
203
203
204
instance NvimObject Int8 where
@@ -207,7 +208,7 @@ instance NvimObject Int8 where
207
208
fromObject (ObjectUInt i) = return $ fromIntegral i
208
209
fromObject (ObjectDouble o) = return $ round o
209
210
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
211
212
212
213
213
214
instance NvimObject Word where
@@ -217,7 +218,7 @@ instance NvimObject Word where
217
218
fromObject (ObjectUInt i) = return $ fromIntegral i
218
219
fromObject (ObjectDouble o) = return $ round o
219
220
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
221
222
222
223
223
224
instance NvimObject Word64 where
@@ -227,7 +228,7 @@ instance NvimObject Word64 where
227
228
fromObject (ObjectUInt i) = return $ fromIntegral i
228
229
fromObject (ObjectDouble o) = return $ round o
229
230
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
231
232
232
233
233
234
instance NvimObject Word32 where
@@ -237,7 +238,7 @@ instance NvimObject Word32 where
237
238
fromObject (ObjectUInt i) = return $ fromIntegral i
238
239
fromObject (ObjectDouble o) = return $ round o
239
240
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
241
242
242
243
243
244
instance NvimObject Word16 where
@@ -247,7 +248,7 @@ instance NvimObject Word16 where
247
248
fromObject (ObjectUInt i) = return $ fromIntegral i
248
249
fromObject (ObjectDouble o) = return $ round o
249
250
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
251
252
252
253
253
254
instance NvimObject Word8 where
@@ -257,7 +258,7 @@ instance NvimObject Word8 where
257
258
fromObject (ObjectUInt i) = return $ fromIntegral i
258
259
fromObject (ObjectDouble o) = return $ round o
259
260
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
261
262
262
263
263
264
instance NvimObject Int where
@@ -267,22 +268,22 @@ instance NvimObject Int where
267
268
fromObject (ObjectUInt i) = return $ fromIntegral i
268
269
fromObject (ObjectDouble o) = return $ round o
269
270
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
271
272
272
273
273
274
instance {-# OVERLAPPING #-} NvimObject [Char ] where
274
275
toObject = ObjectBinary . UTF8. fromString
275
276
276
277
fromObject (ObjectBinary o) = return $ UTF8. toString o
277
278
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
279
280
280
281
281
282
instance {-# OVERLAPPABLE #-} NvimObject o => NvimObject [o ] where
282
283
toObject = ObjectArray . map toObject
283
284
284
285
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
286
287
287
288
288
289
instance NvimObject o => NvimObject (Maybe o ) where
@@ -320,23 +321,23 @@ instance (Ord key, NvimObject key, NvimObject val)
320
321
. (fromObject *** fromObject))
321
322
. SMap. toList) om
322
323
323
- fromObject o = throwError $ " Expected ObjectMap, but got" <+> pretty ( show o)
324
+ fromObject o = throwError $ " Expected ObjectMap, but got" <+> viaShow o
324
325
325
326
326
327
instance NvimObject Text where
327
328
toObject = ObjectBinary . encodeUtf8
328
329
329
330
fromObject (ObjectBinary o) = return $ decodeUtf8 o
330
331
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
332
333
333
334
334
335
instance NvimObject ByteString where
335
336
toObject = ObjectBinary
336
337
337
338
fromObject (ObjectBinary o) = return o
338
339
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
340
341
341
342
342
343
instance NvimObject Object where
@@ -353,7 +354,7 @@ instance (NvimObject o1, NvimObject o2) => NvimObject (o1, o2) where
353
354
fromObject (ObjectArray [o1, o2]) = (,)
354
355
<$> fromObject o1
355
356
<*> fromObject o2
356
- fromObject o = throwError $ " Expected ObjectArray, but got" <+> pretty ( show o)
357
+ fromObject o = throwError $ " Expected ObjectArray, but got" <+> viaShow o
357
358
358
359
instance (NvimObject o1 , NvimObject o2 , NvimObject o3 ) => NvimObject (o1 , o2 , o3 ) where
359
360
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
362
363
<$> fromObject o1
363
364
<*> fromObject o2
364
365
<*> fromObject o3
365
- fromObject o = throwError $ " Expected ObjectArray, but got" <+> pretty ( show o)
366
+ fromObject o = throwError $ " Expected ObjectArray, but got" <+> viaShow o
366
367
367
368
368
369
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
373
374
<*> fromObject o2
374
375
<*> fromObject o3
375
376
<*> fromObject o4
376
- fromObject o = throwError $ " Expected ObjectArray, but got" <+> pretty ( show o)
377
+ fromObject o = throwError $ " Expected ObjectArray, but got" <+> viaShow o
377
378
378
379
379
380
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
385
386
<*> fromObject o3
386
387
<*> fromObject o4
387
388
<*> fromObject o5
388
- fromObject o = throwError $ " Expected ObjectArray, but got" <+> pretty ( show o)
389
+ fromObject o = throwError $ " Expected ObjectArray, but got" <+> viaShow o
389
390
390
391
391
392
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
398
399
<*> fromObject o4
399
400
<*> fromObject o5
400
401
<*> fromObject o6
401
- fromObject o = throwError $ " Expected ObjectArray, but got" <+> pretty ( show o)
402
+ fromObject o = throwError $ " Expected ObjectArray, but got" <+> viaShow o
402
403
403
404
404
405
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
412
413
<*> fromObject o5
413
414
<*> fromObject o6
414
415
<*> fromObject o7
415
- fromObject o = throwError $ " Expected ObjectArray, but got" <+> pretty ( show o)
416
+ fromObject o = throwError $ " Expected ObjectArray, but got" <+> viaShow o
416
417
417
418
418
419
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
427
428
<*> fromObject o6
428
429
<*> fromObject o7
429
430
<*> fromObject o8
430
- fromObject o = throwError $ " Expected ObjectArray, but got" <+> pretty ( show o)
431
+ fromObject o = throwError $ " Expected ObjectArray, but got" <+> viaShow o
431
432
432
433
433
434
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
443
444
<*> fromObject o7
444
445
<*> fromObject o8
445
446
<*> fromObject o9
446
- fromObject o = throwError $ " Expected ObjectArray, but got" <+> pretty ( show o)
447
+ fromObject o = throwError $ " Expected ObjectArray, but got" <+> viaShow o
447
448
448
449
449
450
-- 1}}}
0 commit comments