What is the best way to start a GHC proposal

… Huh. If I/O were possible but internal-to-the-language divergence wasn’t, would that actually matter to you?

I may have an answer to that…but it’s probably too far off-this-topic; a new thread seems more appropriate for it.

That is missing the point. I would like to be able to use "Int" as a value which comes from somewhere (like a file or the result of a function) , not a hard coded value.
So yes quotation are very convenient but they are (in there actual form) very limited. It seems that everything related to types (type name, constructor etc …) can not be anti-quoted which is really inconvenient if your creating for examples new types from others.

It could be the result of a function:

foo True = [t|Bool]
foo False = [t|Int]

...

  [d| data A = A $(foo (even 7)) |]

Getting it out of a file is more difficult. It’s still possible if the file is only choosing from a fixed set of types (possibly inifinite), but it cannot just name any string as a name. Although you can do that with ConT (mkName "Int"), which is probably a pretty stable and lightweight part of the API. But that is also highly unsafe as the name might not exist.

1 Like

I understand that there is a need for staging things and I might have no use the correct word.
What I mean is what is referred as declaration groups

I don’t want to and I am happy to separate (within the same file) the code to run as macro and the code to be compiled (maybe a bit like how literate haskell work). TH mixes both codes, for example you use the same import section to import code to be compiled (and which need to be linked) and code that you only need to generate the code (which needs to be linked at compile time but not at run time). Maybe what I am describing is more a pre-processor than a macrosystem. I agree that this “system” might be able to do everything that TH does , but it could some it in a simpler way or some other than TH can’t do (like using String in data splices).
We could have both system.

Anyway, are you trying to help me to design such a system (which might result in extending in TH) or just to prove me that I should just give up.

Why does everybody take everything literally in this forum ?

Ok, you used a function but the final types are still hard coded ([t|Bool|] and [t|Int|]) which defeats the point of metaprogramming.

When I said function I means things like (++ "F") So I can create FooF from Foo.

Yes, but @rhendric was talking about quotation and was trying to find example where quotation were not sufficient.

It was an example, and I actually I have had problems with ConP which isn’t stable.

But I got the message, everybody is there to defend Template Haskell and I am fighting a lost battle so I shant’ bother.

I am trying to dissuade you from proposing sweeping reforms without adequately understanding the existing solution. I am not trying to convince you to give up on improving the status quo. But whatever forms your efforts take, I expect you’ll be more successful if you put more energy into looking for the good in what exists instead of starting from scratch and trying to make what exists conform to your vision of the ideal. You’re not the only person to have thought about what ideal Haskell metaprogramming would look like!

I’m also trying to dissuade you from this. Template Haskell is already poorly understood by many; how much worse would it be if there were two macro systems for users to choose from?

2 Likes

So TH is so bad

that it needs to be protected from an eventual competition … bizare

That’s a pretty massive reinterpretation of what I said, but okay. Good luck with your proposal.