Fun with Types

Fun with Types

Talk given at The Developers Conference in Sao Paulo, 2014 in the Scala track

22cac40ebe7d9e1e7854ea9808debd7b?s=128

Breno Ferreira

August 08, 2014
Tweet

Transcript

  1. 3.

    FOR EXAMPLE d e f d i v ( x

    : I n t , y : I n t ) = x / y
  2. 10.

    FOR EXAMPLE: v a l s j o b s

    : ( ) = > S t r i n g s j o b s ( ) / / : " A p p l e I " s j o b s ( ) / / : " A p p l e I I " s j o b s ( ) / / : " M a c i n t o s h ! " s j o b s ( ) / / : " ✗"
  3. 12.

    FOR EXAMPLE: v a l s j o b s

    : ( ) = > S t r i n g s j o b s ( ) / / : " i P h o n e " s j o b s ( ) / / : " i P a d " s j o b s ( ) / / : " i C l o u d " s j o b s ( ) / / : " ✝"
  4. 13.
  5. 14.

    WHAT ABOUT A GETTER OF GETTERS? ( ) = >

    ( ) = > T r y [ O p t i o n [ T ] ]
  6. 15.

    EXTRACT TO INTERFACE t r a i t I t

    e r a b l e [ T ] { g e t I t e r a t o r : I t e r a t o r [ T ] } t r a i t I t e r a t o r [ T ] { h a s N e x t : B o o l e a n n e x t : T }
  7. 18.

    ASYNC GETTER ( ( T r y [ T ]

    ) = > ( ) ) = > ( )
  8. 19.

    BASICALLY, A FUTURE t r a i t F u

    t u r e [ T ] { o n S u c c e s s : T = > ( ) o n F a i l u r e : E x c e p t i o n = > ( ) }
  9. 21.

    EASY: ( ( T r y [ I t e

    r a b l e [ T ] ] ) = > ( ) ) = > ( )
  10. 22.

    BETTER: ( ( T r y [ O p t

    i o n [ T ] ] ) = > ( ) ) = > ( )
  11. 23.

    OBSERVABLE/OBSERVER t r a i t O b s e

    r v a b l e [ T ] { s u b s c r i b e ( o b s e r v e r : O b s e r v e r [ T ] ) } t r a i t O b s e r v e r [ T ] { o n N e x t ( v a l u e : T ) o n E r r o r ( e r r o r : E x c e p t i o n ) o n C o m p l e t e d ( ) }
  12. 24.

    FOUR BASIC EFFECTS IN COMPUTING: One Many Sync T /

    Option[T] Iterable[T] Async Future[T] Observable[T]
  13. 25.
  14. 26.

    Q&A