agentm / project-m36

Project: M36 Relational Algebra Engine
The Unlicense
876 stars 47 forks source link

add template haskell quasi-quoter to support parsing TutorialD at compile-time #288

Open agentm opened 3 years ago

agentm commented 3 years ago

This could be a useful improvement so that users don't have to use the more verbose Haskell ADT directly.

executeRelationalExpr [tutd|s where name="Boston"|]
YuMingLiao commented 3 years ago

Hi @agentm

I've tried to embed the TutorialD in Haskell. I guess you might want to see it: ShortCut.hs It needs the convertible library.

Although it has some drawbacks:

{,,,} => [,,,] since Haskell can only overload []. the # prefix is needed for attribute names due to OverloadedLabels extension. the # prefix for relation-related operator and @ prefix for attribute-related operator is needed due to some keyword operator is preserved. f "count" [...] for function expressions. ... so it may look a bit weird. (And right now, relation type expression haven't been implemented.)

But there are some advantages too:

It can have a persistent with macro because Haskell can give an expression a function name. So it can compose. And maybe it can make expression as a function, not sure about that, haven't tried that. And plus, it can turn a type with Atomable type class in haskell into ConstructedAtomType directly.

Hope it helps.

agentm commented 3 years ago

Hm... the link included in the comment claims the file has been deleted. Can you make a pull request?

YuMingLiao commented 3 years ago

Oops. Okay, I've pulled a request now.

YuMingLiao commented 3 years ago

f "count" [...] for function expressions is a bad/not-working design. I'll see if I can fix it.