Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2017
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. module Utilities
  2. ( pickColor, colors, spacedPrint ) where
  3.  
  4. import System.Random (RandomGen)
  5. import System.Random.Shuffle (shuffle')
  6.  
  7. import Types (Secret (..), Color (..), PrettyPrint (..))
  8. import Data.Monoid ((<>))
  9. import qualified Data.Text as T
  10.  
  11. -- | Utilities for color choosing
  12. pickColor :: RandomGen a => a -> Secret Color
  13. pickColor gen = Secret color
  14. where (color: _) = shuffle' colors (T.length colors) gen
  15.  
  16. colors :: [Color]
  17. colors = [minBound .. maxBound]
  18.  
  19. spacedPrint :: Color -> T.Text
  20. spacedPrint color = prettyPrint color <> formatting
  21. where
  22. formatting = if (color == maxBound) then "" else " "
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement