dsl

How can Haskell quasiquotation be used for replacing tokens on the Haskell level?

 ̄綄美尐妖づ 提交于 2019-12-03 03:05:14
Quasiquotation as described in haskellwiki is shown mostly as useful tool for embedding other languages inside Haskell without messing around with string quotation. Question is: For Haskell itself, how easy it would be to put existing Haskell code through a quasiquoter for the purpose of just replacing tokens and passing the result over to ghc? Perhaps Template Haskell is key here? I have looked for code examples and didn't find any. Some EDSLs can benefit from this ability by reducing the size of their combinating operators (e.g. turn 'a .|. b .>>. c' to '[myedsl|a | b >> c]'). shang You can

Simplfying DSL written for a C# app with IronPython

孤者浪人 提交于 2019-12-03 02:59:17
Thanks to suggestions from a previous question , I'm busy trying out IronPython, IronRuby and Boo to create a DSL for my C# app. Step one is IronPython, due to the larger user and knowledge base. If I can get something to work well here, I can just stop. Here is my problem: I want my IronPython script to have access to the functions in a class called Lib. Right now I can add the assembly to the IronPython runtime and import the class by executing the statement in the scope I created: // load 'ScriptLib' assembly Assembly libraryAssembly = Assembly.LoadFile(libraryPath); _runtime.LoadAssembly

Working out the details of a type indexed free monad

余生长醉 提交于 2019-12-03 02:01:57
I've been using a free monad to build a DSL. As part of the language, there is an input command, the goal is to reflect what types are expected by the input primitive at the type level for additional safety. For example, I want to be able to write the following program. concat :: Action '[String, String] () concat = do (x :: String) <- input (y :: String) <- input output $ x ++ " " ++ y Along with an evaluation function eval :: Action params res -> HList params -> [String] eval = ... Which works in the following way.. > eval concat ("a" `HCons` "b" `HCons` HNil) ["a b"] Here's what I have so

Noise-free JSON processing with Scala

浪子不回头ぞ 提交于 2019-12-03 01:59:27
I'm coming from a dotnet land, but recently have been looking at the possibilities of alternative programming languages. Nothing really serious, just some bits here and there. Recently I've discovered Scala and I'm pretty fascinated with it. Despite non-deterministic tinkering, I've done some intermediate checks of stuff that is important for me in C# and I feel rather satisfied: functional notions - tick, ad-hoc polymorphism - tick, annotations - tick, reflection and codegen - tick. Now I'm thinking about how one would program an analogue of JSON processing library I've implemented in C# 4.0

What's the point of DSLs / fluent interfaces

廉价感情. 提交于 2019-12-02 19:10:58
I was recently watching a webcast about how to create a fluent DSL and I have to admit, I don't understand the reasons why one would use such an approach (at least for the given example). The webcast presented an image resizing class, that allows you to specify an input-image, resize it and save it to an output-file using the following syntax (using C#): Sizer sizer = new Sizer(); sizer.FromImage(inputImage) .ToLocation(outputImage) .ReduceByPercent(50) .OutputImageFormat(ImageFormat.Jpeg) .Save(); I don't understand how this is better than a "conventional" method that takes some parameters:

Good books on Ruby based DSL [closed]

非 Y 不嫁゛ 提交于 2019-12-02 16:53:00
I'm trying to create a DSL in ruby, can you suggest me some good books? I looked around amazon and safari but so far couldn't find any. Thanks in advance! Mike Woodhouse Here are some possible sources: Metaprogramming Ruby: Program Like the Ruby Pros (Prag Progs, Feb 2010) Martin Fowler's DSL Book (in beta) Martin Fowler's Domain Specific Languages book contains some Ruby examples in the Internal DSLs section. You can read the work in progress on his web site or if you've got a Safari account then it's available as a rough cut . There are also some slides here from an Agile DSL Development in

Extended computation expressions without for..in..do

人走茶凉 提交于 2019-12-02 16:41:48
What I mean by extended computation expressions is computation expressions with custom keywords defined via CustomOperation attribute. When reading about extended computation expressions , I come across very cool IL DSL by @kvb: let il = ILBuilder() // will return 42 when called // val fortyTwoFn : (unit -> int) let fortyTwoFn = il { ldc_i4 6 ldc_i4_0 ldc_i4 7 add mul ret } I wonder how the operations compose without using for..in..do construct. My gut feeling is that it starts with x.Zero member, but I haven't found any reference to verify that. If the example above is too technical, here is

What are the main differences between Jetbrains' MPS and Eclipse Xtext?

北战南征 提交于 2019-12-02 15:24:16
I have used Eclipse Xtext in several projects. I loved the ease of defining a grammar over an Ecore (meta)model and letting everything generated for you including awesome Eclipse plugin editor, but I was quite uncomfortable with the underlying EMF framework with everything hard-wired in static fields. Lately I came across Jetbrains' MPS (Meta Programming System) . It's based on completely different philosophy. While Xtext is for creating text-based DSLs generating a parser for you (and instantiating those EObjects), in MPS-created language one edits directly underlying model structure. So far

Convert Hibernate @Formula to JOOQ field

会有一股神秘感。 提交于 2019-12-02 11:26:03
问题 I am rewriting entire DB access layer from Hibernate to JOOQ and I face following issue. One of JPA models is annotated with @Formula annotation as follows: @Formula("fee1 + fee2 + fee3 + fee4") private BigDecimal fee5; Later in the code, a JPA query is made against the database which compares fee5 to parameter: SELECT ... FROM ... WHERE fee5 > input; How can above query be translated to JOOQ DSL? 回答1: I managed to resolve the issue with following JOOQ query: BigDecimal input = ...; Field

Modeling set-based code-listings of sql data manipulation operations

假装没事ソ 提交于 2019-12-01 20:06:25
Technologies like LINQ do a good job being able to describe relational data queries, with types such as IQueryable , IGrouping , and IOrderedQueryable modeling projections , selections , aggregations , sorting , etc. These concepts from relational algebra allow us to communicate a fairly arbitrary query in one language on one machine and execute it in a different language (~sql) on a different machine. It would be nice to be able to do the same thing for even more complicated multi-part queries and even for data manipulation commands involving INSERT s, UPDATE s, and DELETE s which can