Zaid-Ajaj / Fable.Remoting

Type-safe communication layer (RPC-style) for F# featuring Fable and .NET Apps
https://zaid-ajaj.github.io/Fable.Remoting/
MIT License
273 stars 55 forks source link

Typo in readme #94

Closed NOBLES5E closed 6 years ago

NOBLES5E commented 6 years ago

It seems that in the readme, the following example code has an extra ()

open SharedTypes

let getStudents() = async {
    return [
        { Name = "Mike";  Age = 23; }
        { Name = "John";  Age = 22; }
        { Name = "Diana"; Age = 22; }
    ]
}

let findStudentByName name = async {
    let! students = getStudents() 
    let student = List.tryFind (fun student -> student.Name = name) students
    return student 
}

let studentApi : IStudentApi = {
    studentByName = findStudentByName
    allStudents = getStudents()  // shouldn't have () here
}
Zaid-Ajaj commented 6 years ago

Hello @ikzk, thanks for checking the readme, but this is not a typo, the record field allStudents has type Async<Student list>, so I need to evaluate getStudents when constructing the record field

If allStudents had the type unit -> Async<Student list> then I wouldn't need to use () but that is not the case here, see for yourself that this actually compiles in this dotnet fiddle sample

NOBLES5E commented 6 years ago

Gotcha. Thanks for your comments!