mirror of
https://github.com/polysemy-research/polysemy.git
synced 2024-12-12 13:06:18 +03:00
loopbreak nondet
This commit is contained in:
parent
df7c9be46d
commit
9dd70fa096
@ -1,4 +1,5 @@
|
|||||||
{-# LANGUAGE DeriveAnyClass #-}
|
{-# LANGUAGE DeriveAnyClass #-}
|
||||||
|
{-# LANGUAGE TemplateHaskell #-}
|
||||||
|
|
||||||
module Polysemy.NonDet
|
module Polysemy.NonDet
|
||||||
( NonDet (..)
|
( NonDet (..)
|
||||||
@ -47,12 +48,14 @@ instance Monad (NonDetC m) where
|
|||||||
{-# INLINE (>>=) #-}
|
{-# INLINE (>>=) #-}
|
||||||
|
|
||||||
|
|
||||||
runNonDet :: Alternative f => Semantic (NonDet ': r) a -> Semantic r (f a)
|
inlineRecursiveCalls [d|
|
||||||
runNonDet (Semantic m) = Semantic $ \k -> runNonDetC $ m $ \u ->
|
runNonDet :: Alternative f => Semantic (NonDet ': r) a -> Semantic r (f a)
|
||||||
case decomp u of
|
runNonDet (Semantic m) = Semantic $ \k -> runNonDetC $ m $ \u ->
|
||||||
Left x -> NonDetC $ \cons nil -> do
|
case decomp u of
|
||||||
z <- k $ weave [()] (fmap concat . traverse runNonDet) x
|
Left x -> NonDetC $ \cons nil -> do
|
||||||
foldr cons nil z
|
z <- k $ weave [()] (fmap concat . traverse runNonDet) x
|
||||||
Right Empty -> empty
|
foldr cons nil z
|
||||||
Right (Choose ek) -> pure (ek True) <|> pure (ek False)
|
Right Empty -> empty
|
||||||
|
Right (Choose ek) -> pure (ek True) <|> pure (ek False)
|
||||||
|
|]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user