Personal tools

Embedded domain specific language

From HaskellWiki

(Difference between revisions)
Jump to: navigation, search
(observable sharing in graphs)
(Discussion of common problems)
 
(2 intermediate revisions by one user not shown)
Line 18: Line 18:
   
 
* Oleg in Haskell-Cafe about [http://www.haskell.org/pipermail/haskell-cafe/2008-February/039639.html Designing DSL with explicit sharing (was: I love purity, but it's killing me)]
 
* Oleg in Haskell-Cafe about [http://www.haskell.org/pipermail/haskell-cafe/2008-February/039639.html Designing DSL with explicit sharing (was: I love purity, but it's killing me)]
* Koen Classen: [http://www.cs.chalmers.se/~koen/pubs/entry-asian99-lava.html Observable Sharing for Functional Circuit Description]
+
* Koen Classen: [http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.31.4053 Observable Sharing for Functional Circuit Description]
* Andy Gill: [http://www.ittc.ku.edu/~andygill/paper.php?label=DSLExtract09 Type-Safe Observable Sharing]
+
* Andy Gill: [http://www.ittc.ku.edu/~andygill/papers/reifyGraph.pdf Type-Safe Observable Sharing]
 
* Tom Lokhorst [http://tom.lokhorst.eu/2010/02/awesomeprelude-presentation-video AwesomePrelude presentation (video)]
 
* Tom Lokhorst [http://tom.lokhorst.eu/2010/02/awesomeprelude-presentation-video AwesomePrelude presentation (video)]
 
* Leandro Lisboa Penz [http://lpenz.github.com/articles/hedsl-sharedexpenses/ Haskell eDSL Tutorial - Shared expenses]
 
* Leandro Lisboa Penz [http://lpenz.github.com/articles/hedsl-sharedexpenses/ Haskell eDSL Tutorial - Shared expenses]

Latest revision as of 14:50, 29 November 2012

Embedded Domain Specific Language means that you embed a Domain specific language in a language like Haskell. E.g. using the Functional MetaPost library you can write Haskell expressions, which are then translated to MetaPost, MetaPost is run on the generated code and the result of MetaPost can be post-processed in Haskell.


Contents

[edit] 1 Degree of embedding

There are two major degrees of embedding:

  • Shallow embedding: All Haskell operations immediately translate to the target language. E.g. the Haskell expression
    a+b
    is translated to a
    String
    like
    "a + b"
    containing that target language expression.
  • Deep embedding: Haskell operations only build an interim Haskell data structure that reflects the expression tree. E.g. the Haskell expression
    a+b
    is translated to the Haskell data structure
    Add (Var "a") (Var "b")
    . This structure allows transformations like optimizations before translating to the target language.


[edit] 2 Discussion of common problems

Sharing and recursion are common problems when implementing DSLs. Often some kind of observable sharing is requested that requires a deep embedding.

[edit] 3 Examples of Domain Specific Languages

  • Functional MetaPost is a Haskell frontend to the MetaPost language by John Hobby. Users write their graphics as Haskell programs, which then emit MetaPost code that can be compiled into encapsulated PostScript files and smoothly included into e.g. LaTeX.
  • orc: Orchestration-style coordination EDSL
  • The diagrams-cairo package. A full-featured backend for rendering diagrams using the cairo rendering engine. To get started, see Diagrams.Backend.Cairo.CmdLine.
  • Workflow: library for transparent execution of interruptible computations

[edit] 4 More to read/view