Zap in cats?

20 views
Skip to first unread message

Chen Harry

unread,
Mar 13, 2018, 5:21:17 AM3/13/18
to scala...@googlegroups.com
I am trying to use Cofree to interpret the program written in Free monad. There is a Zap typeclass in Scalaz can help to do that. does Cats have similar typeclass which is equivalent to Scalaz.Zap? or it is a obsolete tech to interpret Free program? 
Thanks,
Harry

Tony Morris

unread,
Mar 13, 2018, 6:58:06 AM3/13/18
to scala...@googlegroups.com

It is not obsolete tech to interpret Free program.

--
You received this message because you are subscribed to the Google Groups "Melbourne Scala User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-melb+...@googlegroups.com.
To post to this group, send email to scala...@googlegroups.com.
Visit this group at https://groups.google.com/group/scala-melb.
For more options, visit https://groups.google.com/d/optout.

signature.asc

Chen Harry

unread,
Mar 13, 2018, 7:30:53 PM3/13/18
to scala...@googlegroups.com
Good to know that. thanks Tony.

Chen Harry

unread,
Mar 14, 2018, 6:43:12 AM3/14/18
to scala...@googlegroups.com
I am trying scalaz to interpret Free program by Cofree interpreter: https://gist.github.com/chenharryhua/a4d14896b2a26b30fe85e8d2cac143b1
the program is pretty simple: a traditional terminal DSL. 
my problem is that it is compiled but when I run it, a runtime error occurs: java.lang.ClassCastException: scala.runtime.BoxedUnit cannot be cast to scalaz.Free.

I am highly appreciated if someone give me some clue.
 
Thanks,
Harry


Chen Harry

unread,
Mar 14, 2018, 7:36:23 PM3/14/18
to scala...@googlegroups.com
use non-GADT encoding for algebra. it works fine. I've updated the gist. thanks everyone. Ken's code (https://github.com/kenbot/free/blob/master/src/main/scala/kenbot/free/KVS.scala) helps a lot.

Ken Scambler

unread,
Mar 14, 2018, 10:34:33 PM3/14/18
to Unname
David Laing did some articles & talks on using Cofree a few years ago, which you might find interesting:

http://dlaing.org/cofun/posts/free_and_cofree.html

https://www.youtube.com/watch?v=IhzvLsvRO98


On 15 March 2018 at 10:36, Chen Harry <chen.ha...@gmail.com> wrote:
use non-GADT encoding for algebra. it works fine. I've updated the gist. thanks everyone. Ken's code (https://github.com/kenbot/free/blob/master/src/main/scala/kenbot/free/KVS.scala) helps a lot.
On Wed, Mar 14, 2018 at 9:42 PM Chen Harry <chen.ha...@gmail.com> wrote:
I am trying scalaz to interpret Free program by Cofree interpreter: https://gist.github.com/chenharryhua/a4d14896b2a26b30fe85e8d2cac143b1
the program is pretty simple: a traditional terminal DSL. 
my problem is that it is compiled but when I run it, a runtime error occurs: java.lang.ClassCastException: scala.runtime.BoxedUnit cannot be cast to scalaz.Free.

I am highly appreciated if someone give me some clue.
 
Thanks,
Harry



On Wed, Mar 14, 2018 at 10:30 AM Chen Harry <chen.ha...@gmail.com> wrote:
Good to know that. thanks Tony.

On Tue, Mar 13, 2018 at 9:58 PM Tony Morris <tonym...@gmail.com> wrote:

It is not obsolete tech to interpret Free program.


On 13/03/18 19:21, Chen Harry wrote:
I am trying to use Cofree to interpret the program written in Free monad. There is a Zap typeclass in Scalaz can help to do that. does Cats have similar typeclass which is equivalent to Scalaz.Zap? or it is a obsolete tech to interpret Free program? 
Thanks,
Harry

--
You received this message because you are subscribed to the Google Groups "Melbourne Scala User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-melb+unsubscribe@googlegroups.com.

To post to this group, send email to scala...@googlegroups.com.
Visit this group at https://groups.google.com/group/scala-melb.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Melbourne Scala User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-melb+unsubscribe@googlegroups.com.

To post to this group, send email to scala...@googlegroups.com.
Visit this group at https://groups.google.com/group/scala-melb.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Melbourne Scala User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-melb+unsubscribe@googlegroups.com.

Chen Harry

unread,
Mar 14, 2018, 11:00:12 PM3/14/18
to scala...@googlegroups.com
Yep.. I referred a few blogs. the one you mentioned is one of them. there are a few also very helpful:


On Thu, Mar 15, 2018 at 1:34 PM Ken Scambler <ken.sc...@gmail.com> wrote:
David Laing did some articles & talks on using Cofree a few years ago, which you might find interesting:

http://dlaing.org/cofun/posts/free_and_cofree.html

https://www.youtube.com/watch?v=IhzvLsvRO98

On 15 March 2018 at 10:36, Chen Harry <chen.ha...@gmail.com> wrote:
use non-GADT encoding for algebra. it works fine. I've updated the gist. thanks everyone. Ken's code (https://github.com/kenbot/free/blob/master/src/main/scala/kenbot/free/KVS.scala) helps a lot.
On Wed, Mar 14, 2018 at 9:42 PM Chen Harry <chen.ha...@gmail.com> wrote:
I am trying scalaz to interpret Free program by Cofree interpreter: https://gist.github.com/chenharryhua/a4d14896b2a26b30fe85e8d2cac143b1
the program is pretty simple: a traditional terminal DSL. 
my problem is that it is compiled but when I run it, a runtime error occurs: java.lang.ClassCastException: scala.runtime.BoxedUnit cannot be cast to scalaz.Free.

I am highly appreciated if someone give me some clue.
 
Thanks,
Harry



On Wed, Mar 14, 2018 at 10:30 AM Chen Harry <chen.ha...@gmail.com> wrote:
Good to know that. thanks Tony.

On Tue, Mar 13, 2018 at 9:58 PM Tony Morris <tonym...@gmail.com> wrote:

It is not obsolete tech to interpret Free program.


On 13/03/18 19:21, Chen Harry wrote:
I am trying to use Cofree to interpret the program written in Free monad. There is a Zap typeclass in Scalaz can help to do that. does Cats have similar typeclass which is equivalent to Scalaz.Zap? or it is a obsolete tech to interpret Free program? 
Thanks,
Harry

--
You received this message because you are subscribed to the Google Groups "Melbourne Scala User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-melb+...@googlegroups.com.

To post to this group, send email to scala...@googlegroups.com.
Visit this group at https://groups.google.com/group/scala-melb.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Melbourne Scala User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-melb+...@googlegroups.com.

To post to this group, send email to scala...@googlegroups.com.
Visit this group at https://groups.google.com/group/scala-melb.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Melbourne Scala User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-melb+...@googlegroups.com.

To post to this group, send email to scala...@googlegroups.com.
Visit this group at https://groups.google.com/group/scala-melb.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Melbourne Scala User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-melb+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages