Support for additional type classes #916
Replies: 1 comment
-
I was holding off for a while to see how the concepts/shapes proposal progressed with
In principle I'm all for bespoke implementations of the types, but the general story isn't so great. Right now I'm unfortunately very time poor, so I probably won't be looking at this in the short term I'm afraid. But I'll keep this open, because I agree they're valuable. |
Beta Was this translation helpful? Give feedback.
-
I think it would be a nice addition to this library to support some of the following type classes from Haskell:
Comonad w
extract :: w a -> a
duplicate :: w a -> w (w a)
extend :: (w a -> b) -> w a -> w b
Contravariant
contramap :: (a -> b) -> f a -> f b
Profunctor
lmap :: (a -> b) -> p b c -> p b c
lmap :: (b -> c) -> p a b -> p a c
dimap :: (a -> b) -> (c -> d) -> p b c -> p a d
Arrow
arr :: (b -> c) -> a b c
first :: a b c -> a (b, d) (c, d)
second :: a b c -> a (d, b) (d, c)
pair :: a b c -> a b' c' -> a (b, b') (c, c')
combine :: a b c -> a b c' -> a b (c, c')
Along with some comonad types:
Env e a = (e, a)
(reader comonad)Traced m a = m -> a
(writer comonad)Store s a = (s -> a) -> s
(state comonad)NonEmpty a = a | (a * (NonEmpty a))
(non-empty list)Stream a = a * Stream a
(strictly infinite list)RoseTree a = a * [RoseTree a]
(rose tree)This list of type classes and types is meant as suggestions.
I think they might be benifitial for anyone and general enough for a functional base library.
I've written implementations of all of these types myself, but I don't think my implementation comes anywhere close to the quality of this library.
I could work on more elaborate implementations and provide them as a pull request if desired when I find time to re-implement them.
Beta Was this translation helpful? Give feedback.
All reactions