Thank you guys. For some weired reason I thought one cannot define two 
distinct types, one being defined type in terms of the other, the other 
being defined through the first one. I should have tried before asking. At 
least in Haskell I can do it:

{-# LANGUAGE  TypeSynonymInstances, FlexibleInstances #-}

import Math.Core.Field
import Math.CommutativeAlgebra.Polynomial
import Math.Algebras.Structures

type Expression = GlexPoly Q Kernel

data Kernel = Symbol String
            | Exp Expression
            deriving (Eq, Ord)

instance Show Kernel where
  show (Symbol str) = str
  show (Exp x) = "exp(" ++ show x ++ ")"

instance Floating Expression where
  exp = glexvar.Exp

compiled! I was really surprised, but it works:

*Main> let [x, y] = map glexvar [Symbol "x", Symbol "y"]
*Main> 13*x*y + exp(y^3 + x^2 - exp(x) + 4*exp(x))
13xy+exp(y^3+x^2+3exp(x))


>

-- 
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/fricas-devel/-/fz5x3PMCnKEJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/fricas-devel?hl=en.

Reply via email to