{-# LANGUAGE ScopedTypeVariables #-} import Data.Int import Data.Word import Data.Bits type Line = Int8 type TetrisBoard = [Line] po2 :: forall a. (Bits a, Num a) => Int -> a po2 = shiftL (1 :: a) po2b :: forall a. (Bits a, Num a) => Bool -> Int -> a po2b b = if b then po2 else const 0 fromRow :: Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Word8 fromRow a b c d e f g = foldl1 (.|.) $ zipWith po2b [a, b, c, d, e, f, g] [0..] fromRowList :: [Bool] -> Word8 fromRowList [a, b, c, d, e, f, g] = fromRow a b c d e f g fromRowList _ = undefined minos = [ [ "####" ], [ ".#.", "###", ".#." ], [ "..#", "..#", "###" ], [ "#", "#", "#", "#" ], [ "##", "##" ]]