{-#LANGUAGE TypeOperators, MultiParamTypeClasses, FlexibleInstances, FlexibleContexts, IncoherentInstances, UndecidableInstances, ScopedTypeVariables #-}
-----------------------------------------------------------------------------
--
-- Module      :  Base.Mult
-- Copyright   :
-- License     :  AllRightsReserved
--
-- Maintainer  :
-- Stability   :
-- Portability :
--
-- |
--
-----------------------------------------------------------------------------

module Base.Mult where

import Base.Expr
import Base.Inject
import Base.Eval

-- adding a new operation

data Mult e = Mult e e

instance Functor Mult where
    fmap f (Mult e1 e2) = Mult (f e1) (f e2)

instance Eval Mult where
    evalAlgebra (Mult x y) = x * y

infixl 7 `mult`

mult :: ((:<:) Mult f) => Expr f -> Expr f -> Expr f
mult x y = inject (Mult x y)

