
com.github.mperry.fg.IdentityM.groovy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of functionalgroovy-main Show documentation
Show all versions of functionalgroovy-main Show documentation
FunctionalGroovy enhances FunctionalJava for Groovy
The newest version!
package com.github.mperry.fg
import com.github.mperry.fg.typeclass.Monad
import fj.F
import fj.Unit
import groovy.transform.Canonical
import groovy.transform.TypeChecked
/**
* Created by MarkPerry on 9/01/14.
*/
@TypeChecked
@Canonical
class IdentityM extends Monad {
A item
private IdentityM(A a) {
item = a
}
static IdentityM idUnit() {
lift(Unit.unit())
}
static IdentityM lift(B b) {
new IdentityM(b)
}
@Override
def IdentityM flatMap(IdentityM mb, F> f) {
f.f(mb.item)
}
@Override
def IdentityM unit(B b) {
lift(b)
}
def IdentityM flatMap(F> f) {
flatMap(this, f)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy