packages feed

ecstasy 0.1.0.0 → 0.1.0.1

raw patch · 5 files changed

+25/−57 lines, 5 filesdep ~base

Dependency ranges changed: base

Files

ChangeLog.md view
@@ -1,5 +1,11 @@ # Revision history for ecstasy -## 0.1.0.0  -- YYYY-mm-dd+## 0.1.0.1  -- 2018-02-14 +* Added 'yieldSystemT' for resuming a 'SystemT' computation later.+* Bumped the upper bound on 'base' to 5 (thanks to nek0).++## 0.1.0.0  -- 2017-12-27+ * First version. Released on an unsuspecting world.+
ecstasy.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                ecstasy-version:             0.1.0.0+version:             0.1.0.1 synopsis:   A GHC.Generics based entity component system. @@ -37,8 +37,7 @@   exposed-modules: Data.Ecstasy   other-modules:   Data.Ecstasy.Deriving                  , Data.Ecstasy.Types-                 , Main   -- other-extensions:-  build-depends:       base >=4.9 && <4.10, containers, mtl, transformers+  build-depends:       base >=4.9 && <5, containers, mtl, transformers   hs-source-dirs:      src   default-language:    Haskell2010
src/Data/Ecstasy.hs view
@@ -26,6 +26,7 @@ import           Data.Functor.Identity (runIdentity) import           Data.Maybe (catMaybes) import           Data.Traversable (for)+import           Data.Tuple (swap) import           GHC.Generics  @@ -214,6 +215,17 @@ runQueryT e qt = do   cs <- getEntity e   lift $ unQueryT qt cs+++------------------------------------------------------------------------------+-- | Provides a resumable 'SystemT'. This is a pretty big hack until I come up+-- with a better formalization for everything.+yieldSystemT+    :: Monad m+    => SystemState world+    -> SystemT world m a+    -> m (SystemState world, a)+yieldSystemT = (fmap swap .) . flip S.runStateT   ------------------------------------------------------------------------------
src/Data/Ecstasy/Types.hs view
@@ -20,10 +20,13 @@   show (Ent e) = "Ent " ++ show e  +------------------------------------------------------------------------------+-- | The internal state of the 'SystemT' monad.+type SystemState w = (Int, w 'WorldOf)  ------------------------------------------------------------------------------ -- | A monad transformer over an ECS given a world 'w'.-type SystemT w = StateT (Int, w 'WorldOf)+type SystemT w = StateT (SystemState w)  ------------------------------------------------------------------------------ -- | A monad over an ECS given a world 'w'.
− src/Main.hs
@@ -1,52 +0,0 @@-{-# LANGUAGE DataKinds                    #-}-{-# LANGUAGE DeriveGeneric                #-}-{-# LANGUAGE TypeFamilies                 #-}--module Main where--import Data.Ecstasy-import Control.Monad (void)-import Control.Monad.IO.Class (liftIO)---main :: IO ()-main = do-  e <- runSystemT defWorld $ do-    void $ newEntity $ defEntity-        { pos = Just 0-        , vel = Just 1-        , ack = Just True-        }--    void $ newEntity $ defEntity-      { pos = Just 0-      , ack = Just False-      }--    let-      step = do-        pos' <- get pos-        vel' <- get vel-        pure $ defEntity'-          { pos = Set $ pos' + vel'-          }-    emap step-    emap step--    efor $ \i -> do-      with ack-      pure $ show i--  print e---   print $ pos e---   print $ vel e---   print $ ack e---data Entity f = Entity-  { pos :: Component f 'Field  Int-  , vel :: Component f 'Field  Int-  , ack :: Component f 'Unique Bool-  } deriving (Generic)--