Utilizing RowList metaprogramming for non-empty records?
47 views
Skip to first unread message
Adam Saleh
unread,
Oct 30, 2017, 4:41:39 AM10/30/17
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to purescript
Hi all,
I have been playing around with the RowCons style meta-programming, mostly by downloading the purescript-map-record Justin Woo [1] and hacking away. By reusing various parts of the library I managed to create fold [2], traverse [3] and even something that looks like sequence [4] if you squint hard enough.
What I think I am interested in now, is to create fold1, traverse1 and sequence1 equivalents.
My main motivation to create a proper sequence1 for records, where if I have some Apply m and i.e. {a : m x, b: m y} I can easily convert it to m {a : x, b: y}. I don't think I would be able to manage a proper sequence with arbitrary Applicative m, because I don't think the compiler would be able to figure our the m for the empty record.
If I hard-code the Applicative though, as I did with Maybe in [4] it seems to work fine, so maybe there is some way?
Anyway, I understand that with the examples in purescript-map-record I am so far doing some-sort of type-level recursion that terminates with Nil row-list. Is there a way to terminate one level higher? Or some other workaround?
I am using Pulp version 12.0.1, purs version 0.11.6 using node/v8.4.0
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to purescript
It would be possible with instance chains in 0.12, I think. The problem is you have two different `Cons` cases: one that attempts to match a tail of `Nil`, and then the alternative. This isn't possible in 0.11 without overlapping instances.