-
Notifications
You must be signed in to change notification settings - Fork 43
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
instance for Control.Monad.Trans.Select #59
Comments
Turns out SelectT has parameters in the wrong order. Still, djinn can write a dimap for |
I'm a bit confused here—are you proposing something concrete here that |
{-# LANGUAGE FlexibleInstances #-}
import Control.Monad.Trans.Select
import Data.Profunctor
import Data.Coerce
newtype T m r a = T (SelectT r m a)
newtype U m r a = U (Costar ((->) a) (m r) (m a))
newtype V m r a = V ( (a -> m r) -> m a )
ut :: T m r a -> U m r a
ut = coerce
tv :: T m r a -> V m r a
tv = coerce
instance Functor f => Profunctor (T f) where
dimap a b (T (SelectT c)) = T $ SelectT $ \d -> b <$> c (fmap a . d . b)
{- law abiding:
dimap id id (T (SelectT c)) =>
T $ SelectT $ \d -> id <$> c (fmap id . d . id)
T $ SelectT $ \d -> c (id . d . id) -- fmap id
T $ SelectT $ \d -> c d -- id and (.)
T $ SelectT $ c
(T (SelectT c))
=> dimap id id = id
-}
|
Indeed, I think changing the order of type variables in I don't have a strong opinion on adding a newtype wrapper around I suppose a general solution would be to figure out a way to make this typecheck: newtype Swizzle p m a b = Swizzle { runSwizzle :: p a m b }
instance (???) => Profunctor (Swizzle p m) where ... But I don't know what to put in place of the |
SelectT
is in http://hackage.haskell.org/package/transformers-0.5.4.0/docs/Control-Monad-Trans-Select.html but is missing fromtransformers<=0.5.2.0
. It is (not?) a Profunctor because:I haven't looked into
ctx :: (* -> *) -> Constraint
ininstance ctx m => Profunctor (SelectT m)
, ctx /= Identity.The text was updated successfully, but these errors were encountered: