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

com.github.mperry.fg.StateIntMonad.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.Monad
import fj.F
import fj.P
import groovy.transform.Canonical
import groovy.transform.TypeChecked
import groovy.transform.TypeCheckingMode

/**
 * Created by MarkPerry on 9/01/14.
 */
@TypeChecked
@Canonical
class StateIntMonad extends Monad {

    @Override
    @TypeChecked(TypeCheckingMode.SKIP)
    def  StateInt flatMap(StateInt mb, F> f) {
        mb.flatMap(f)
    }

    @Override
    @TypeChecked(TypeCheckingMode.SKIP)
    def  StateInt unit(B b) {
        new StateInt({ Integer s -> P.p(b, s) } as F)
    }

}