forked from dsyme/guido-learns-fsharp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
playground.fsx
57 lines (38 loc) · 1.38 KB
/
playground.fsx
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
(* PREPARATION
Before you start, it's worth knowing about the Elmish architecture
See the overview slide.
*)
// Task 5 - play with a new web service using F# scripting
// Task 5.1 -
// Problem: Learn to use the F# REPL
//
// Approach
// - Type 1+1
// - Select the code (keyboard or mouse)
// - Use "Alt-Enter" to execute in REPL
// Task 5.2
// Problem: we want to examine the REST service we would like to use
//
// Approach:
// Look at https://www.geonames.org/export/ws-overview.html
// Look at http://api.geonames.org/findNearbyWikipediaJSON?lat=52.3676&lng=4.9041&username=dsyme
// Task 5.3
// Problem: We need a package to use
//
// Look at https://nuget.org, search for FSharp.Data
// Copy the text to reference for scripting.
// Task 5.4 - Point the JsonProvider to the web service
//
// #r "nuget:FSharp.Data"
// open FSharp.Data
// type WikipediaIO = JsonProvider<"http://api.geonames.org/findNearbyWikipediaJSON?lat=52.3676&lng=4.9041&username=dsyme">
// Task 5.5 - Use the JsonProvider to download the data, the code is below
//
// let info =
// $"http://api.geonames.org/findNearbyWikipediaJSON?lat=52.3676&lng=4.9041&username=dsyme"
// |> WikipediaIO.AsyncLoad
// |> Async.RunSynchronously
// Task 5.6 - Extract the title, latitude, longitude and summary for each result
//
// A starting snippet is below
// [ for x in info.Geonames -> x.Title ]