Skip to content

Commit

Permalink
remove monad, typeoperators, and some spurious imports warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
vincenthz committed Aug 19, 2022
1 parent 9a2d2a5 commit 7abf0e1
Show file tree
Hide file tree
Showing 39 changed files with 39 additions and 45 deletions.
1 change: 1 addition & 0 deletions basement/Basement/Block.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
{-# LANGUAGE UnboxedTuples #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE TypeOperators #-}
module Basement.Block
( Block(..)
, MutableBlock(..)
Expand Down
1 change: 0 additions & 1 deletion basement/Basement/Block/Base.hs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ instance PrimType ty => Semigroup (Block ty) where
(<>) = append
instance PrimType ty => Monoid (Block ty) where
mempty = empty
mappend = append
mconcat = concat

instance PrimType ty => IsList (Block ty) where
Expand Down
5 changes: 2 additions & 3 deletions basement/Basement/Block/Builder.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
-- Block builder

{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE TypeOperators #-}

module Basement.Block.Builder
( Builder
Expand Down Expand Up @@ -57,9 +58,7 @@ instance Semigroup Builder where
{-# INLINABLE (<>) #-}
instance Monoid Builder where
mempty = empty
{-# INLINE mempty #-}
mappend = append
{-# INLINABLE mappend #-}
{-# INLINABLE mempty #-}
mconcat = concat
{-# INLINABLE mconcat #-}

Expand Down
1 change: 1 addition & 0 deletions basement/Basement/Bounded.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE TypeOperators #-}
module Basement.Bounded
( Zn64
, unZn64
Expand Down
2 changes: 1 addition & 1 deletion basement/Basement/BoxedArray.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE TypeOperators #-}
module Basement.BoxedArray
( Array
, MArray
Expand Down Expand Up @@ -132,7 +133,6 @@ instance Semigroup (Array a) where
(<>) = append
instance Monoid (Array a) where
mempty = empty
mappend = append
mconcat = concat

instance Show a => Show (Array a) where
Expand Down
1 change: 1 addition & 0 deletions basement/Basement/Cast.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
{-# LANGUAGE DefaultSignatures #-}
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeOperators #-}
-- |
-- Module : Basement.Cast
-- License : BSD-style
Expand Down
4 changes: 2 additions & 2 deletions basement/Basement/Compat/MonadTrans.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ instance Monad m => Applicative (State s m) where
(a,s3) <- runState fa s2
return (ab a, s3)
instance Monad m => Monad (State r m) where
return a = State $ \st -> return (a,st)
return = pure
ma >>= mb = State $ \s1 -> do
(a,s2) <- runState ma s1
runState (mb a) s2
Expand All @@ -44,7 +44,7 @@ instance Monad m => Applicative (Reader r m) where
ab <- runReader fab r
return $ ab a
instance Monad m => Monad (Reader r m) where
return a = Reader $ \_ -> return a
return = pure
ma >>= mb = Reader $ \r -> do
a <- runReader ma r
runReader (mb a) r
1 change: 1 addition & 0 deletions basement/Basement/IntegralConv.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
{-# LANGUAGE UnboxedTuples #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE TypeOperators #-}
module Basement.IntegralConv
( IntegralDownsize(..)
, IntegralUpsize(..)
Expand Down
6 changes: 0 additions & 6 deletions basement/Basement/Numerical/Conversion.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@ import Basement.Compat.Primitive
import GHC.IntWord64
#endif

#if __GLASGOW_HASKELL__ >= 904

#else

#endif

intToInt64 :: Int -> Int64
#if WORD_SIZE_IN_BITS == 64
#if __GLASGOW_HASKELL__ >= 904
Expand Down
1 change: 0 additions & 1 deletion basement/Basement/Types/OffsetSize.hs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ instance Semigroup (CountOf ty) where

instance Monoid (CountOf ty) where
mempty = azero
mappend = (+)
mconcat = foldl' (+) 0

sizeOfE :: CountOf Word8 -> CountOf ty -> CountOf Word8
Expand Down
1 change: 0 additions & 1 deletion basement/Basement/UArray/Base.hs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ instance PrimType ty => Semigroup (UArray ty) where
(<>) = append
instance PrimType ty => Monoid (UArray ty) where
mempty = empty
mappend = append
mconcat = concat

instance PrimType ty => IsList (UArray ty) where
Expand Down
1 change: 0 additions & 1 deletion foundation/Foundation/Array/Bitmap.hs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ instance Semigroup Bitmap where
(<>) = append
instance Monoid Bitmap where
mempty = empty
mappend = append
mconcat = concat

type instance C.Element Bitmap = Bool
Expand Down
1 change: 0 additions & 1 deletion foundation/Foundation/Array/Chunked/Unboxed.hs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ instance Semigroup (ChunkedUArray a) where
(<>) = append
instance Monoid (ChunkedUArray a) where
mempty = empty
mappend = append
mconcat = concat

type instance C.Element (ChunkedUArray ty) = ty
Expand Down
2 changes: 1 addition & 1 deletion foundation/Foundation/Check/Gen.hs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ instance Applicative Gen where
in ab a

instance Monad Gen where
return a = Gen (\_ _ -> a)
return = pure
ma >>= mb = Gen $ \rng params ->
let (r1,r2) = genGenerator rng
a = runGen ma r1 params
Expand Down
10 changes: 6 additions & 4 deletions foundation/Foundation/Check/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -273,10 +273,12 @@ testCheckPlan name actions = do
then return (GroupResult name 0 (planValidations st) [])
else do
displayCurrent name
forM_ fails $ \(PropertyResult name' nb r) ->
case r of
PropertySuccess -> whenVerbose $ displayPropertySucceed (name <> ": " <> name') nb
PropertyFailed w -> whenErrorOnly $ displayPropertyFailed (name <> ": " <> name') nb w
forM_ fails $ \fail -> case fail of
PropertyResult name' nb r ->
case r of
PropertySuccess -> whenVerbose $ displayPropertySucceed (name <> ": " <> name') nb
PropertyFailed w -> whenErrorOnly $ displayPropertyFailed (name <> ": " <> name') nb w
_ -> error "should not happen"
return (GroupResult name (length fails) (planValidations st) fails)

testProperty :: String -> Property -> CheckMain TestResult
Expand Down
1 change: 0 additions & 1 deletion foundation/Foundation/Check/Property.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ module Foundation.Check.Property
) where

import Basement.Imports hiding (Typeable)
import Data.Proxy (Proxy(..))
import Basement.Compat.Typeable
import Foundation.Check.Gen
import Foundation.Check.Arbitrary
Expand Down
4 changes: 1 addition & 3 deletions foundation/Foundation/Class/Storable.hs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ module Foundation.Class.Storable

#include "MachDeps.h"

import GHC.Types (Double, Float)

import Foreign.Ptr (castPtr)
import qualified Foreign.Ptr
import qualified Foreign.Storable (peek, poke)
Expand All @@ -42,7 +40,7 @@ import Basement.Types.OffsetSize
import Basement.Types.Word128 (Word128(..))
import Basement.Types.Word256 (Word256(..))
import Foundation.Collection
import Foundation.Collection.Buildable (builderLift, build_)
import Foundation.Collection.Buildable (builderLift)
import Basement.PrimType
import Basement.Endianness
import Foundation.Numerical
Expand Down
3 changes: 2 additions & 1 deletion foundation/Foundation/Collection/Buildable.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import Basement.Compat.Base
import Basement.Monad
import Basement.MutableBuilder
import Basement.Compat.MonadTrans
import Data.Kind (Type)

-- $setup
-- >>> import Control.Monad.ST
Expand All @@ -42,7 +43,7 @@ class Buildable col where
{-# MINIMAL append, build #-}

-- | Mutable collection type used for incrementally writing chunks.
type Mutable col :: * -> *
type Mutable col :: Type -> Type

-- | Unit of the smallest step possible in an `append` operation.
--
Expand Down
1 change: 1 addition & 0 deletions foundation/Foundation/Collection/Collection.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE TypeOperators #-}
module Foundation.Collection.Collection
( Collection(..)
-- * NonEmpty Property
Expand Down
1 change: 1 addition & 0 deletions foundation/Foundation/Collection/InnerFunctor.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{-# LANGUAGE DefaultSignatures #-}
{-# LANGUAGE TypeOperators #-}
module Foundation.Collection.InnerFunctor
( InnerFunctor(..)
) where
Expand Down
1 change: 1 addition & 0 deletions foundation/Foundation/Collection/Sequential.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
{-# LANGUAGE DefaultSignatures #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeOperators #-}
module Foundation.Collection.Sequential
( Sequential(..)
) where
Expand Down
1 change: 1 addition & 0 deletions foundation/Foundation/Collection/Zippable.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE TypeOperators #-}
module Foundation.Collection.Zippable
( BoxedZippable(..)
, Zippable(..)
Expand Down
1 change: 1 addition & 0 deletions foundation/Foundation/Conduit.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE TypeOperators #-}
module Foundation.Conduit
( Conduit
, ResourceT
Expand Down
2 changes: 1 addition & 1 deletion foundation/Foundation/Conduit/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ instance Applicative m => Applicative (Pipe l i o u m) where
{-# INLINE (<*>) #-}

instance (Functor m, Monad m) => Monad (Pipe l i o u m) where
return = Done
return = pure
{-# INLINE return #-}

Yield p c o >>= fp = Yield (p >>= fp) c o
Expand Down
2 changes: 0 additions & 2 deletions foundation/Foundation/Conduit/Textual.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ module Foundation.Conduit.Textual
) where

import Basement.Imports hiding (throw)
import Basement.UArray (UArray)
import Foundation.String (String)
import Foundation.Collection
import qualified Basement.String as S
import Foundation.Conduit.Internal
Expand Down
2 changes: 1 addition & 1 deletion foundation/Foundation/Exception.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Foundation.Exception
) where

import Basement.Imports
import Control.Exception (Exception, SomeException)
import Control.Exception (SomeException)
import Foundation.Monad.Exception

finally :: MonadBracket m => m a -> m b -> m a
Expand Down
5 changes: 2 additions & 3 deletions foundation/Foundation/Format/CSV/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,13 @@ module Foundation.Format.CSV.Types
) where

import Basement.Imports
import Basement.BoxedArray (Array, length, unsafeIndex)
import Basement.BoxedArray (length, unsafeIndex)
import Basement.NormalForm (NormalForm(..))
import Basement.From (Into, into)
import Basement.String (String, any, elem, null, uncons)
import Basement.String (any, elem, null, uncons)
import qualified Basement.String as String (singleton)
import Basement.Types.Word128 (Word128)
import Basement.Types.Word256 (Word256)
import Basement.Types.OffsetSize (Offset, CountOf)
import Foundation.Collection.Element (Element)
import Foundation.Collection.Collection (Collection, nonEmpty_)
import Foundation.Collection.Sequential (Sequential)
Expand Down
3 changes: 1 addition & 2 deletions foundation/Foundation/List/DList.hs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ instance Semigroup (DList a) where
(<>) dl1 dl2 = DList $ unDList dl1 . unDList dl2
instance Monoid (DList a) where
mempty = DList id
mappend dl1 dl2 = DList $ unDList dl1 . unDList dl2

instance Functor DList where
fmap f = foldr (cons . f) mempty
Expand All @@ -48,7 +47,7 @@ instance Applicative DList where

instance Monad DList where
(>>=) m k = foldr (mappend . k) mempty m
return = singleton
return = pure

type instance Element (DList a) = a

Expand Down
3 changes: 1 addition & 2 deletions foundation/Foundation/Monad.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import Foundation.Monad.MonadIO
import Foundation.Monad.Exception
import Foundation.Monad.Transformer
import Foundation.Numerical
import Control.Applicative (liftA2)

#if MIN_VERSION_base(4,8,0)
import Data.Functor.Identity
Expand Down Expand Up @@ -66,5 +65,5 @@ replicateM (CountOf count) f = loop count
where
loop cnt
| cnt <= 0 = pure []
| otherwise = liftA2 (:) f (loop (cnt - 1))
| otherwise = (:) <$> f <*> (loop (cnt - 1))
{-# INLINEABLE replicateM #-}
2 changes: 1 addition & 1 deletion foundation/Foundation/Monad/Except.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ instance Monad m => MonadFailure (ExceptT e m) where
mFail = ExceptT . pure . Left

instance Monad m => Monad (ExceptT e m) where
return a = ExceptT $ return (Right a)
return = pure
m >>= k = ExceptT $ do
a <- runExceptT m
case a of
Expand Down
2 changes: 1 addition & 1 deletion foundation/Foundation/Monad/Identity.hs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ instance Applicative m => Applicative (IdentityT m) where
{-# INLINE (<*>) #-}

instance Monad m => Monad (IdentityT m) where
return x = IdentityT (return x)
return = pure
{-# INLINE return #-}
ma >>= mb = IdentityT $ runIdentityT ma >>= runIdentityT . mb
{-# INLINE (>>=) #-}
Expand Down
2 changes: 1 addition & 1 deletion foundation/Foundation/Monad/Reader.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ instance Applicative m => Applicative (ReaderT r m) where
{-# INLINE (<*>) #-}

instance Monad m => Monad (ReaderT r m) where
return a = ReaderT $ const (return a)
return = pure
{-# INLINE return #-}
ma >>= mab = ReaderT $ \r -> runReaderT ma r >>= \a -> runReaderT (mab a) r
{-# INLINE (>>=) #-}
Expand Down
2 changes: 1 addition & 1 deletion foundation/Foundation/Monad/State.hs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ instance (Applicative m, Monad m) => Applicative (StateT s m) where
{-# INLINE (<*>) #-}

instance (Functor m, Monad m) => Monad (StateT s m) where
return a = StateT $ \s -> (,s) `fmap` return a
return = pure
{-# INLINE return #-}
ma >>= mab = StateT $ runStateT ma >=> (\(a, s2) -> runStateT (mab a) s2)
{-# INLINE (>>=) #-}
Expand Down
1 change: 1 addition & 0 deletions foundation/Foundation/Network/IPv4.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeOperators #-}

module Foundation.Network.IPv4
( IPv4
Expand Down
2 changes: 1 addition & 1 deletion foundation/Foundation/Network/IPv6.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
-- IPv6 data type
--
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE TypeOperators #-}

module Foundation.Network.IPv6
( IPv6
Expand All @@ -28,7 +29,6 @@ import Numeric (readHex)

import Foundation.Class.Storable
import Foundation.Hashing.Hashable
import Basement.Numerical.Additive (scale)
import Basement.Compat.Base
import Data.Proxy
import Foundation.Primitive
Expand Down
1 change: 1 addition & 0 deletions foundation/Foundation/Parser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE TypeOperators #-}

module Foundation.Parser
( Parser
Expand Down
2 changes: 1 addition & 1 deletion foundation/Foundation/Random/DRG.hs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ instance Applicative (MonadRandomState gen) where
in (f a, g3)

instance Monad (MonadRandomState gen) where
return a = MonadRandomState $ \g -> (a, g)
return = pure
(>>=) m1 m2 = MonadRandomState $ \g1 ->
let (a, g2) = runRandomState m1 g1
in runRandomState (m2 a) g2
Expand Down
Loading

0 comments on commit 7abf0e1

Please sign in to comment.