agentm / project-m36

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

user can't define ConstructedAtom's show #244

Open YuMingLiao opened 5 years ago

YuMingLiao commented 5 years ago

Since project-m36 imeplement ADT to represent structural messages, it may worth to have a user-defined show for ConstructedAtom. (and further, for AttributeName)

However, for now, not all ConstructedAtom come from Atomable instance. So the typeclass Show in haskell space cannot be utilized.

YuMingLiao commented 5 years ago

And, dataFrameAsHtml can't show utf8 character in TextAtom correctly. After I changed atomToText (TextAtom i) = T.pack . show $ i to i, it works. It is the show function that add some slash and make utf8 unable to be identified.

agentm commented 5 years ago

Is bc3997f00eaeff4256585bbae0905cd3826e4415 what you're looking for?

Please tell me more about the use-case for a custom Show implementation. What I imagined was that clients who need custom rendering would do so after receiving the ConstructedAtom itself via Binary serialization or the atom's JSON representation, not its text representation.

YuMingLiao commented 5 years ago

To translate a whole Relation, a TextAtom in HTML format seems not enough.

Since ConstructedAtom explains things better than null, I was hoping to able to see a ConstructedAtom in a tutd, not just in html format, with user's own language. It allows me to use the tutd's awsome ability to instantly show a complicated relvar expression.

I just found now, in a relvar, AttributeName, TextAtom and ConsturctedAotm, all of them, use Text. So, I guess, a user can have their own language by customized Atomable and Tupleable. one just need to handle the translation in fromX and toX. This is a way without adding code to project-m36. However, the project-m36 side lose the default Text representation.

But internalization seems to me a good idea to mention and talk about. I guess it helps international users to give relational algebra a taste.

If project-m36 only support one representation in tutd, then it seems then I'll need to translate a Relation or DataFrame in Haskell space and show it on the haskell side, HTML or IO, and lose the tutd's awsome ability to instantly show a complicated relvar expression.

To make a relvar have international representation. It need not to be show in a Show typeclass. But that requires project-m36 to get functions that translate Atom, AtomType and Attribute. And have a language setting in tutd, and showexpr changed result accordingly.

YuMingLiao commented 5 years ago

After second thought, relational algebra need one text representation to describe things in an expression. An multi language relation may not be useful. User already can define their own representation in custom atomable and tupleable.

agentm commented 5 years ago

Well, it's worth discussing. For example, what would a tutd session in Chinese look like? Since tutd is English-based I imagine the tutd syntax would change as well. Would each type have its own localized name?