<commit_before>﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace ZedSharp
{
    public static class IO
    {
        public static IO<A> Of<A>(A val)
        {
            return new IO<A>(() => val);
        }

        public static IO<A> Of<A>(Func<A> cont)
        {
            return new IO<A>(cont);
        }

        public static IO<Unit> Of_(Action cont)
        {
            return new IO<Unit>(Z.UnitF(cont));
        }

        public static IO<A> Flatten<A>(this IO<IO<A>> io)
        {
            return IO.Of(io.Eval().Cont);
        }

        public static IO<A> Sum<A>(this IEnumerable<IO<A>> seq)
        {
            return seq.Aggregate((x, y) => x.Then(y));
        }

        public static IO<IEnumerable<A>> Sequence<A>(this IEnumerable<IO<A>> seq)
        {
            return IO.Of(() => seq.Select(x => x.Eval()));
        }

        public static Func<A, IO<C>> Compose<A, B, C>(this Func<A, IO<B>> f, Func<B, IO<C>> g)
        {
            return a => f(a).SelectMany(g);
        }
    }

    public struct IO<A><commit_msg>Added Fix : (a -> IO a) -> a<commit_after>﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace ZedSharp
{
    public static class IO
    {
        public static IO<A> Of<A>(A val)
        {
            return new IO<A>(() => val);
        }

        public static IO<A> Of<A>(Func<A> cont)
        {
            return new IO<A>(cont);
        }

        public static IO<Unit> Of_(Action cont)
        {
            return new IO<Unit>(Z.UnitF(cont));
        }

        public static IO<A> Flatten<A>(this IO<IO<A>> io)
        {
            return IO.Of(io.Eval().Cont);
        }

        public static IO<A> Sum<A>(this IEnumerable<IO<A>> seq)
        {
            return seq.Aggregate((x, y) => x.Then(y));
        }

        public static IO<IEnumerable<A>> Sequence<A>(this IEnumerable<IO<A>> seq)
        {
            return IO.Of(() => seq.Select(x => x.Eval()));
        }

        public static Func<A, IO<C>> Compose<A, B, C>(this Func<A, IO<B>> f, Func<B, IO<C>> g)
        {
            return a => f(a).SelectMany(g);
        }

        public static IO<A> Fix<A>(this Func<A, IO<A>> f)
        {
            return f(Fix(f).Eval());
        }
    }

    public struct IO<A>
{'fraction_non_alphanumeric': 0.15647712697734073, 'fraction_numerical': 0.0, 'mean_word_length': 1.740046838407494, 'pattern_counts': {'":': 0, '<': 67, '<?xml version=': 0, '>': 79, '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': '3164623', 'n_tokens_mistral': 796, 'n_tokens_neox': 780, 'n_words': 185}