Permalink
Browse files

Use NonEmpty from semigroups

  • Loading branch information...
1 parent 0334a6d commit 0bdcf97ad490bad3d81b8bd8eb8dd57d3f883a2d @bartavelle committed May 15, 2014
Showing with 5 additions and 10 deletions.
  1. +2 −1 7startups.cabal
  2. +2 −9 Startups/GameTypes.hs
  3. +1 −0 Startups/Interpreter.hs
View
@@ -40,7 +40,8 @@ library
random == 1.*,
split == 0.2.*,
ansi-wl-pprint == 0.6.*,
- operational == 0.2.*
+ operational == 0.2.*,
+ semigroups == 0.13.*
-- hs-source-dirs:
default-language: Haskell2010
View
@@ -20,6 +20,7 @@ import qualified Data.Map.Strict as M
import Control.Monad.Operational
import Control.Monad.State.Strict
import Control.Monad.Error
+import Data.List.NonEmpty
import Control.Applicative
import System.Random
@@ -64,16 +65,8 @@ data PlayerAction = PlayerAction ActionType Card
data ActionType = Play | Drop | BuildCompany
deriving Eq
--- | Some types for non empty lists
-data NonEmpty a = NonEmpty a [a]
-
_NonEmpty :: Prism' [a] (NonEmpty a)
-_NonEmpty = prism fromNonEmpty toNonEmpty
- where
- fromNonEmpty (NonEmpty x xs) = x : xs
- toNonEmpty l = case l of
- [] -> Left l
- (x:xs) -> Right (NonEmpty x xs)
+_NonEmpty = prism' toList nonEmpty
-- | This describe the capabilities needed to write the rules, when no
-- interaction with the player is required.
@@ -8,6 +8,7 @@ import Startups.GameTypes
import qualified Data.Map.Strict as M
import Control.Monad.Operational
import Control.Monad.State.Strict
+import Data.List.NonEmpty
data OperationDict m = OperationDict { _doPlayerDecision :: Age -> Turn -> PlayerId -> NonEmpty Card -> GameState -> m (PlayerAction, Exchange)
, _doAskCard :: Age -> PlayerId -> NonEmpty Card -> GameState -> Message -> m Card

0 comments on commit 0bdcf97

Please sign in to comment.