Skip to content

Commit

Permalink
Make hlint happy
Browse files Browse the repository at this point in the history
  • Loading branch information
Bodigrim committed Aug 8, 2024
1 parent 9ce97e3 commit c6fc501
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions Control/Monad/Logic.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveTraversable #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeFamilies #-}
Expand All @@ -32,6 +33,9 @@
{-# LANGUAGE Trustworthy #-}
#endif

{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-}
{-# HLINT ignore "Avoid restricted function" #-}

module Control.Monad.Logic (
module Control.Monad.Logic.Class,
-- * The Logic monad
Expand Down Expand Up @@ -88,6 +92,10 @@ import GHC.IsList (IsList(..))
import GHC.Exts (IsList(..))
#endif

#if MIN_VERSION_base(4,18,0)
import qualified Data.Foldable1 as F1
#endif

import Control.Monad.Logic.Class

-------------------------------------------------------------------------
Expand Down Expand Up @@ -151,9 +159,9 @@ observeManyT n m
| n <= 0 = return []
| n == 1 = unLogicT m (\a _ -> return [a]) (return [])
| otherwise = unLogicT (msplit m) sk (return [])
where
sk Nothing _ = return []
sk (Just (a, m')) _ = (a:) `liftM` observeManyT (n-1) m'
where
sk Nothing _ = return []
sk (Just (a, m')) _ = (a:) <$> observeManyT (n-1) m'

-------------------------------------------------------------------------
-- | Runs a 'LogicT' computation with the specified initial success and
Expand Down Expand Up @@ -409,7 +417,11 @@ instance MonadPlus (LogicT m) where
-- | @since 0.7.0.3
instance Semigroup (LogicT m a) where
(<>) = mplus
#if MIN_VERSION_base(4,18,0)
sconcat = F1.foldr1 mplus
#else
sconcat = F.foldr1 mplus
#endif

-- | @since 0.7.0.3
instance Monoid (LogicT m a) where
Expand Down Expand Up @@ -471,7 +483,7 @@ toML :: Applicative m => LogicT m a -> ML m a
toML (LogicT q) = ML $ q (\a m -> pure $ ConsML a (ML m)) (pure EmptyML)

fromML :: Monad m => ML m a -> LogicT m a
fromML (ML m) = lift m >>= \r -> case r of
fromML (ML m) = lift m >>= \case
EmptyML -> empty
ConsML a xs -> pure a <|> fromML xs

Expand Down

0 comments on commit c6fc501

Please sign in to comment.