swlaschin / fsharpforfunandprofit.com Goto Github PK
View Code? Open in Web Editor NEWSource for fsharpforfunandprofit.com. For typos, please send a PR or create an issue. Thanks!
Source for fsharpforfunandprofit.com. For typos, please send a PR or create an issue. Thanks!
Hey!
I'm getting redirected to GitBook main page when trying to download the ebook PDF (also end-up trying for ePub and Kindle and got the same problem).
Thanks for your time!
In the end of the post, last sentence: "In order to work with the Shape
type, a function needs to handle each case of the Shape, which it does with pattern matching."
<a href="conciseness-pattern-matching.html">pattern matching</a>
click, redirect to https://fsharpforfunandprofit.com/posts/key-concepts/conciseness-pattern-matching.html
, 404 Not Found
In the paragraph:
A hidden agenda, of course, is that once your fellow developers get a chance to play with F#, they’ll be hooked, and you’ll be one step closer to using F# end to end!
the link to https://colinbul.wordpress.com/2013/02/23/f-end-to-end/ is no longer available.
Hi,
Domain Modelling Made Functional Book
Just bought the book from amazon.co.uk. Could you please post the diagram that is meant to be on the top of page 18! The diagram that is in my copy ‘Book version: P1.0-January 2018’ has the same diagram on page 18 as is on page 17 i.e. the ‘Problem space (real world) - Solution space (domain world). I have looked around and can find no mention of this error or the correct diagram.
Best regards
Stephen
At the beginning of the post (https://fsharpforfunandprofit.com/posts/roman-numerals/):
Last time we looked at parsing a command line. This time we’ll we’ll look at another pattern matching example, this time using Roman numerals.
In "Choosing properties for property-based testing", it says a sorted list should be:
In fact, these two properties, adjacent pairs from a list should be ordered and a sorted list has same contents as the original list should indeed ensure that any implementation is correct.
This (as implemented in the article by checking the length and permutation-ness) is true of a list without duplicates, and the EDFH would have a hard time implementing such an algorithm, but this case passes the tests and is wrong:
sort [2; 2; 1; 3] -> [1; 1; 2; 3]
First, Thanks for your blog, it is changing my mind for programming... I've read it entirelly twice, and now I'm in the third reading...
I noticed that in the Reinventing the Reader monad, when I tried to run the sample code, I always got a failure from the executeApiAction func... I tried to run the code related to the api outside the result expression and it worked, so I thought that the problem should be in the builder... after some digging I noticed that the Zero value for the builder is Failure, and I noticed it gets binded to to the actual result in every for in loop... and as binding to a failure gives a failure, the result of the computation expression is always a failure....
as a work arround is to change the zero value to a Success (), but then the meaning of the zero would be wrong, because it should be starting from a failure.... I'm thinking about other possibilities.
The post "Comparing F# with C#: Sorting" has incorrectly rendered source code in Correctness section. The if statement and last curly bracket should be placed in new lines. Please look at the images below.
However it's rendered correctly, when I open this post at GitHub.
Checked at:
Internet Explorer version 11.1098.17763.0
Opera version 65.0.3467.56
Chrome version 80.0.3987.149
Thanks for all of your hard work in providing this great resource.
Just a small error in the 'Shell scripts in F#' section on the 'Installing and using F#' page.
The command given to run the shell script example is -
fsi ShellScriptExample.fsx http://google.com google_homepage
this should be -
dotnet fsi ShellScriptExample.fsx http://google.com google_homepage
Hi! I was just reading this page, and near the bottom the following is said:
F# has an interactive window where you can test the code immediately and play around with it. In C# there is no easy way to do this.
Just like how F# has an interactive REPL, C# has one too, which works just fine:
View -> Other Windows -> C# Interactive
Re #5, update the page to be more OO vs FP rather than C# vs F#
or does no one else in the world think that date and time of an article is important?
would this be more or less relevant if it was from 1897 or 2021? some maybe not, TECH probably relevant!
date and time at the TOP of every blog post webpage youtube or whatever for some date CONTEXT please, things move fast in this world, #datestampit, please.
Good time of the day!
It is not a serious issue, but the there's a wrong definition for lift2
function in the second part of the parser combinators tutorial:
let lift2 f xP yP =
returnP f <*> xP <*> yP
The type of lift2
is this:
val lift2 :
f:('a -> 'b -> 'c) -> Parser<'a> -> Parser<'b> -> Parser<'c>
f
is a normal function, i.e. not Parser<('a -> 'b -> 'c)>
. However, the type of <*>
is this:
val applyP :
Parser<('a -> 'b)> -> Parser<'a> -> Parser<'b>
The type of f
doesn't match...
I think the correct version should be this:
// correct definition:
let lift2 f xP yP =
returnP f <!> xP <*> yP // map instead of apply
I did this small test in OCaml, and the types seem to match in case of map:
val lift2 :
('a -> 'b -> 'c) ->
('d -> ('a * 'e) Result.t) ->
('e -> ('b * 'f) Result.t) -> 'd -> ('c * 'f) Result.t = <fun>
Hope this helps!
P.S. I am very much enjoying your tutorial! Thank you very much!
On the Installing and using page, i believe the link for http://www.tryfsharp.org/ should be updated to https://try.fsharp.org/.
Reference URL: https://fsharpforfunandprofit.com/installing-and-using/#browser
"F# has built in support for this model, as well as for the more traditional approach."
https://fsharpforfunandprofit.com/posts/let-use-do/
The code for testTimerWithDisposable won't compile with newer f# versions. I don't know f# sharp to fix it. This is the error I get:
"typecheck error One or more of the overloads of this method has curried arguments. Consider redesigning these members to take arguments in tupled form"
https://fsharpforfunandprofit.com/posts/discriminated-unions/#union-representation
At the end of the page it reads:
Union types have a nice default string representation, and can be serialized easily. But unlike tuples, the ToString() representation is unhelpful.
type Contact = Email of string | Phone of int
let email = Email "[email protected]"
printfn "%A" email // nice
printfn "%O" email // ugly!
But the console output is the same for both:
Email "[email protected]"
Email "[email protected]"
which is a contradiction to the initial statement (ToString() representation is unhelpful).
Cheers
The first computation expressions tutorial has some code snippets that use HttpWebRequest
from System.Net
in the "Asynchronous calls with callbacks" section.
open System.Net
let req1 = HttpWebRequest.Create("http://fsharp.org")
let req2 = HttpWebRequest.Create("http://google.com")
let req3 = HttpWebRequest.Create("http://bing.com")
req1.BeginGetResponse((fun r1 ->
use resp1 = req1.EndGetResponse(r1)
printfn "Downloaded %O" resp1.ResponseUri
req2.BeginGetResponse((fun r2 ->
use resp2 = req2.EndGetResponse(r2)
printfn "Downloaded %O" resp2.ResponseUri
req3.BeginGetResponse((fun r3 ->
use resp3 = req3.EndGetResponse(r3)
printfn "Downloaded %O" resp3.ResponseUri
),null) |> ignore
),null) |> ignore
),null) |> ignore
I get the following warning when running this.
warning FS0044: This construct is deprecated. WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.
Here's an alternative using HttpClient
open System.Net.Http
open System.Threading.Tasks
let url1 = "http://fsharp.org"
let url2 = "http://google.com"
let url3 = "http://bing.com"
let client = new HttpClient()
client.GetAsync(url1).ContinueWith(fun (task1 : Task<HttpResponseMessage>) ->
let result1: HttpResponseMessage = task1.Result
printfn "Heres the result: %A" result1
client.GetAsync(url2).ContinueWith(fun (task2 : Task<HttpResponseMessage>) ->
printfn "Heres the result: %A" task2.Result
client.GetAsync(url2).ContinueWith(fun (task3 : Task<HttpResponseMessage>) ->
printfn "Heres the result: %A" task3.Result
)
)
)
However, this isn't very didactic (have to explain what a Task
is, etc.) and it only runs if you load the file in an interactive fsi
session;
RunSynchronously
results in an exception.
In the post Understanding FsCheck, it was mentioned ints generated are not uniformly distributed but clustered around zero.
// see how the values are clustered around the center point
intGenerator
|> Gen.sample 30 10000
|> Seq.groupBy id
|> Seq.map (fun (k,v) -> (k,Seq.length v))
|> Seq.sortBy (fun (k,v) -> k)
|> Seq.toList
I believe it is no longer true since FsCheck 2.14.0 release. I verified that the results are now uniformly distributed by running the code snippet above.
I've tried to import the epub in Google Books, and it fails to validate it, therefore it cannot be imported.
I've ran the IDPF epub validator against it, and it reveals quite a lot of errors:
validation errors gist
Sorry for the lack of PR but just don't have the time to fork and everything at the moment.
On the page https://fsharpforfunandprofit.com/posts/concurrency-reactive/ in the Counting Events section, the requirement is presented as At each tick, print the number of ticks so far and the current time.
. The examples only print the tick count.
Hi Scott,
There is a broken link in the following section of fsharpforfunandprofit.
https://fsharpforfunandprofit.com/posts/concurrency-reactive/
the broken link is correspondind to the Observable module in the summary section.
I suggest to replace it with https://docs.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2010/ee370313(v=vs.100)?redirectedfrom=MSDN but microsfot indicates that is no longer update this content regularly.
Thanks for your wonderful content
I believe now it's easier to get up and running with VS Code and F# than ever before with .NET 5 (and next ones). There is no need for Mono anymore I believe, all what's really needed is .NET SDK, VS Code and Ionide. Easy to set up on both Windows and Linux, including WSL (I don't have Mac machine available, so I cannot tell but it should not be very different).
There are some links on that page which have expired / will expire. It also seems like F# PowerPack is no longer maintained / needed. Maybe the VS v2008 (obsolete?) part could be removed. Screenshots could be updated too. Or maybe the whole section for installation could be referenced to MS sites where all the install info can be found.
I would be happy to do the updates if you prefer and send for your review.
https://fsharpforfunandprofit.com/posts/dependencies/
The Line: "First, we want generally want to create code that is predictable and"
Hi -- the 3 links to your ROP videos are broken on page https://fsharpforfunandprofit.com/rop :
Thanks for providing this resource to the community!
I really enjoyed the series "Map and Bind and Apply, Oh my!", and each step clicked nicely, until I tried to make sense of this line in "Understanding traverse and sequence".
retn cons <*> (f head) <*> (mapOption f tail)
As a C# programmer, I fell in the trap of reading it automatically like this
return ( cons <*> (f head) <*> (mapOption f tail) )
And of course, no matter how many times I went back to read the apply
chapter, I could not get it.
I don't know (yet) if this is a valid F# syntax but if it was, that would be one way to make it harder to fall into this trap.
(retn cons) <*> (f head) <*> (mapOption f tail)
Or maybe an additional note could warn the unsuspecting C# programmer of the danger ahead.
Firstly, I would like to commend you on this book. I'm not writing in F# ( elixir and elm at the moment ) but your explanations address how to think about the problem vs how to write code. Thank you again for all of your insight.
I enjoyed your book so much that I would like to subscribe to your newsletter...but I receive this message.
Some links appear to be broken in Why Use F#: "Many common programming tasks are much simpler in F#. This includes things like creating and using [/posts/conciseness-type-definitions/](complex type definitions), doing list processing, [/posts/convenience-types/](comparison and equality), state machines, and much more."
This is a fantastic website btw!
Clicking subscribe on https://fsharpforfunandprofit.com/subscribe.html
Goes to https://fsharpforfunandprofit.us7.list-manage.com/subscribe/post?u=4da12e20f26ec7bac54728cb9&id=f0380695b6
Displaying:
"Failed to load resource: the server responded with a status of 404 ()" error displays in the console in developer tools.
Freebase was ended. Try to find replacement with type provider. Possible target is Wikidata.
Scott - Thanx for your great book which is helping an old C guy learn a new func language. Do you think you could upload all of your F# fs files into GitHub so that we can download them and open them in Visual Studio? It would be easier than copying and pasting from the eBook or PDF book.
Thanks
Tony D
On the page entitled "Choosing between collection functions" (https://fsharpforfunandprofit.com/posts/list-module-functions/), there is a link or two in this paragraph:
If you want to know what changed between F# v3 and F# v4, please see this chart (from here). The chart shows the new APIs in F# v4 (green), previously-existing APIs (blue), and intentional remaining gaps (white).
The link to the 404 is: https://learn.microsoft.com/en-us/archive/blogs/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-39-71-metablogapi/3125.collectionapi_5f00_254ea354
I appreciate fsharpforfunandprofit.com. It seems to be just what I need to get more up to speed in F#. And I hope this post is helpful in maintaining the website by calling attention to this issue.
Ron Lewis
Hello!
First and foremost, thanks a bunch for this website! I learnt quite a bit from it.
But, https://fsharpforfunandprofit.com/posts/dependency-injection-1/ seems to date from 2016, and I was wondering if a part 2 will ever see the light of day.
Also, not having new articles gives a feeling that F# is less active on that front.
Is there any plan for the future?
Hi Scott,
thank you so much for all your work and effort that you have put into this website. I find it especially awesome that you also provide an offline version of the page as ebook.
There is only one flaw to it, namely, it is fairly difficult to navigate for the following reason. The table of contents only includes section numbers but not page numbers. The content itself, however, does not include the section numbers at all, but only the page number.
Could you please extend your ebook generator in such a way that:
I would be ever so grateful for that.
Once again, thank you for everything and keep up the good work!
I was following this site and when at this page I've found this problem,
There is a union type of Address which consists of three other types.
type Address = USAddress | UKAddress | InternationalAddress
The problem is compiler does not understand that these three are itself another type and thus I can not assign a UkAddress variable in an Address variable.
For now, I've found a workaround for this. which is like that,
type Address = UsAddress of USAddress | UkAddress of UKAddress | InternationalAddress of InternationalAddress
Also, I think if there is a Customer variable with some dummy data then it would be much more understandable.
Hello,
First of all, thanks for the excellent content.
The msdn links for the fold and fold back documentation are broken for this page.
First broken link:
Text: If we compare the signature with the List.fold documentation we ....
Correct link (suggestion):
https://fsharp.github.io/fsharp-core-docs/reference/fsharp-collections-listmodule.html#fold
Secondbroken link:
Text: Again, if we compare the signature with the List.foldBack documentation ....
Correct link (suggestion):
https://fsharp.github.io/fsharp-core-docs/reference/fsharp-collections-listmodule.html#foldBack
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.