[Haskell-cafe] Generalising Categories - categories of tuples
clintonmead at gmail.com
Wed Feb 17 05:01:02 UTC 2016
Thanks for the reply. I'm not sure what you mean however by making the code
shorter. Could you show an example that relates to category composition
which my code is about, not function application?
I considered putting the category arguments in the class head like you have
in your example, but as discussed in the blog, I found I'd lose type
inference, unless I put in all the equality constraints anyway.
Could you perhaps show how I could rewrite the class and the (f1, f2) .
(f1', f2') = (f1 . f1', f2 . f2') instance with shorter code?
On Wed, Feb 17, 2016 at 3:53 PM, adam vogt <vogt.adam at gmail.com> wrote:
> Hi Clinton,
> HList has some functions that help with defining something similar: <
> https://gist.github.com/aavogt/50d5313c99b7224b62dd>. It might be
> possible to use less classes to define the replicate/zip/map functions
> needed (by using more GADTs and type families instead) and end up being
> allowed to define an instance Control.Category.Category HF.
> Your code will be shorter if you make instance heads more general and use
> equality constraints (~). I mean that the following instance (from my
> paste) gets selected as long as the first argument to ($) is a function,
> and no type families are needed:
> instance (a ~ a', b ~ b') => Dollar (a -> b) a' b'
> where f $ x = f x
> On Tue, Feb 16, 2016 at 12:21 AM, Clinton Mead <clintonmead at gmail.com>
>> Hi All
>> I've been doing some work on generalising categories, basically so the
>> composition operator (.) works for not just functions, but things like
>> tuples of functions, whilst still retaining type inference.
>> Control.Category is a bit too restrictive for such instances.
>> You can see the details in my blog post here:
>> Any comments appreciated, I hope people find it interesting. Also, a
>> quick plug, I'm looking for work, so if there's any Haskell (and/or
>> functional programing) work around Sydney, Australia going I'd be
>> interested. :-)
>> If people really think this is useful, tell me, and I'll try to put it up
>> as a package. Alternatively, if it's already been done, I'd appreciate a
>> pointer in that direction.
>> Clinton Mead
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe