move some utility functions from Waterdeep.Actions to Waterdeep.Utils.
This commit is contained in:
parent
4331512a3e
commit
62260d2d28
|
|
@ -495,18 +495,6 @@ forCurrentPlayer a1 = do
|
|||
p <- use gameCurrentPlayer
|
||||
withActivePlayer p a1
|
||||
|
||||
-- Like (<$>), but with the same fixity and precedence as ($)
|
||||
(<$$>) :: Applicative f => (a -> b) -> f a -> f b
|
||||
(<$$>) = (<$>)
|
||||
infixr 0 <$$>
|
||||
|
||||
joinStrings :: [String] -> String
|
||||
joinStrings [] = "nothing"
|
||||
joinStrings [x] = x
|
||||
joinStrings [x,y] = x ++ " and " ++ y
|
||||
joinStrings [x,y,z] = x ++ ", " ++ y ++ ", and " ++ z
|
||||
joinStrings (x:xs) = x ++ ", " ++ joinStrings xs
|
||||
|
||||
shufflePiles :: Lens WaterdeepState WaterdeepState [a] [a]
|
||||
-> Lens WaterdeepState WaterdeepState [a] [a]
|
||||
-> Waterdeep ()
|
||||
|
|
|
|||
|
|
@ -8,12 +8,15 @@ module Waterdeep.Util
|
|||
, countOf
|
||||
, singular
|
||||
, mif
|
||||
, joinStrings
|
||||
, (<$$>)
|
||||
) where
|
||||
|
||||
import Lens.Family2
|
||||
import Control.Applicative
|
||||
import Data.List
|
||||
import Data.Maybe
|
||||
import Data.Monoid
|
||||
import Lens.Family2
|
||||
|
||||
deleteAt :: Int -> [a] -> [a]
|
||||
deleteAt n l = left ++ drop 1 right
|
||||
|
|
@ -42,3 +45,15 @@ singular t f b = (\a' -> b & t .~ a') `fmap` (f (unJust (firstOf t b)))
|
|||
|
||||
mif :: Monoid m => Bool -> m -> m
|
||||
mif c m = if c then m else mempty
|
||||
|
||||
joinStrings :: [String] -> String
|
||||
joinStrings [] = "nothing"
|
||||
joinStrings [x] = x
|
||||
joinStrings [x,y] = x ++ " and " ++ y
|
||||
joinStrings [x,y,z] = x ++ ", " ++ y ++ ", and " ++ z
|
||||
joinStrings (x:xs) = x ++ ", " ++ joinStrings xs
|
||||
|
||||
-- Like (<$>), but with the same fixity and precedence as ($)
|
||||
(<$$>) :: Applicative f => (a -> b) -> f a -> f b
|
||||
(<$$>) = (<$>)
|
||||
infixr 0 <$$>
|
||||
|
|
|
|||
Loading…
Reference in New Issue