<div dir="ltr">I've done a bit of work on a library that allows you to `fmap` say over sets, (i.e. fmap :: Ord a, Ord b => (a -> b) -> Set a -> Set b) which is more powerful than Monofunctor as it doesn't require the types to be the same.<div><br><div>And it will involve importing a new version of "Functor" and "fmap", however it should be largely backwards compatible.</div><div><br></div><div>However, it still needs a little bit of work to be in a state ready to be uploaded to Hackage (and even then, it probably needs even more work) but I'll give you a buzz when its up, hopefully in the next week or so.</div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Feb 28, 2017 at 2:01 PM, Guru Devanla <span dir="ltr"><<a href="mailto:gurudev.devanla@gmail.com" target="_blank">gurudev.devanla@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Thanks, Will. I think adding the constraint to the functions is a good idea. Plus, it makes the intent clearer at the function level.<br></div><div><div><br><br></div></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Feb 27, 2017 at 6:02 PM, Will Yager <span dir="ltr"><<a href="mailto:will.yager@gmail.com" target="_blank">will.yager@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div></div><div>1. You could use MonoFunctor (complicated and probably not a good idea here) or just put the Taskable constraint on functions instead of on the Task definition (good and easy). </div><div><br></div><div>So it would be</div><div><br></div><div>data Task a = Task a deriving Functor</div><div><br></div><div>And then put "Taskable a" on functions that require it. </div><div><br></div><div>2. You can't do it because it doesn't really make sense. A big part of a functor is that it has to be totally agnostic of what it's parametrized over. Otherwise you could easily violate the functor laws. </div><div><br></div><div>Good question though, I used to wonder the same thing. </div><div><br></div><div>cheers,</div><div>Will</div><div><div class="m_-1779362276913801953h5"><div><br>On Feb 27, 2017, at 6:48 PM, Guru Devanla <<a href="mailto:gurudev.devanla@gmail.com" target="_blank">gurudev.devanla@gmail.com</a>> wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr"><div>Hello All,<br><br>I am working on a program that will define a bunch of tasks. Each task<br>will have to implement certain methods as part of a type class.<br><br>-- task 1<br>data UpdateAcctsTask = UpdateAccts<br><br>-- task 2<br>data EmailConfig = EmaiConfig {someattrs::String}<br>data SendEmailTask = SendEmailsTask EmailConfig<br><br>-- task 3<br>data GeneralWriterTask a = GeneralWriterTask a<br><br>Each of these tasks implement a class, Taskable. The return<br>values are simplified for this example.<br><br>class Taskable a where<br> process :: a -> Bool<br> can_run :: a -> Bool<br><br><br>This works fine. I can expand on these tasks and execute them.<br><br>Now, I wanted to be able to defined dependencies between these (Taskable's). I decided<br>I could create a data type for this dependency and may be also get a FreeMonad<br>around this structure for further processing using a graph of Tasks. But, before that I wanted<br></div>to create an wrapper for these Taskables and create a functor for it as follows<br><div><br>The first thing I did was, define a Task, which generalizes over all<br>the above defined (and future Taskables)<br><br>data Task a where<br> Task :: (Taskable a) => a -> Task a<br><br><br>instance Functor Task where<br> fmap:: (Taskable a, Taskable b) -> (a -> b) -> Task a -> Task b --- THIS DOES NOT WORK<br> fmap f (Task a) = Task $ f a<br><br><br>But, I realized that I cannot define an fmap over a type constraint.<br><br>My questions are:<br><br>1. Is there any way to do this. I see there is an answer of SO. I wanted<br> to make sure if there were any improvements to this since that answer'<br> was posted. <br> <a href="http://stackoverflow.com/questions/17157579/functor-instance-for-a-gadt-with-type-constraint" target="_blank">http://stackoverflow.com/quest<wbr>ions/17157579/functor-instance<wbr>-for-a-gadt-with-type-constrai<wbr>nt</a><br><br>2. Secondly, I would like to know why this is not possible. Is it a current<br> limitation of GHC or if there is some fundamental category theory concepts<br> that dis-allows such declarations that I need to grok!<br><br></div>Appreciate any help on this. Thank you!<br></div>
</div></blockquote></div></div><blockquote type="cite"><div><span>______________________________<wbr>_________________</span><br><span>Haskell-Cafe mailing list</span><br><span>To (un)subscribe, modify options or view archives go to:</span><br><span><a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" target="_blank">http://mail.haskell.org/cgi-bi<wbr>n/mailman/listinfo/haskell-caf<wbr>e</a></span><br><span>Only members subscribed via the mailman list are allowed to post.</span></div></blockquote></div></blockquote></div><br></div>
</div></div><br>______________________________<wbr>_________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-<wbr>bin/mailman/listinfo/haskell-<wbr>cafe</a><br>
Only members subscribed via the mailman list are allowed to post.<br></blockquote></div><br></div>