[Haskell-beginners] Making a generic interpreter

Brent Yorgey byorgey at seas.upenn.edu
Fri May 6 20:01:08 CEST 2011


On Fri, May 06, 2011 at 07:39:13PM +0200, Erik Helin wrote:
> Hi Patrick,
> thanks for taking your time!
> 
> On Fri, May 6, 2011 at 18:45, Patrick LeBoutillier
> <patrick.leboutillier at gmail.com> wrote:
> > I don't see how you can make the StackBool something else than Bool.
> > The CMP and BRANCH operators seem to me very Boolean by definition.
> > Can you provide an example of how it would work?
> >
> > Patrick
> >
> 
> I actually can :) I've been hacking today, and the result is:
> 
> {-# LANGUAGE MultiParamTypeClasses #-}
> {-# LANGUAGE FunctionalDependencies #-}
> 

Why not use

> class (Show a) => AbsInteger a where
>     (+)        :: a -> a -> a
>     (==)       :: AbsBool b => a -> a -> b
>     absInteger :: Integer -> a

?

-Brent



More information about the Beginners mailing list