module ReaderPractice where

import           Control.Applicative
import           Data.Maybe

x = [1,2,3]
y = [4,5,6]
z = [7,8,9]


xs :: Maybe Integer
xs = lookup 3 $ zip x y

ys :: Maybe Integer
ys = lookup 6 $ zip y z

zs :: Maybe Integer
zs = lookup 4 $ zip x y

z' :: Integer -> Maybe Integer
z' n = lookup n $ zip x z

x1 = liftA2 (,) xs ys

x2 = liftA2 (,) ys zs

x3 n = (z' n, z' n)

summed = uncurry (+)

bolt :: Integer -> Bool
bolt = (&&) <$> (>3) <*> (<8)

main :: IO ()
main = do
  print $ foldl (&&) True $ sequA 7
  print $ sequA (fromMaybe 0 s')
  print $ bolt (fromMaybe 0 ys)


sequA :: Integral a => a -> [Bool]
sequA m = sequenceA [(>3), (<8), even] m

s' = summed <$> ((,) <$> xs <*> ys)
