Skip to content

Instantly share code, notes, and snippets.

@sifue
Last active September 13, 2015 07:01
Show Gist options
  • Select an option

  • Save sifue/8a73b7f093b3171bf125 to your computer and use it in GitHub Desktop.

Select an option

Save sifue/8a73b7f093b3171bf125 to your computer and use it in GitHub Desktop.
DDDに役立つScalaの関数型プログラミング的機能 ref: http://qiita.com/sifue/items/8618eba5e48bd8063813
public interface User {
public LotResult lot();
public class Present {}
public interface LotResult {
public Present present();
}
public class Hit implements LotResult {
public Present present() { return new Present();}
}
public class Blank implements LotResult {
public Present present() { return null;}
}
}
trait User {
def lot:Option[Present]
}
class Present
trait Student {
def tryTest:Either[FailReason, Department]
}
trait BanExecutor {
def ban(user:User, administrator:Administrator): (BanedUser, BanMail)
}
interface Administrator {
public BanResult ban(user:User);
}
interface BanResult
val invitations:Seq[Invitaion] = visitors
.filter(_.signUped)
.filter(_.prefecture == "東京都")
.map(createInvitaion)
trait User {
def present(item:Item, targetUser:User): Unit = {
moveOwnership(buy(item), targetUser)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment