Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module Utilities
- ( pickColor, colors, spacedPrint ) where
- import System.Random (RandomGen)
- import System.Random.Shuffle (shuffle')
- import Types (Secret (..), Color (..), PrettyPrint (..))
- import Data.Monoid ((<>))
- import qualified Data.Text as T
- -- | Utilities for color choosing
- pickColor :: RandomGen a => a -> Secret Color
- pickColor gen = Secret color
- where (color: _) = shuffle' colors (T.length colors) gen
- colors :: [Color]
- colors = [minBound .. maxBound]
- spacedPrint :: Color -> T.Text
- spacedPrint color = prettyPrint color <> formatting
- where
- formatting = if (color == maxBound) then "" else " "
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement