{- |
We provide a way to specify a set of columns
that matches the tuple structure of a certain graph type.
-}
module Graphics.Gnuplot.Value.ColumnSet
   (T(Cons), atom, pair, triple, quadruple,
   ) where

import qualified Graphics.Gnuplot.Value.Atom  as Atom


newtype T a = Cons [Int]

{-
Functor and Applicative instances would be useful
for combining column sets,
but they are dangerous, because they can bring
type and column number out of sync.

instance Functor Column where
   fmap _ (Cons n) = Cons n

instance Applicative Column where
   pure _ = Cons []
   Cons ns <*> Cons ms = Cons (ns++ms)
-}

atom :: Atom.C a => Int -> T a
atom :: Int -> T a
atom Int
i = [Int] -> T a
forall a. [Int] -> T a
Cons [Int
i]

pair :: T a -> T b -> T (a,b)
pair :: T a -> T b -> T (a, b)
pair (Cons [Int]
ai) (Cons [Int]
bi) = [Int] -> T (a, b)
forall a. [Int] -> T a
Cons ([Int]
ai[Int] -> [Int] -> [Int]
forall a. [a] -> [a] -> [a]
++[Int]
bi)

triple :: T a -> T b -> T c -> T (a,b,c)
triple :: T a -> T b -> T c -> T (a, b, c)
triple (Cons [Int]
ai) (Cons [Int]
bi) (Cons [Int]
ci) = [Int] -> T (a, b, c)
forall a. [Int] -> T a
Cons ([Int]
ai[Int] -> [Int] -> [Int]
forall a. [a] -> [a] -> [a]
++[Int]
bi[Int] -> [Int] -> [Int]
forall a. [a] -> [a] -> [a]
++[Int]
ci)

quadruple :: T a -> T b -> T c -> T d -> T (a,b,c,d)
quadruple :: T a -> T b -> T c -> T d -> T (a, b, c, d)
quadruple (Cons [Int]
ai) (Cons [Int]
bi) (Cons [Int]
ci) (Cons [Int]
di) = [Int] -> T (a, b, c, d)
forall a. [Int] -> T a
Cons ([Int]
ai[Int] -> [Int] -> [Int]
forall a. [a] -> [a] -> [a]
++[Int]
bi[Int] -> [Int] -> [Int]
forall a. [a] -> [a] -> [a]
++[Int]
ci[Int] -> [Int] -> [Int]
forall a. [a] -> [a] -> [a]
++[Int]
di)