Uploaded on

例によって時間が押してできなかったLightning Talksのネタを上げておきます. ま, 誰でも知っているようなつまらないネタですけど...

例によって時間が押してできなかったLightning Talksのネタを上げておきます. ま, 誰でも知っているようなつまらないネタですけど...

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
318
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
0
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. MONAD ON GROOVY == MANADOLOGIE masaki@metabolics.co.jp 2011.06.17 1
  • 2. monad? Haskell monoidcontinuation...... 2
  • 3. monad! ( )Haskell Maybe Monad Groovy (2009/8/30, Gr ) 3
  • 4. example 1 2 S = {2x|x ∈ N, x > 3} (comprehension)x 3 ,2 *x 4
  • 5. groovy waydef s(n) { ((0..n) .findAll { it**2 > 3 }) .collect { it*2 }} Groovy , 5
  • 6. example 2import static hr.helix.monadologie.MonadComprehension.foreachdef s(n) {   foreach {       x = takeFrom { 0..n }       guard { x**2 > 3 }       yield { 2*x }   }} 6
  • 7. example 3def pythags(n) {   foreach {       z = takeFrom { 1..n }       x = takeFrom { 1..z }       y = takeFrom { x..z }       guard { x**2 + y**2 == z**2 }       yield { [x, y, z] }   }}assert pythags(12) == [[3, 4, 5], [6, 8, 10]] 7
  • 8. monadologie https://github.com/dsrkoc/monadologie by Dinko Srkoc 8
  • 9. what’s the pointmonadologie ?=> Collection , 9
  • 10. interface Monad<M> { M unit(Object a) M bind(Closure f)} 10
  • 11. List (!) (List<X> X )List<X> (X a) = { [a] } //List<Y> (List<X> m, f) = { m.inject([]) { r, e -> r + f(e) } } // // where f s.t. List<Y> f(X x) // f apply [] 11
  • 12. unit, bindbind(m, unit) == mbind(unit(m), f) == f(m) //bind(bind(m, f), g) == bind(m, { bind(f(it), g) }) // 12
  • 13. Groovy ?=> List (Collection) , ( ) ... 13
  • 14. Option - (e.g. null) Maybe Groovy safe reference “?.”Either -Reader - ClosureWriter -State -STM -memoize, ,AST 14
  • 15. , ? ( ) ...:-) 15
  • 16. LT 16