This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type StreamCons<'a> = | |
| | Nil | |
| | Cons of 'a * Stream<'a> | |
| and Stream<'a> = Lazy<StreamCons<'a>> | |
| let inline force (l: Lazy<_>) = l.Force() | |
| let rec toStream l : Stream<_> = | |
| lazy match l with | |
| | [] -> Nil |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #r @"C:\Users\User\.nuget\packages\fsharp.compiler.service\25.0.1\lib\net45\FSharp.Compiler.Service.dll" | |
| open System.Text | |
| open Microsoft.FSharp.Compiler.Ast | |
| open Microsoft.FSharp.Compiler.Range | |
| open Microsoft.FSharp.Compiler.SourceCodeServices | |
| //PARSING | |
| let parse text = |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #r @"C:\Users\ayrat.hudaygulov\.nuget\packages\fsharp.compiler.service\26.0.1\lib\net45\FSharp.Compiler.Service.dll" | |
| open System.IO | |
| open Microsoft.FSharp.Compiler.Ast | |
| open Microsoft.FSharp.Compiler.SourceCodeServices | |
| let parse text = | |
| let fileName = "whatever.fs" | |
| let checker = FSharpChecker.Create() | |
| let opts = |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function CleanupRepo { | |
| param([string]$repo) | |
| <#work directory should be repo root#> | |
| cd $repo | |
| git fetch "origin" | |
| git reset --hard origin/master | |
| "getting branch list..." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| interface IJsonFormatter<byte[]> with | |
| member __.Serialize(writer, value, formatterResolver) = | |
| if value = null then writer.WriteNull() | |
| else | |
| writer.WriteRaw value | |
| //This is very convoluted way of escaping non-escaped strings from verbatim UTF8 string as byte array | |
| member __.Deserialize(reader, formatterResolver) = | |
| if reader.ReadIsNull() then null else |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function CleanupTags { | |
| param([string]$repo) | |
| <#work directory should be repo root#> | |
| cd $repo | |
| git fetch "origin" | |
| git reset --hard origin/master | |
| "getting tags list..." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| open BenchmarkDotNet.Attributes | |
| open BenchmarkDotNet.Running | |
| open Hopac | |
| [<SimpleJob(launchCount = 3, warmupCount = 3, targetCount = 5)>] | |
| [<GcServer(true)>] | |
| [<MemoryDiagnoser>] | |
| type Benchs() = | |
| [<Benchmark>] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // not inlined GENERIC function | |
| let bar x = printfn "%A" x | |
| // CASE 1. Usual function. impossible now and that's OK | |
| let foo (f: 'a -> unit) = // 'a is inferred as string | |
| f "" // warning here. generic is not generic! | |
| f 1 // compile error | |
| //calling site before inline | |
| foo bar | |
| //calling site after inline |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| open System.Text | |
| open Microsoft.FSharp.Reflection | |
| let printDu du = | |
| let rec inner (builder: StringBuilder, duValue: obj, duType: Type) = | |
| if not (FSharpType.IsUnion duType) then failwith "FU!" | |
| let case, values = FSharpValue.GetUnionFields(duValue, duType) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type ThirdLevel = | |
| | Payload of int | |
| and SecondLevel = | |
| | Nested of ThirdLevel list | |
| | Payload of string | |
| and FirstLevel = | |
| | Nested of SecondLevel list | |
| | Payload of double | |
| | EmptyLine | |
| and AllBuilder() = |