4
4
{-# LANGUAGE FlexibleContexts #-}
5
5
{-# LANGUAGE FlexibleInstances #-}
6
6
{-# LANGUAGE GADTs #-}
7
+ {-# LANGUAGE InstanceSigs #-}
7
8
{-# LANGUAGE MultiParamTypeClasses #-}
8
9
{-# LANGUAGE NoImplicitPrelude #-}
9
10
{-# LANGUAGE OverloadedStrings #-}
10
11
{-# LANGUAGE PolyKinds #-}
11
12
{-# LANGUAGE RecordWildCards #-}
12
13
{-# LANGUAGE ScopedTypeVariables #-}
13
- {-# LANGUAGE TypeApplications #-}
14
14
{-# LANGUAGE TypeOperators #-}
15
15
{-# LANGUAGE TupleSections #-}
16
16
{-# LANGUAGE UndecidableInstances #-}
@@ -159,8 +159,7 @@ import qualified Data.Primitive.Types as PM
159
159
import qualified Data.Primitive.PrimArray as PM
160
160
161
161
import Data.Coerce (Coercible , coerce )
162
- import GHC.TypeNats
163
- import Data.Kind (Type )
162
+ import GHC.TypeLits
164
163
165
164
parseIndexedJSON :: (Value -> Parser a ) -> Int -> Value -> Parser a
166
165
parseIndexedJSON p idx value = p value <?> Index idx
@@ -1434,12 +1433,15 @@ instance ( IsRecord f isRecord
1434
1433
, FromTaggedFlatObject' arity f isRecord
1435
1434
, Constructor c
1436
1435
) => FromTaggedFlatObject arity (C1 c f ) where
1436
+ parseTaggedFlatObject :: Text :* TypeName :* Options :* FromArgs arity a
1437
+ -> Object
1438
+ -> Maybe (Parser (C1 c f a ))
1437
1439
parseTaggedFlatObject (tag :* p@ (_ :* opts :* _)) obj
1438
- | tag == tag' = Just $ fmap M1 $ (unTagged @ Type @ isRecord ) $ parseTaggedFlatObject' (cname :* p) obj
1440
+ | tag == tag' = Just $ fmap M1 $ (unTagged :: Tagged isRecord ( Parser ( f a )) -> Parser ( f a ) ) $ parseTaggedFlatObject' (cname :* p) obj
1439
1441
| otherwise = Nothing
1440
1442
where
1441
1443
tag' = pack $ constructorTagModifier opts cname
1442
- cname = conName (undefined :: M1 i c a p )
1444
+ cname = conName (undefined :: M1 i c f p )
1443
1445
1444
1446
class FromTaggedFlatObject' arity f isRecord where
1445
1447
parseTaggedFlatObject' :: ConName :* TypeName :* Options :* FromArgs arity a
@@ -1453,7 +1455,7 @@ instance FromTaggedFlatObject' arity U1 False where
1453
1455
parseTaggedFlatObject' _ _ = Tagged (pure U1 )
1454
1456
1455
1457
instance OVERLAPPABLE_ (PositionFromObject 1 arity f ) => FromTaggedFlatObject' arity f False where
1456
- parseTaggedFlatObject' (_ :* p) obj = Tagged (positionFromObject (Proxy @ 1 ) p obj)
1458
+ parseTaggedFlatObject' (_ :* p) obj = Tagged (positionFromObject (Proxy :: Proxy 1 ) p obj)
1457
1459
1458
1460
class KnownNat n => PositionFromObject n arity f where
1459
1461
positionFromObject :: Proxy n
@@ -1463,15 +1465,15 @@ class KnownNat n => PositionFromObject n arity f where
1463
1465
1464
1466
instance (KnownNat n , GFromJSON arity a ) => PositionFromObject n arity (S1 m a ) where
1465
1467
positionFromObject _ (_ :* opts :* fargs) obj =
1466
- explicitParseField (gParseJSON opts fargs) obj $ pack $ show $ natVal $ Proxy @ n
1468
+ explicitParseField (gParseJSON opts fargs) obj $ pack $ show $ natVal ( Proxy :: Proxy n )
1467
1469
1468
1470
instance ( PositionFromObject n arity f
1469
1471
, PositionFromObject (n + 1 ) arity g
1470
1472
) => PositionFromObject n arity (f :*: g ) where
1471
1473
positionFromObject _ p obj =
1472
1474
(:*:)
1473
- <$> positionFromObject (Proxy @ n ) p obj
1474
- <*> positionFromObject (Proxy @ (n + 1 )) p obj
1475
+ <$> positionFromObject (Proxy :: Proxy n ) p obj
1476
+ <*> positionFromObject (Proxy :: Proxy (n + 1 )) p obj
1475
1477
1476
1478
--------------------------------------------------------------------------------
1477
1479
0 commit comments