Advertisement
Guest User

Untitled

a guest
Jan 19th, 2019
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. Hi, here's is the problem I was talking about yesterday in a distilled form:
  2.  
  3. I want to talk about datatypes which have deep recursive structure, ideally:
  4.  
  5. class (WellFormed a, All2 WellFormedR (Code a)) => WellFormedR a where
  6.  
  7. This would work, with some extensions like UndecidableSuperClasses, if I could
  8. instantiate leaf types, like Int, with something like:
  9.  
  10. instance All2 WellFormedR (Code Int) where
  11.  
  12. This cannot happen because All2 is a type synonym and cannot be directly
  13. instantiated, and `Code Int` does not really evaluate to an actual list of list
  14. of types.
  15.  
  16. Now, there are libraries which deal with this recursive idea (see the recent
  17. generics-mrsop) but they bring a lot of problems that imho are unnecessary in
  18. this use case, because I actually don't care for the recursive position of the
  19. same datatype (ie. in Foo, I don't care to know the recursive positions in which
  20. I have Foo - I just want to treat uniformly the recursion).
  21.  
  22. The motivation for this kind of structure this time is that I want to talk about
  23. typed substitutions for a prolog-like engine, I have working code here [0], and
  24. I was progressing smoothly with a few workarounds until I had to write a type
  25. signature for:
  26.  
  27. unify :: (?) => Term a -> Term a -> Unification Substitution
  28.  
  29. As the subterms have to be unified, they have to share the same constraint I
  30. put on unify, recursively, and I haven't found a workaround for this.
  31.  
  32. If you have any ideas on how I should approach this problem and why, please
  33. share!
  34.  
  35. [0] https://gist.github.com/meditans/a0d3075c3a6f99f73c598c5bd839b2b3
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement