-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use representable Moore and Mealy #73
Comments
You may actually want an data Mealy a b where
Mealy :: (Applicative u, Adjunction f u) => f (u (a -> f b)) -> Mealy a b This allows you to do things like define arr = (coerce :: (Identity (Identity (a -> Identity b)) -> Mealy a b) -> (a -> b) -> Mealy a b) Mealy The instance Choice Mealy where
left' (Mealy fu) = Mealy $ fmap (liftA2 (\fr fl -> either (fmap Left . fl) (fmap Right . fr)) $ distribute unit) fu
right' (Mealy fu) = Mealy $ fmap (liftA2 (\fl fr -> either (fmap Left . fl) (fmap Right . fr)) $ distribute unit) fu You don't technically need liftAdj2 :: Adjunction f u => (a -> b -> c) -> u a -> u b -> u c
liftAdj2 f ua ub = leftAdjunct (\fab -> f (rightAdjunct fst fab) (rightAdjunct snd fab)) (ua, ub) But as mentioned before, every sensible |
NB: It isn't until you allow adjunctions to spread to other categories than just Hask -> Hask that anything extra is gained. |
Using |
Interestingly it is possible to implement |
You mean with fs <*> xs = (\(Pair (Left f) (Right x)) <$>
distribute (Pair (fmap Left fs) (fmap Right xs)) or something like that? I guess it uses parametricity to ensure totality. |
https://www.fpcomplete.com/user/edwardk/moore/for-less
This would give us Moore machines with a more efficient mapping operation for one, and all of the recent improvements could be ported over.
The text was updated successfully, but these errors were encountered: