Skip to content

Commit f3cf912

Browse files
committed
Add fix2
1 parent ab141f0 commit f3cf912

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/Text/Parsing/Parser/Combinators.purs.hs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import Prelude
44

55
import Data.Maybe
66
import Data.Array
7+
import Data.Tuple
78
import Data.Either
89

910
import Control.Monad
@@ -18,6 +19,11 @@ import Text.Parsing.Parser
1819
fix :: forall m s a. (ParserT m s a -> ParserT m s a) -> ParserT m s a
1920
fix f = ParserT (StateT (\s -> runStateT (unParserT (f (fix f))) s))
2021

22+
fix2 :: forall m s a b. (Tuple (ParserT m s a) (ParserT m s b) -> Tuple (ParserT m s a) (ParserT m s b)) -> Tuple (ParserT m s a) (ParserT m s b)
23+
fix2 f = Tuple
24+
(ParserT (StateT (\s -> runStateT (unParserT (fst (f (fix2 f)))) s)))
25+
(ParserT (StateT (\s -> runStateT (unParserT (snd (f (fix2 f)))) s)))
26+
2127
many :: forall m s a. (Monad m) => ParserT s m a -> ParserT s m [a]
2228
many p = many1 p <|> return []
2329

0 commit comments

Comments
 (0)