Skip to content

Commit bef903b

Browse files
committed
Use Lysxia's implementation
1 parent b52baa8 commit bef903b

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/Data/Aeson/Types/Internal.hs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ import Data.Char (isLower, isUpper, toLower, isAlpha, isAlphaNum)
9595
import Data.Aeson.Key (Key)
9696
import Data.Data (Data)
9797
import Data.Foldable (foldl')
98-
import Data.Functor.Identity (Identity (..))
9998
import Data.Hashable (Hashable(..))
10099
import Data.List (intercalate)
101100
import Data.Scientific (Scientific)
@@ -313,10 +312,14 @@ instance Monad.Monad Parser where
313312
--
314313
-- @since 2.1.0.0
315314
instance MonadFix Parser where
316-
mfix f = let p = f (lower [] p) in p
315+
mfix f = Parser $ \path kf ks -> let x = runParser (f (fromISuccess x)) path IError ISuccess in
316+
case x of
317+
IError p e -> kf p e
318+
ISuccess y -> ks y
317319
where
318-
lower :: JSONPath -> Parser a -> a
319-
lower path p = runIdentity (runParser p path (error "mfix @Aeson.Parser") Identity)
320+
fromISuccess :: IResult a -> a
321+
fromISuccess (ISuccess x) = x
322+
fromISuccess (IError path msg) = error $ "mfix @Aeson.Parser: " ++ formatPath path ++ ": " ++ msg
320323

321324
instance Fail.MonadFail Parser where
322325
fail msg = Parser $ \path kf _ks -> kf (reverse path) msg

0 commit comments

Comments
 (0)