-
Notifications
You must be signed in to change notification settings - Fork 0
/
Resources.fs
31 lines (26 loc) · 881 Bytes
/
Resources.fs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
module BlindfoldChessTraining.Resources
open FSharp.Data
open FSharpx.Collections
open Microsoft.Maui.Storage
open System.IO
open Types
let puzzleLines resourceName =
async {
let! stream = FileSystem.OpenAppPackageFileAsync(resourceName) |> Async.AwaitTask
let reader = new StreamReader(stream)
return reader.ReadToEnd().Split()
}
|> Async.RunSynchronously
|> LazyList.ofSeq
|> LazyList.filter (fun s -> s.Trim() <> "")
let endgamePuzzleLines () = puzzleLines "endgame_puzzles.jsonl"
let openingPuzzleLines () = puzzleLines "opening_puzzles.jsonl"
let sponsorDetails () =
let url =
"https://mrdimosthenis.github.io/BlindfoldChessTraining/sponsor.json"
try
Http.RequestString(url, timeout = 3000)
|> Newtonsoft.Json.JsonConvert.DeserializeObject<Sponsor>
|> Some
with _ ->
None