#!/usr/bin/env stack {- stack --nix --resolver lts-11.15 --install-ghc runghc --package random -} {-# LANGUAGE TypeSynonymInstances #-} {- Problem: Create a string array containing a representation of the 52 cards in a standard deck, and then a second array that shuffles the 52 cards. Start with two string arrays of the cards and suits: Cards: 2, 3, 4, 5, 6, 7, 8, 9, 10, J, K, Q, A Suits: Clubs, Diamonds, Aces, Spades -} import System.Random import Control.Monad import Control.Applicative data Name = Two | Three | Four | Five | Six | Seven | Eight | Nine | Ten | Jack | King | Queen | Ace deriving (Show, Enum, Bounded) names :: [Name] names = [ Two .. ] data Suit = Club | Diamond | Heart | Spade deriving (Show, Enum) suits :: [Suit] suits = [ Club .. ] allCards :: [(Name, Suit)] allCards = liftA2 (,) names suits data CardsGen = CardsGen deriving (Show) --instance RandomGen CardsGen where -- genRange _ = (0, cardsLength) -- next CardsGen = stdNext (StdGen 0 cardsLength) -- split = stdSplit (StdGen 0 cardsLength) suffle :: [cards] -> [cards] suffle arr = undefined main :: IO [()] main = do sequence $ map (putStrLn.show) allCards