viercc / matchable Goto Github PK
View Code? Open in Web Editor NEWMatchable Functors
License: BSD 3-Clause "New" or "Revised" License
Matchable Functors
License: BSD 3-Clause "New" or "Revised" License
matchable
--allow-newer
--allow-newer
matchable-th
--allow-newer
--allow-newer
Matchable
, Bimatchable
classes themselves can be defined in Haskell98. Currently it requires base >= 4.10
.
Hi there, I independently discovered something like your Matchable
, but I'm actually using the Bifunctor
version. Would you be interested in adding this typeclass to your package?
class Bifunctor f => Bimatchable f where
bimatch :: f a x -> f b y -> Maybe (f (a, b) (x, y))
bimatch = bimatchWith (fmap Just . (,)) (fmap Just . (,))
bimatchWith
:: (a -> b -> Maybe c) -> (x -> y -> Maybe z)
-> f a x -> f b y -> Maybe (f c z)
Note that, to match your Matchable
, we'd want to add an Eq2
superclass, though I'm not convinced it's necessary.
Taking an idea from https://hackage.haskell.org/package/recursion-schemes-5.2.2.2/docs/Data-Functor-Foldable-TH.html
It'll be good to be able to do this โ
data Foo a b = Foo a [b] deriving Functor
makeMatchableInstances [d|
instance Eq a => Eq1 (Foo a)
instance Eq a => Matchable (Foo a)
|]
For my own project I wrote deriveBimatchable
(like the functions you'd find in Data.Bifunctor.TH
). I could adapt it and write deriveMatchable
as well, if you're interested.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.