jonsterling/Foam — Issue #14: Traits
Author: jonsterling
Created: 2012-01-05 06:26:42+00:00
State: open

Traits are roughly analogous to protocols.

~~~~ruby
trait FMDogLoaderDelegate [
- dogLoader:obj didFinishLoadingDog:dog.
- dogLoaderDidCancel:obj.
].

# Traits can also provide concrete implementations of methods.
# To implement this, we can take a look at https://github.com/jspahrsummers/libextobjc.

trait Functor [
- map:{id(^)(id)}block.

- foreach:{void(^)(id)}block [
^ @map: [:x | block(x). ^x. ].
].
].

trait Monad [
- join.

- flatMap:{id(^)(id)}block [
^ @map: block | join.
].
].
~~~~