-- | Typeclass for 'Drawable' values.
module Sound.SC3.UGen.Dot.Class where

import Sound.SC3 as S
import Sound.SC3.UGen.Graph as S
import Sound.SC3.UGen.Dot.Internal
import Sound.SC3.UGen.Dot.Type

-- | Draw the unit generator graph provided using the viewer at the
--   environment variable @DOTVIEWER@, or @dotty@ if that variable is
--   not defined.
class Drawable a where
    dot_with_opt :: Dot_Options -> a -> String

-- | 'S.Graph's are 'Drawable', by 'dotGraph'.
instance Drawable S.Graph where
    dot_with_opt = dotGraph

-- | 'S.UGens's are 'Drawable', by 'S.ugen_to_graph'.
instance Drawable S.UGen where
    dot_with_opt o = dotGraph o . S.ugen_to_graph

-- | 'S.Synthdef's are 'Drawable', by 'S.synthdefGraph'.
instance Drawable S.Synthdef where
    dot_with_opt o = dotGraph o . S.synthdefGraph