co-routine support in Frege?

30 views
Skip to first unread message

zhou...@163.com

unread,
Nov 17, 2017, 5:13:20 AM11/17/17
to Frege Programming Language
In scheme, I can implement my co-routine by defining a function like this:

(define (spawn prog)
 (call/cc
  (lambda (start)
    (let ((suspend (lambda ()
               (call/cc
                (lambda (k)
                      (start k))))))
      (prog suspend)))))

Recently I use Frege to program android, I notice that  Control.Monad.Cont is not available, I try to define it follow the book https://en.wikibooks.org/wiki/Haskell/Continuation_passing_style

newtype Cont r a = Cont { runCont :: ((a -> r) -> r) } -- r is the final result type of the whole computation 
 
instance Monad (Cont r) where
   
return a       = Cont $ \k -> k a                       -- i.e. return a = \k -> k a
   
(Cont c) >>= f = Cont $ \k -> c (\a -> runCont (f a) k) -- i.e. c >>= f = \k -> c (\a -> f a k)

But no luck, 'newtype' is not supported by Frege

Dierk König

unread,
Nov 17, 2017, 5:41:26 AM11/17/17
to frege-program...@googlegroups.com
Cool. 
You can just use “data” in replacement of “newtype”. It makes no difference to the generated code. 

It would be cool to hear more about your project!

Cheers
Dierk

sent from:mobile 
--
You received this message because you are subscribed to the Google Groups "Frege Programming Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to frege-programming-l...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

zhou...@163.com

unread,
Nov 19, 2017, 7:19:32 AM11/19/17
to Frege Programming Language
I am finally giving up thinking about Haskell mtl way, instead, I decide to try kilim and akka in Frege, I feel like Frege is an universal glue which greatly mitigate my bad feeling by direct programming on Java. I am currently leading an effort to put Frege on our production environment, our team only have scheme programming experience before, they are really accustomed to REPL and Emacs programming environment. I develop an simple dex code dynamically loading mechanism,  so that we can use Emacs Haskell mode to edit Frege code and one key binding to translate into dex jar and loaded by the Frege activity program. Saving a lot of time watching grandle building process. With this machinery, I rewrite a lot of android code on the fly, the USB code, the RSA code, the networking code, the DateBase access code. But when I came to serial port code, I need coroutine just like I did it on gambit-c scheme. Although nobody reports that kilim can ever been ported to android, but I think it is just the proguard configuration thing

在 2017年11月17日星期五 UTC+8下午6:13:20,zhou...@163.com写道:

zhou...@163.com

unread,
Nov 19, 2017, 7:20:16 AM11/19/17
to Frege Programming Language
I am finally giving up thinking about Haskell mtl way, instead, I decide to try kilim and akka in Frege, I feel like Frege is an universal glue which greatly mitigate my bad feeling by direct programming on Java. I am currently leading an effort to put Frege on our production environment, our team only have scheme programming experience before, they are really accustomed to REPL and Emacs programming environment. I develop an simple dex code dynamically loading mechanism,  so that we can use Emacs Haskell mode to edit Frege code and one key binding to translate into dex jar and loaded by the Frege activity program. Saving a lot of time watching grandle building process. With this machinery, I rewrite a lot of android code on the fly, the USB code, the RSA code, the networking code, the DateBase access code. But when I came to serial port code, I need coroutine just like I did it on gambit-c scheme. Although nobody reports that kilim can ever been ported to android, but I think it is just the proguard configuration thing

在 2017年11月17日星期五 UTC+8下午6:41:26,Dierk Koenig写道:
To unsubscribe from this group and stop receiving emails from it, send an email to frege-programming-language+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages