{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveFoldable #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DeriveTraversable #-}

#if __GLASGOW_HASKELL__ >= 702
#define LANGUAGE_DeriveGeneric
{-# LANGUAGE DeriveGeneric #-}
#endif

module System.Console.Terminal.Common
  ( Window(..)
  ) where

import Data.Data (Typeable, Data)

#if __GLASGOW_HASKELL__ < 710
import Data.Foldable (Foldable)
import Data.Traversable (Traversable)
#endif

#ifdef LANGUAGE_DeriveGeneric
import GHC.Generics
  ( Generic
#if __GLASGOW_HASKELL__ >= 706
  , Generic1
#endif
  )
#endif

-- | Terminal window width and height
data Window a = Window
  { forall a. Window a -> a
height :: !a
  , forall a. Window a -> a
width  :: !a
  } deriving
    ( Int -> Window a -> ShowS
[Window a] -> ShowS
Window a -> String
(Int -> Window a -> ShowS)
-> (Window a -> String) -> ([Window a] -> ShowS) -> Show (Window a)
forall a. Show a => Int -> Window a -> ShowS
forall a. Show a => [Window a] -> ShowS
forall a. Show a => Window a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall a. Show a => Int -> Window a -> ShowS
showsPrec :: Int -> Window a -> ShowS
$cshow :: forall a. Show a => Window a -> String
show :: Window a -> String
$cshowList :: forall a. Show a => [Window a] -> ShowS
showList :: [Window a] -> ShowS
Show, Window a -> Window a -> Bool
(Window a -> Window a -> Bool)
-> (Window a -> Window a -> Bool) -> Eq (Window a)
forall a. Eq a => Window a -> Window a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall a. Eq a => Window a -> Window a -> Bool
== :: Window a -> Window a -> Bool
$c/= :: forall a. Eq a => Window a -> Window a -> Bool
/= :: Window a -> Window a -> Bool
Eq, ReadPrec [Window a]
ReadPrec (Window a)
Int -> ReadS (Window a)
ReadS [Window a]
(Int -> ReadS (Window a))
-> ReadS [Window a]
-> ReadPrec (Window a)
-> ReadPrec [Window a]
-> Read (Window a)
forall a. Read a => ReadPrec [Window a]
forall a. Read a => ReadPrec (Window a)
forall a. Read a => Int -> ReadS (Window a)
forall a. Read a => ReadS [Window a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: forall a. Read a => Int -> ReadS (Window a)
readsPrec :: Int -> ReadS (Window a)
$creadList :: forall a. Read a => ReadS [Window a]
readList :: ReadS [Window a]
$creadPrec :: forall a. Read a => ReadPrec (Window a)
readPrec :: ReadPrec (Window a)
$creadListPrec :: forall a. Read a => ReadPrec [Window a]
readListPrec :: ReadPrec [Window a]
Read, Typeable (Window a)
Typeable (Window a) =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> Window a -> c (Window a))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (Window a))
-> (Window a -> Constr)
-> (Window a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (Window a)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (Window a)))
-> ((forall b. Data b => b -> b) -> Window a -> Window a)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Window a -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Window a -> r)
-> (forall u. (forall d. Data d => d -> u) -> Window a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Window a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Window a -> m (Window a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Window a -> m (Window a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Window a -> m (Window a))
-> Data (Window a)
Window a -> Constr
Window a -> DataType
(forall b. Data b => b -> b) -> Window a -> Window a
forall a. Data a => Typeable (Window a)
forall a. Data a => Window a -> Constr
forall a. Data a => Window a -> DataType
forall a.
Data a =>
(forall b. Data b => b -> b) -> Window a -> Window a
forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> Window a -> u
forall a u.
Data a =>
(forall d. Data d => d -> u) -> Window a -> [u]
forall a r r'.
Data a =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Window a -> r
forall a r r'.
Data a =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Window a -> r
forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> Window a -> m (Window a)
forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Window a -> m (Window a)
forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Window a)
forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Window a -> c (Window a)
forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Window a))
forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Window a))
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Window a -> u
forall u. (forall d. Data d => d -> u) -> Window a -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Window a -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Window a -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Window a -> m (Window a)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Window a -> m (Window a)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Window a)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Window a -> c (Window a)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Window a))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Window a))
$cgfoldl :: forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Window a -> c (Window a)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Window a -> c (Window a)
$cgunfold :: forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Window a)
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Window a)
$ctoConstr :: forall a. Data a => Window a -> Constr
toConstr :: Window a -> Constr
$cdataTypeOf :: forall a. Data a => Window a -> DataType
dataTypeOf :: Window a -> DataType
$cdataCast1 :: forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Window a))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Window a))
$cdataCast2 :: forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Window a))
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Window a))
$cgmapT :: forall a.
Data a =>
(forall b. Data b => b -> b) -> Window a -> Window a
gmapT :: (forall b. Data b => b -> b) -> Window a -> Window a
$cgmapQl :: forall a r r'.
Data a =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Window a -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Window a -> r
$cgmapQr :: forall a r r'.
Data a =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Window a -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Window a -> r
$cgmapQ :: forall a u.
Data a =>
(forall d. Data d => d -> u) -> Window a -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> Window a -> [u]
$cgmapQi :: forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> Window a -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Window a -> u
$cgmapM :: forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> Window a -> m (Window a)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Window a -> m (Window a)
$cgmapMp :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Window a -> m (Window a)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Window a -> m (Window a)
$cgmapMo :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Window a -> m (Window a)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Window a -> m (Window a)
Data, Typeable
    , (forall m. Monoid m => Window m -> m)
-> (forall m a. Monoid m => (a -> m) -> Window a -> m)
-> (forall m a. Monoid m => (a -> m) -> Window a -> m)
-> (forall a b. (a -> b -> b) -> b -> Window a -> b)
-> (forall a b. (a -> b -> b) -> b -> Window a -> b)
-> (forall b a. (b -> a -> b) -> b -> Window a -> b)
-> (forall b a. (b -> a -> b) -> b -> Window a -> b)
-> (forall a. (a -> a -> a) -> Window a -> a)
-> (forall a. (a -> a -> a) -> Window a -> a)
-> (forall a. Window a -> [a])
-> (forall a. Window a -> Bool)
-> (forall a. Window a -> Int)
-> (forall a. Eq a => a -> Window a -> Bool)
-> (forall a. Ord a => Window a -> a)
-> (forall a. Ord a => Window a -> a)
-> (forall a. Num a => Window a -> a)
-> (forall a. Num a => Window a -> a)
-> Foldable Window
forall a. Eq a => a -> Window a -> Bool
forall a. Num a => Window a -> a
forall a. Ord a => Window a -> a
forall m. Monoid m => Window m -> m
forall a. Window a -> Bool
forall a. Window a -> Int
forall a. Window a -> [a]
forall a. (a -> a -> a) -> Window a -> a
forall m a. Monoid m => (a -> m) -> Window a -> m
forall b a. (b -> a -> b) -> b -> Window a -> b
forall a b. (a -> b -> b) -> b -> Window a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
$cfold :: forall m. Monoid m => Window m -> m
fold :: forall m. Monoid m => Window m -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> Window a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> Window a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> Window a -> m
foldMap' :: forall m a. Monoid m => (a -> m) -> Window a -> m
$cfoldr :: forall a b. (a -> b -> b) -> b -> Window a -> b
foldr :: forall a b. (a -> b -> b) -> b -> Window a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> Window a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> Window a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> Window a -> b
foldl :: forall b a. (b -> a -> b) -> b -> Window a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> Window a -> b
foldl' :: forall b a. (b -> a -> b) -> b -> Window a -> b
$cfoldr1 :: forall a. (a -> a -> a) -> Window a -> a
foldr1 :: forall a. (a -> a -> a) -> Window a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> Window a -> a
foldl1 :: forall a. (a -> a -> a) -> Window a -> a
$ctoList :: forall a. Window a -> [a]
toList :: forall a. Window a -> [a]
$cnull :: forall a. Window a -> Bool
null :: forall a. Window a -> Bool
$clength :: forall a. Window a -> Int
length :: forall a. Window a -> Int
$celem :: forall a. Eq a => a -> Window a -> Bool
elem :: forall a. Eq a => a -> Window a -> Bool
$cmaximum :: forall a. Ord a => Window a -> a
maximum :: forall a. Ord a => Window a -> a
$cminimum :: forall a. Ord a => Window a -> a
minimum :: forall a. Ord a => Window a -> a
$csum :: forall a. Num a => Window a -> a
sum :: forall a. Num a => Window a -> a
$cproduct :: forall a. Num a => Window a -> a
product :: forall a. Num a => Window a -> a
Foldable, (forall a b. (a -> b) -> Window a -> Window b)
-> (forall a b. a -> Window b -> Window a) -> Functor Window
forall a b. a -> Window b -> Window a
forall a b. (a -> b) -> Window a -> Window b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall a b. (a -> b) -> Window a -> Window b
fmap :: forall a b. (a -> b) -> Window a -> Window b
$c<$ :: forall a b. a -> Window b -> Window a
<$ :: forall a b. a -> Window b -> Window a
Functor, Functor Window
Foldable Window
(Functor Window, Foldable Window) =>
(forall (f :: * -> *) a b.
 Applicative f =>
 (a -> f b) -> Window a -> f (Window b))
