3 ms·
Pattern synonyms are really expressive but the complex version is kinda headache inducing: http://hackage.haskell.org/package/lens-4.17/docs/src/Control.Lens.C
by Tarean 8y ago
Pattern synonyms are really expressive but the complex version is kinda headache inducing:
http://hackage.haskell.org/package/lens-4.17/docs/src/Control.Lens.Cons.html#%3A< http://hackage.haskell.org/package/lens-4.17/docs/src/Contro...
This creates a bidirectional pattern synonym - you can both match and construct values with it:
foo :: Cons' s Char => s -> s
foo (a :< b) = 'c' :< b
foo other = other
Pattern synonyms make completeness checking undecidable so you need to give manual hints to get a nice api. It also wreaks cost models - is foo O(1) or O(n)?