module Nove where

import Nove.Verse
import Nove.Logic ( step )

import Data.Map as Map ( Map )

{- State should be independent of time and not recorded
-- so every recorded frame should be enough to reconstruct the universe without it
-- state stores stuff like the currently focused cell
-- it does not provide information about the universe
-- State can however influence the universe
-- as is the case for the random seed or user input
-}

-- a cell is defined by its behaviour
newtype Automata state a = Automata (Atom a => state -> Map Dir a -> a -> a)

instance Semigroup (Automata state a) where
   Automata g <> Automata f = Automata (\s ns -> g s ns . f s ns)

instance Monoid (Automata state a) where
   mempty = Automata (\_ _ -> id)

sim :: Atom a => Automata state a -> state -> Verse a -> Verse a
sim (Automata f) = step . f