> > Right, that makes sense, and indeed > > implicit def monoidOfTagged[T, A](implicit M0: Monoid[A]): Monoid[A @@ T] = > Tag.subst[A, Monoid, T](M0) > > > works perfectly. >
> Now, when I am thinking back, I realise, that at the beginning the goal > was to apply binary operations on tagged values. For example you can add > Kilogramms or Cms to each other, but you can not add Kg to Cm, so it should > not compile. While tagging solves the second problem, the first one still > remains (I think to #unwrap manually every time you wan to add two numbers > - is not a real solution), so I thought to solve it with Monoid. But now I > see, that it does not give you arithmetical operations at all, and > moreover, this reasoning is only valid when Numbers are tagged. > > So actually, it makes sense to have this functionality on a Numeric > typeclass (which is most likely noy the scalaZ domain): > > implicit def numericOfTagged[T, A: Numeric]: Numeric[A @@ T] > > On Monday, 26 September 2016 09:45:29 UTC+2, Stephen Compall wrote: > > On September 26, 2016 2:28:53 PM GMT+07:00, Chris Marshall < > [email protected] <javascript:>> wrote: > >I think scalaz should roll with a non > >implicit conversion you can use when you definitely want it, > > Indeed, `Tag.subst` and TagOf#subst can do this already; for example, > Gleb, you can write > > implicit def monoidOfTagged[T, A](implicit M0: Monoid[A]): Monoid[A @@ T] > = Tag.subst(M0) > > subst is highly abstract and applicable in a huge variety of contexts; > every on* function in Tag and everything else is just a specialization of > subst or unsubst. > -- > Stephen Compall > If anyone in the MSA is online, you should watch this flythrough. -- You received this message because you are subscribed to the Google Groups "scalaz" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/scalaz. For more options, visit https://groups.google.com/d/optout.
