module MAAM.Time where

import FP
import qualified FP.Pretty as P
import MAAM.Initial
import GHC.TypeLits

class Time τ where
  tzero :: τ ψ
  tick :: ψ -> τ ψ -> τ ψ

-- Concrete
newtype  ψ =  [ψ]
  deriving (Eq, Ord, Pretty, Iterable ψ, Buildable ψ, ListLike ψ)
instance Functorial Eq  where functorial = W
instance Functorial Ord  where functorial = W
instance Functorial Pretty  where functorial = W
instance Initial ( ψ) where initial = nil
instance Time  where
  tzero = initial
  tick = cons

-- kCFA
newtype  (k :: Nat) ψ =  [ψ]
  deriving (Eq, Ord, Pretty, Iterable ψ, Buildable ψ, ListLike ψ)
instance Functorial Eq ( k) where functorial = W
instance Functorial Ord ( k) where functorial = W
instance Functorial Pretty ( k) where functorial = W
instance Initial ( k ψ) where initial = nil
instance (KnownNat k) => Time ( k) where
  tzero = initial
  tick x y = toListLike $ firstN (natVal (P :: P k)) $ fromListLike $ cons x y

-- 0CFA
data  ψ = 
  deriving (Eq, Ord)
instance Pretty ( a) where
  pretty  = P.lit "∙"
instance Functorial Eq  where functorial = W
instance Functorial Ord  where functorial = W
instance Functorial Pretty  where functorial = W
instance Initial ( ψ) where initial = 
instance Time  where
  tzero = initial
  tick = const id