I am trying to port a programme written in Maude, which is a reflective
language based on rewriting logic ( http://maude.cs.uiuc.edu/ ), to
Haskell. I thought using Template Haskell might be a good idea, but I
got stuck and now I am wondering if this is really possible in Haskell.
Let me give an example of a Maude module defining the function last over
a list of Peano numbers. 

fmod LAST is
        sorts Peano PeanoList .
        
        op 0 : -> Peano [ctor] .
        op s : Peano -> Peano [ctor] .
        
        op [] : -> PeanoList [ctor] .
        op cons : Peano PeanoList -> PeanoList [ctor] .
        
        op last : PeanoList -> Peano .
        
        vars X Y : Peano .
        var Xs : PeanoList .
        
        eq last(cons(X,[])) = X .
        eq last(cons(X,cons(Y,Xs))) = last(cons(Y,Xs)) .
        
endfm

So, last(cons(s(0),cons(s(s(0)),cons(s(s(s(0))),[])))) would reduce to
s(s(s(0))). The cool thing about Maude is, that terms, modules, ... can
be lifted to the meta level. For example:

upModule('LAST, false)

would yield


_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to