-> (forall (f :: * -> *) a.
    Applicative f =>
    Window (f a) -> f (Window a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> Window a -> m (Window b))
-> (forall (m :: * -> *) a.
    Monad m =>
    Window (m a) -> m (Window a))
-> Traversable Window
forall (t :: * -> *).
(Functor t, Foldable t) =>
(forall (f :: * -> *) a b.
 Applicative f =>
 (a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a. Monad m => Window (m a) -> m (Window a)
forall (f :: * -> *) a.
Applicative f =>
Window (f a) -> f (Window a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Window a -> m (Window b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Window a -> f (Window b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Window a -> f (Window b)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Window a -> f (Window b)
$csequenceA :: forall (f :: * -> *) a.
Applicative f =>
Window (f a) -> f (Window a)
sequenceA :: forall (f :: * -> *) a.
Applicative f =>
Window (f a) -> f (Window a)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Window a -> m (Window b)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Window a -> m (Window b)
$csequence :: forall (m :: * -> *) a. Monad m => Window (m a) -> m (Window a)
sequence :: forall (m :: * -> *) a. Monad m => Window (m a) -> m (Window a)
Traversable
#ifdef LANGUAGE_DeriveGeneric
    , (forall x. Window a -> Rep (Window a) x)
-> (forall x. Rep (Window a) x -> Window a) -> Generic (Window a)
forall x. Rep (Window a) x -> Window a
forall x. Window a -> Rep (Window a) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x. Rep (Window a) x -> Window a
forall a x. Window a -> Rep (Window a) x
$cfrom :: forall a x. Window a -> Rep (Window a) x
from :: forall x. Window a -> Rep (Window a) x
$cto :: forall a x. Rep (Window a) x -> Window a
to :: forall x. Rep (Window a) x -> Window a
Generic
#if __GLASGOW_HASKELL__ >= 706
    , (forall a. Window a -> Rep1 Window a)
-> (forall a. Rep1 Window a -> Window a) -> Generic1 Window
forall a. Rep1 Window a -> Window a
forall a. Window a -> Rep1 Window a
forall k (f :: k -> *).
(forall (a :: k). f a -> Rep1 f a)
-> (forall (a :: k). Rep1 f a -> f a) -> Generic1 f
$cfrom1 :: forall a. Window a -> Rep1 Window a
from1 :: forall a. Window a -> Rep1 Window a
$cto1 :: forall a. Rep1 Window a -> Window a
to1 :: forall a. Rep1 Window a -> Window a
Generic1
#endif
#endif
    )