Automatically "deducing" of wrappers

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Baa
Reply | Threaded
Open this post in threaded view
|

Automatically "deducing" of wrappers

Baa
Hello, List! This is a little bit theoretical question but not only...
Let's suppose I have a lot of functions like:

  llfunc :: A -> B -> C -> D -> C

and I have types C and HLC and "constructor" of HLC from C:

  makeHLC :: C -> Maybe HLC    -- or Either String HLC

and I want to create "automatically" (i.e. with minimal coding!)
functions like:

  hlfunc :: A -> B -> HLC -> D -> HLC   -- see llfunc

i.e. for each ll* (low-level) to create hl* (high-level). For example,
I can have even HLC -> C function. I may have a lot of llfunc's. Idea
is to replace a coding of hlfunc's with some automatically or
semi-automatically deduce/creating of them. For example, C may be
`FilePath`, HLC may be some kind of `Path a` (wrapper for paths). And I
have a lot of FilePath-based legacy functions.

I suppose it's possible to solve such problem in D language (I made
somthing similar several years ago). And possible it's easy in Nim
(Nimrod) because of them: a) types exist b) meta-programming features.
IMHO should be a way to do similar in Haskell, but it does not look
easy. IMHO I can code arguments + return types with Generic, and next
step may be type class with custom methods C -> HLC/HLC -> C and default
method like `perform` which will get Generic and automatically makes
instance of this type class or... And how will it look like?

Is it even possible in Haskell?


===
Best regards, Paul
_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners