fastfood-hs/app/Main.hs
2024-03-21 11:52:28 +01:00

26 lines
641 B
Haskell

module Main where
import System.Random
import Data.Time
data Fastfood = Kapsalon
| Pizza
| Lasagne
| Nachos
| Friet
| Durum
deriving (Show, Eq, Ord, Enum, Read, Bounded)
instance Random Fastfood where
randomR (a, b) g =
case randomR (fromEnum a, fromEnum b) g of
(x, g') -> (toEnum x, g')
random = randomR (minBound, maxBound)
main :: IO ()
main = do
day <- dayOfWeek . utctDay <$> getCurrentTime -- slight golf optimisation
case day of
Tuesday -> print Friet
_ -> print =<< (randomIO :: IO Fastfood)