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 " "
- -bash-4.1$ stack build
- colorguess-0.1.0.0: build (lib + exe)
- Preprocessing library colorguess-0.1.0.0...
- [3 of 4] Compiling Utilities ( src/Utilities.hs, .stack-work/dist/x86_64-linux-gmp4/Cabal-1.24.0.0/build/Utilities.o )
- /meta/h/handyc/colorguess/src/Utilities.hs:14:48: error:
- • Couldn't match expected type ‘T.Text’ with actual type ‘[Color]’
- • In the first argument of ‘T.length’, namely ‘colors’
- In the second argument of ‘shuffle'’, namely ‘(T.length colors)’
- In the expression: shuffle' colors (T.length colors) gen
- -- While building package colorguess-0.1.0.0 using:
- /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"
- Process exited with code: ExitFailure 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement