<commit_before>﻿namespace FsControl

open System.Runtime.CompilerServices
open System.Runtime.InteropServices
open FsControl.Internals
open FsControl.Internals.Prelude
open FsControl.Internals.MonadOps
open FSharpPlus


type Traverse =
    inherit Default1
    static member inline Traverse (t:^a   , f, [<Optional>]_output:'R, [<Optional>]_impl:Default3) =  Map.Invoke f ((^a) : (static member SequenceA: _ -> 'R) t)
    static member inline Traverse (t:^a   , f, [<Optional>]_output:'R, [<Optional>]_impl:Default2) =  ((^a) : (static member Traverse: _*_ -> 'R) t, f)
    static member inline Traverse (t:Id<_>, f, [<Optional>]_output:'R, [<Optional>]_impl:Default1) = Map.Invoke Id.create (f (Id.run t))
    static member inline Traverse (t:_ seq, f, [<Optional>]_output:'R, [<Optional>]_impl:Default1) = 
       let cons x y = seq {yield x; yield! y}
       let cons_f x ys = Map.Invoke (cons:'a->seq<_>->seq<_>) (f x) <*> ys
       Seq.foldBack cons_f t (result (Seq.empty))

    static member Traverse (t:'t seq ,f:'t->'u option , [<Optional>]_output:option<seq<'t>>, [<Optional>]_impl:Traverse) =
       let ok = ref true
       let res = Seq.toArray (seq {
           use e = t.GetEnumerator()
           while (e.MoveNext() && ok.Value) do
               match f e.Current with
               | Some v -> yield v
               | None   -> ok.Value <- false})
       if ok.Value then Some (Array.toSeq res) else None

    static member        Traverse (t:'t seq   ,f:'t->Async<'u> , [<Optional>]_output:Async<seq<'u>>, [<Optional>]_impl:Traverse) :Async<seq<_>> = result <| Seq.map (Async.RunSynchronously) (Seq.map f t)
    static member        Traverse (t:Id<'t>   ,f:'t->option<'u>, [<Optional>]_output:option<Id<'u>>, [<Optional>]_impl:Traverse) = Option.map Id.create (f (Id.run t))
    static member inline Traverse (t:option<_>,f , [<Optional>]_output:'R, [<Optional>]_impl:Traverse) :'R = match t with Some x -> Map.Invoke Some (f x) | _ -> result None        <commit_msg>Fix bug in traverse that started showing in F# 4.1 This line: traverse id (seq [Some 1; Some 2]) was not compiling in F# 4.1 but although the signature was incorrect it worked until F# 4.0<commit_after>﻿namespace FsControl

open System.Runtime.CompilerServices
open System.Runtime.InteropServices
open FsControl.Internals
open FsControl.Internals.Prelude
open FsControl.Internals.MonadOps
open FSharpPlus


type Traverse =
    inherit Default1
    static member inline Traverse (t:^a   , f, [<Optional>]_output:'R, [<Optional>]_impl:Default3) =  Map.Invoke f ((^a) : (static member SequenceA: _ -> 'R) t)
    static member inline Traverse (t:^a   , f, [<Optional>]_output:'R, [<Optional>]_impl:Default2) =  ((^a) : (static member Traverse: _*_ -> 'R) t, f)
    static member inline Traverse (t:Id<_>, f, [<Optional>]_output:'R, [<Optional>]_impl:Default1) = Map.Invoke Id.create (f (Id.run t))
    static member inline Traverse (t:_ seq, f, [<Optional>]_output:'R, [<Optional>]_impl:Default1) = 
       let cons x y = seq {yield x; yield! y}
       let cons_f x ys = Map.Invoke (cons:'a->seq<_>->seq<_>) (f x) <*> ys
       Seq.foldBack cons_f t (result (Seq.empty))

    static member Traverse (t:'t seq ,f:'t->'u option , [<Optional>]_output:option<seq<'u>>, [<Optional>]_impl:Traverse) =
       let ok = ref true
       let res = Seq.toArray (seq {
           use e = t.GetEnumerator()
           while (e.MoveNext() && ok.Value) do
               match f e.Current with
               | Some v -> yield v
               | None   -> ok.Value <- false})
       if ok.Value then Some (Array.toSeq res) else None

    static member        Traverse (t:'t seq   ,f:'t->Async<'u> , [<Optional>]_output:Async<seq<'u>>, [<Optional>]_impl:Traverse) :Async<seq<_>> = result <| Seq.map (Async.RunSynchronously) (Seq.map f t)
    static member        Traverse (t:Id<'t>   ,f:'t->option<'u>, [<Optional>]_output:option<Id<'u>>, [<Optional>]_impl:Traverse) = Option.map Id.create (f (Id.run t))
    static member inline Traverse (t:option<_>,f , [<Optional>]_output:'R, [<Optional>]_impl:Traverse) :'R = match t with Some x -> Map.Invoke Some (f x) | _ -> result None        
{'fraction_non_alphanumeric': 0.16084758006260536, 'fraction_numerical': 0.004334216229231881, 'mean_word_length': 3.4427807486631017, 'pattern_counts': {'":': 0, '<': 71, '<?xml version=': 0, '>': 89, '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': '2859941', 'n_tokens_mistral': 1476, 'n_tokens_neox': 1395, 'n_words': 401}