module Language.Grammars.Grammar.AG where

import Language.Grammars.Grammar
import Control.Applicative


------------------------
-- IDIOMS FOR AG


instance  Idiomatic l env f g  => Idiomatic  l env (a -> f) (Symbol a TAttT env -> g) where
--    idiomatic isf is = idiomatic (isf <*> ((\x -> x) <$> (sym is :: PreProductions l env a)))
    idiomatic isf is = idiomatic (isf <*> (sym is :: PreProductions l env a))

instance  Idiomatic l env f g  => Idiomatic  l env (DTerm String -> f) (Kw -> g) where
--    idiomatic isf (Kw is) = idiomatic (isf <*> ((\x -> x) <$> (tr is)))
    idiomatic isf (Kw is) = idiomatic (isf <*> (tr is))

newtype SF a = SF { unSF :: a }

instance Idiomatic l env f g => Idiomatic l env (a -> f)  (SF a -> g) where
    idiomatic isf (SF f) = idiomatic (isf <*> (pure f :: PreProductions l env a))