Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apecs-physics/src/Apecs/Physics/Body.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module Apecs.Physics.Body where
import Apecs
import Apecs.Core
import Control.Monad
import Control.Monad.IO.Class (liftIO, MonadIO)
import Control.Monad.IO.Class (MonadIO)
import qualified Data.IntMap as M
import qualified Data.IntSet as S
import Data.IORef
Expand Down
2 changes: 1 addition & 1 deletion apecs-physics/src/Apecs/Physics/Collision.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module Apecs.Physics.Collision
import Apecs
import Apecs.Core
import Control.Monad
import Control.Monad.IO.Class (MonadIO, liftIO)
import Control.Monad.IO.Class (MonadIO)
import qualified Data.IntMap as M
import Data.IORef
import qualified Data.Vector.Unboxed as U
Expand Down
2 changes: 1 addition & 1 deletion apecs-physics/src/Apecs/Physics/Constraint.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module Apecs.Physics.Constraint
import Apecs
import Apecs.Core
import Control.Monad
import Control.Monad.IO.Class (liftIO, MonadIO)
import Control.Monad.IO.Class (MonadIO)
import qualified Data.IntMap as M
import qualified Data.IntSet as S
import Data.IORef
Expand Down
2 changes: 1 addition & 1 deletion apecs-physics/src/Apecs/Physics/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
module Apecs.Physics.Query where

import Apecs
import Control.Monad.IO.Class (liftIO, MonadIO)
import Control.Monad.IO.Class (MonadIO)
import Foreign.C.Types
import Foreign.ForeignPtr (withForeignPtr)
import Foreign.Marshal.Alloc
Expand Down
2 changes: 1 addition & 1 deletion apecs-physics/src/Apecs/Physics/Space.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module Apecs.Physics.Space where

import Apecs
import Apecs.Core
import Control.Monad.IO.Class (liftIO, MonadIO)
import Control.Monad.IO.Class (MonadIO)
import Data.IORef
import Foreign.Concurrent
import Foreign.ForeignPtr (withForeignPtr)
Expand Down
4 changes: 1 addition & 3 deletions apecs/apecs.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,8 @@ library
array >=0.4 && <0.6
, base >=4.9 && <5
, containers >=0.5 && <0.8
, exceptions >=0.10.0 && <0.11
, mtl >=2.2 && <2.4
, transformers >= 0.5 && <0.7
, template-haskell >=2.12 && <3
, unliftio-core >=0.2.0.1 && <0.3
, vector >=0.11 && <0.14

ghc-options: -Wall
Expand Down
5 changes: 3 additions & 2 deletions apecs/src/Apecs.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ It selectively re-exports the user-facing functions from the submodules.
-}
module Apecs (
-- * Core types
SystemT(..), System, Component(..), Entity(..), Has(..), Not(..),
SystemT, System, Component(..), Entity(..), Has(..), Not(..),
Get, Set, Destroy, Members,

-- * Stores
Expand All @@ -30,7 +30,8 @@ module Apecs (
) where

import Control.Monad.IO.Class (liftIO)
import Control.Monad.Reader (ask, asks, lift)
import Control.Monad.Trans.Class (lift)
import Control.Monad.Trans.Reader (ask, asks)
import Data.Proxy

import Apecs.Components
Expand Down
9 changes: 2 additions & 7 deletions apecs/src/Apecs/Core.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@

module Apecs.Core where

import Control.Monad.Catch
import Control.Monad.IO.Class
import Control.Monad.IO.Unlift
import Control.Monad.Reader
import Control.Monad.Trans.Reader
import qualified Data.Vector.Unboxed as U

-- | An Entity is just an integer, used to index into a component store.
Expand All @@ -30,11 +27,9 @@ newtype Entity = Entity {unEntity :: Int} deriving (Num, Eq, Ord, Show, Enum)
-- * Allow type-based lookup of a component's store through @getStore@.
--
-- * Lift side effects into their host Monad.
newtype SystemT w m a = SystemT {unSystem :: ReaderT w m a} deriving (Functor, Monad, Applicative, MonadTrans, MonadIO, MonadThrow, MonadCatch, MonadMask, MonadUnliftIO)
type SystemT w m = ReaderT w m
type System w = SystemT w IO

deriving instance Monad m => MonadReader w (SystemT w m)

-- | A component is defined by specifying how it is stored.
-- The constraint ensures that stores and components are mapped one-to-one.
class (Elem (Storage c) ~ c) => Component c where
Expand Down
2 changes: 1 addition & 1 deletion apecs/src/Apecs/Experimental/Reactive.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ module Apecs.Experimental.Reactive

import Control.Monad
import Control.Monad.IO.Class
import Control.Monad.Reader
import Control.Monad.Trans.Class (lift)
import qualified Data.Array.IO as A
import qualified Data.IntMap.Strict as IM
import qualified Data.IntSet as S
Expand Down
2 changes: 1 addition & 1 deletion apecs/src/Apecs/Experimental/Stores.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module Apecs.Experimental.Stores
( Pushdown(..), Stack(..)
) where

import Control.Monad.Reader
import Control.Monad.Trans.Reader
import Data.Proxy
import Data.Semigroup

Expand Down
2 changes: 1 addition & 1 deletion apecs/src/Apecs/Stores.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module Apecs.Stores

import Control.Monad
import Control.Monad.IO.Class
import Control.Monad.Reader
import Control.Monad.Trans.Class (lift)
import Data.Bits (shiftL, (.&.))
import qualified Data.IntMap.Strict as M
import Data.IORef
Expand Down
5 changes: 3 additions & 2 deletions apecs/src/Apecs/System.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
module Apecs.System where

import Control.Monad
import Control.Monad.Reader
import Control.Monad.Trans.Class (lift)
import Control.Monad.Trans.Reader
import Data.Proxy
import qualified Data.Vector.Unboxed as U

Expand All @@ -17,7 +18,7 @@ import Apecs.Core
-- | Run a system in a game world
{-# INLINE runSystem #-}
runSystem :: SystemT w m a -> w -> m a
runSystem sys = runReaderT (unSystem sys)
runSystem = runReaderT

-- | Run a system in a game world
{-# INLINE runWith #-}
Expand Down
4 changes: 2 additions & 2 deletions apecs/src/Apecs/TH.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module Apecs.TH
) where

import Control.Monad (filterM)
import Control.Monad.Reader (asks)
import Control.Monad.Trans.Reader (asks)
import Data.Traversable (for)
import Language.Haskell.TH

Expand Down Expand Up @@ -50,7 +50,7 @@ makeWorldNoEC worldName cTypes = do
| (j,_) <- enumerate cTypes
]
[d| instance Monad m => Has $(conT world) m $(conT t) where
getStore = let field $pat = $(varE x) in SystemT (asks field)
getStore = let field $pat = $(varE x) in asks field
|]

-- Destructible type synonym
Expand Down
2 changes: 1 addition & 1 deletion apecs/src/Apecs/Util.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module Apecs.Util (

import Control.Applicative (liftA2)
import Control.Monad.IO.Class
import Control.Monad.Reader
import Control.Monad.Trans.Class (lift)
import Data.Monoid
import Data.Semigroup
import System.Mem (performMajorGC)
Expand Down
Loading