summaryrefslogtreecommitdiff
path: root/rain/main.hs
diff options
context:
space:
mode:
Diffstat (limited to 'rain/main.hs')
-rwxr-xr-xrain/main.hs71
1 files changed, 71 insertions, 0 deletions
diff --git a/rain/main.hs b/rain/main.hs
new file mode 100755
index 0000000..3c431a7
--- /dev/null
+++ b/rain/main.hs
@@ -0,0 +1,71 @@
+#!/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
+
+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 = concat $ map (\n -> map (\s -> (n, s)) suits) names
+
+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