[Haskell-cafe] Partial instance of a class
Tom Ellis
tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk
Tue Feb 27 11:21:51 UTC 2018
On Tue, Feb 27, 2018 at 12:02:49PM +0100, Jeroen Bransen wrote:
> >>In my concrete case I think a profunctor is indeed the thing I was looking
> >>for
> >If you're willing to share your datatype I may be able to help determine
> >exactly what sort of thing it is. I have extensively explored the place of
> >profunctors :)
> http://hackage.haskell.org/package/progress-reporting-1.1.0/docs/Control-Monad-Progress.html
>
> It's a class of functions (that may run in some monadic context) for
> which we can report progress. I can lift certain types of functions
> to this space (those that construct items of a list, or those that
> report their own progress in some way), and then these compose in
> several ways. Obviously having the first and second combinators from
> arrows comes in handy.
The type in question is WithProgress
data WithProgress m a b where
Id :: WithProgress m a a
WithProgressM :: ((Double -> m ()) -> a -> m b) -> WithProgress m a b
Combine :: WithProgress m b c -> WithProgress m a b -> WithProgress m a c
SetWeight :: Double -> WithProgress m a b -> WithProgress m a b
Is this definition of arr somehow unsatisfactory?
arr :: Applicative m => (a -> b) -> WithProgress m a b
arr f = WithProgressM (\_ a -> pure (f a))
NB that if you implement Category and Profunctor then you automatically get
arr (\f -> lmap f id).
Tom
More information about the Haskell-Cafe
mailing list