Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2017
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 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 " "
  23.  
  24.  
  25. -bash-4.1$ stack build
  26. colorguess-0.1.0.0: build (lib + exe)
  27. Preprocessing library colorguess-0.1.0.0...
  28. [3 of 4] Compiling Utilities ( src/Utilities.hs, .stack-work/dist/x86_64-linux-gmp4/Cabal-1.24.0.0/build/Utilities.o )
  29.  
  30. /meta/h/handyc/colorguess/src/Utilities.hs:14:48: error:
  31. • Couldn't match expected type ‘T.Text’ with actual type ‘[Color]’
  32. • In the first argument of ‘T.length’, namely ‘colors’
  33. In the second argument of ‘shuffle'’, namely ‘(T.length colors)’
  34. In the expression: shuffle' colors (T.length colors) gen
  35.  
  36. -- While building package colorguess-0.1.0.0 using:
  37. /meta/h/handyc/.stack/setup-exe-cache/x86_64-linux-gmp4/Cabal-simple_mPHDZzAJ_1.24.0.0_ghc-8.0.1 --builddir=.stack-work/dist/x86_64-linux-gmp4/Cabal-1.24.0.0 build lib:colorguess exe:colorguess-exe --ghc-options " -ddump-hi -ddump-to-file"
  38. Process exited with code: ExitFailure 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement