Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

110617 lt

491 views

Published on

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

  • Be the first to comment

  • Be the first to like this

110617 lt

  1. 1. MONAD ON GROOVY == MANADOLOGIE masaki@metabolics.co.jp 2011.06.17 1
  2. 2. monad? Haskell monoidcontinuation...... 2
  3. 3. monad! ( )Haskell Maybe Monad Groovy (2009/8/30, Gr ) 3
  4. 4. example 1 2 S = {2x|x ∈ N, x > 3} (comprehension)x 3 ,2 *x 4
  5. 5. groovy waydef s(n) { ((0..n) .findAll { it**2 > 3 }) .collect { it*2 }} Groovy , 5
  6. 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. 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. 8. monadologie https://github.com/dsrkoc/monadologie by Dinko Srkoc 8
  9. 9. what’s the pointmonadologie ?=> Collection , 9
  10. 10. interface Monad<M> { M unit(Object a) M bind(Closure f)} 10
  11. 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. 12. unit, bindbind(m, unit) == mbind(unit(m), f) == f(m) //bind(bind(m, f), g) == bind(m, { bind(f(it), g) }) // 12
  13. 13. Groovy ?=> List (Collection) , ( ) ... 13
  14. 14. Option - (e.g. null) Maybe Groovy safe reference “?.”Either -Reader - ClosureWriter -State -STM -memoize, ,AST 14
  15. 15. , ? ( ) ...:-) 15
  16. 16. LT 16

×