<commit_before>package async

import (
	"reflect"
)

type deffered struct {
	ret  []reflect.Value
	done bool
	wait chan bool
}

func Deffered(f interface{}) *deffered {
	def := &deffered{nil, false, make(chan bool)}
	go func() {
		ff := reflect.ValueOf(f)
		def.ret = ff.Call(nil)
		def.done = true
		close(def.wait)
	}()
	return def
}

func (def *deffered) IsDone() bool {
	return def.done
}<commit_msg>added monadic binding<commit_after>package async

import (
	"reflect"
)

type deffered struct {
	ret  []reflect.Value
	done bool
	wait chan bool
}

func Deffered(f interface{}) *deffered {
	def := &deffered{nil, false, make(chan bool)}
	go func() {
		ffun := reflect.ValueOf(f)
		def.ret = ffun.Call(nil)
		def.done = true
		close(def.wait)
	}()
	return def
}

func Init(v ...interface{}) *deffered {
	def := &deffered{make([]reflect.Value, len(v)), true, make(chan bool)}
	for i := range v {
		def.ret[i] = reflect.ValueOf(v[i])
	}
	close(def.wait)
	return def
}

func (def *deffered) IsDone() bool {
	return def.done
}

func (def *deffered) Bind(f interface{}) *deffered {
	newdef := &deffered{nil, false, make(chan bool)}
	go func() {
		for _ = range def.wait {
		}

		ffun := reflect.ValueOf(f)
		ftyp := reflect.TypeOf(f)
		newdef.ret = ffun.Call(def.ret[0:ftyp.NumIn()])
		newdef.done = true
		close(newdef.wait)
	}()
	return newdef
}
{'fraction_non_alphanumeric': 0.15848214285714285, 'fraction_numerical': 0.000744047619047619, 'mean_word_length': 3.8207885304659497, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3028176', 'n_tokens_mistral': 562, 'n_tokens_neox': 524, 'n_words': 130}