All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.mperry.fg.SetMonadExtension.groovy Maven / Gradle / Ivy

There is a newer version: 0.8
Show newest version
package com.github.mperry.fg

import com.github.mperry.fg.typeclass.concrete.ListApplicative
import com.github.mperry.fg.typeclass.concrete.ListMonad
import com.github.mperry.fg.typeclass.concrete.SetMonad
import fj.F
import fj.F2
import fj.F3
import fj.Unit
import groovy.transform.TypeChecked

/**
 * Created by MarkPerry on 13/04/2014.
 */
@TypeChecked
class SetMonadExtension {

    static SetMonad monad() {
        new SetMonad()
    }

    static  Set ap(Set ma, Set> mf) {
        monad().ap(ma, mf)
    }

    static  Set to(Set list, B b) {
        monad().to(list, b)
    }

    static  Set skip(Set list) {
        monad().skip(list)
    }

    static  Set> replicateM(Set list, Integer n) {
        monad().replicateM(n, list)
    }

    static  Set liftM(Set ma, F f) {
        monad().liftM(ma, f)
    }

    static  Set liftM2(Set ma, Set mb, F2 f) {
        monad().liftM2(ma, mb, f)
    }

    static  Set liftM3(Set ma, Set mb, Set mc, F3 f) {
        monad().liftM3(ma, mb, mc, f)
    }

    static  Set map2(Set listA, Set listB, F2 f) {
        monad().map2(listA, listB, f)
    }

    // Applicative

    static  Set apply(Set list, Set> listFs) {
        monad().apply(listFs, list)
    }

    static  Set liftA(Set a1, F f) {
        monad().liftA(f, a1)
    }

    static  Set liftA2(Set listAs, Set listBs, F2 f) {
        monad().liftA2(f, listAs, listBs)
    }

    static  Set liftA3(Set apa, Set apb, Set apc, F3 f) {
        monad().liftA3(f, apa, apb, apc)
    }

}