com.github.mperry.fg.ListMonadExtension.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
package com.github.mperry.fg
import com.github.mperry.fg.typeclass.concrete.ListApplicative
import com.github.mperry.fg.typeclass.concrete.ListFunctor
import com.github.mperry.fg.typeclass.concrete.ListMonad
import fj.F
import fj.F2
import fj.F3
import fj.Unit
import groovy.transform.TypeChecked
//import groovy.transform.TypeChecked
//import groovy.transform.TypeCheckingMode
/**
* Created by MarkPerry on 16/01/14.
*/
@TypeChecked
class ListMonadExtension {
static ListMonad monad() {
new ListMonad()
}
static List ap(List ma, List> mf) {
monad().ap(ma, mf)
}
static List to(List list, B b) {
monad().to(list, b)
}
static List skip(List list) {
monad().skip(list)
}
static List> traverse(List list, F> f) {
monad().traverse(list, f)
}
static List> replicateM(List list, Integer n) {
monad().replicateM(n, list)
}
static List liftM(List ma, F f) {
monad().liftM(ma, f)
}
static List liftM2(List ma, List mb, F2 f) {
monad().liftM2(ma, mb, f)
}
static List liftM3(List ma, List mb, List mc, F3 f) {
monad().liftM3(ma, mb, mc, f)
}
static List map2(List listA, List listB, F2 f) {
monad().map2(listA, listB, f)
}
// Applicative
static ListApplicative applicative() {
new ListApplicative()
}
static List apply(List list, List> listFs) {
applicative().apply(listFs, list)
}
static List liftA(List a1, F f) {
applicative().liftA(f, a1)
}
static List liftA2(List listAs, List listBs, F2 f) {
applicative().liftA2(f, listAs, listBs)
}
static List liftA3(List apa, List apb, List apc, F3 f) {
applicative().liftA3(f, apa, apb, apc)
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy