[Haskell-cafe] Re: Map constructor in a DSL

Ryan Ingram ryani.spam at gmail.com
Thu Oct 28 13:23:10 EDT 2010


On Thu, Oct 28, 2010 at 3:09 AM, Dupont Corentin
<corentin.dupont at gmail.com> wrote:
> EAp :: Exp ref (a -> b) -> Exp ref a -> Exp ref b
> It's from which DSL? It is accessible on the net?

It's my own, just written off the top of my head as an example.
Accessible "on the net": yes, it's in your email. there's nothing
more.

> But in the suggestions from Ryan and Brandon I don't understand why I should
> add an extra type parameter and what it is!

I don't know in Brandon's case, but in my case it's for two reasons:
(1) It allows you to write multiple interpreters for the language by
changing the type of variables passed around.  But, that's not
important if you are only planning to have a single interpreter.
(2) By parametricity, any CExp can't inspect the "insides" of a
reference; all ELam can do with its argument is pass it to EVar.  If
you have a concrete variable type, you can do weird things like

ELam (\(V x) -> EVar (V (x+1)))

which doesn't quite make sense. (how are you returning a variable
containing a different value than the one you passed in?

  -- ryan


More information about the Haskell-Cafe mailing list