Skip to content

Commit

Permalink
Bump version to 0.8.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Bodigrim committed Nov 13, 2024
1 parent 582141d commit 22227ef
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
8 changes: 8 additions & 0 deletions Control/Monad/Logic.hs
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@ instance {-# OVERLAPPABLE #-} (Monad m) => MonadLogic (LogicT m) where
once m = LogicT $ \sk fk -> unLogicT m (\a _ -> sk a fk) fk
lnot m = LogicT $ \sk fk -> unLogicT m (\_ _ -> fk) (sk () fk)

-- | @since 0.8.2.0
instance {-# INCOHERENT #-} MonadLogic Logic where
-- Same as in the generic instance above
msplit m = lift $ unLogicT m ssk (return Nothing)
Expand Down Expand Up @@ -591,29 +592,36 @@ instance MonadError e m => MonadError e (LogicT m) where
handle r = r `catchError` \e -> unLogicT (h e) sk fk
in handle $ unLogicT m (\a -> sk a . handle) fk

-- | @since 0.8.2.0
instance MonadThrow m => MonadThrow (LogicT m) where
throwM = lift . throwM

-- | @since 0.8.2.0
instance MonadCatch m => MonadCatch (LogicT m) where
catch m h = LogicT $ \sk fk -> let
handle r = r `catch` \e -> unLogicT (h e) sk fk
in handle $ unLogicT m (\a -> sk a . handle) fk

-- | @since 0.8.2.0
instance IsList (Logic a) where
type Item (Logic a) = a
fromList xs = LogicT $ \cons nil -> L.foldr cons nil xs
toList = observeAll

-- | @since 0.8.2.0
instance Eq a => Eq (Logic a) where
(==) = (==) `on` observeAll

-- | @since 0.8.2.0
instance Ord a => Ord (Logic a) where
compare = compare `on` observeAll

-- | @since 0.8.2.0
instance Show a => Show (Logic a) where
showsPrec p xs = showParen (p > 10) $
showString "fromList " . shows (toList xs)

-- | @since 0.8.2.0
instance Read a => Read (Logic a) where
readPrec = parens $ prec 10 $ do
Ident "fromList" <- lexP
Expand Down
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 0.8.2.0

* Add instances for `MonadThrow` and `MonadCatch`.
* Add instances `Eq`, `Ord`, `Show`, `Read`, `IsList` for `Logic a`.
* Speed up `instance MonadLogic Logic` with a trick to determine whether a callback is a constant failure.

# 0.8.1.0

* Add `instance MonadLogic (Control.Monad.Writer.CPS.WriterT w m)`.
Expand Down
2 changes: 1 addition & 1 deletion logict.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: logict
version: 0.8.1.0
version: 0.8.2.0
license: BSD3
license-file: LICENSE
copyright:
Expand Down

0 comments on commit 22227ef

Please sign in to comment.