« first day (50 days earlier)      last day (330 days later) » 

12:11 AM
Could anyone recommend newbie level Monomorphism restriction explanation? I'm trying to understand haskellwiki article but it seems as i'm lacking some common type inference knowledge.
 
@maksenov You can find a few by searching for "monomorphism" here on SO, as we get questions about it every so often. I found one that looks promising, take a look:
26
A: Why do 3 and x (which was assigned 3) have different inferred types in Haskell?

pigworkerThere's another factor here, mentioned in some of the links which acfoltzer includes, but it might be worth making explicit here. You're encountering the effect of the monomorphism restriction. When you say let x = 5 you make a top-level definition of a variable. The MR insists that such defin...

Other than that, here's an attempt to sum it up briefly:

1. Polymorphic values are actually functions
2. Functions are recalculated each time, while values are shared
3. Therefore, if you _think_ you have a value, but you actually have a function, that might be the source of hidden performance problems
4. Therefore, we force things that _look_ like values, i.e. `x =` to be non-polymorphic (i.e. monomorphic), unless they have a type signature.
5. In the process of doing this, we might have to pick defaults for some types. Usually this will be Integer, or Double, which ever one fits.
6. If we couldn't find a sensible default, it's a compile error, usually of the form "Ambiguous constraint for ..."
Also, GHC can warn you when this rule is applied if you give it the option -fwarn-monomorphism-restriction.
 
12:52 AM
@hammar Thanks, @hammar. I tried to find something relevant but MR questions aren't the easiest thing to find.
@hammar It seems more or less clear to me now. I wonder why isn't such clear and simple explanation included in RWH.
 
@MatveyBAksenov > We won't attempt to explain the monomorphism restriction[14]. The consensus within the Haskell community is that it doesn't arise often; it is tricky to explain; it provides almost no practical benefit; and so it mostly serves to trip people up.
That's the explanation for the lack of explanation given in RWH.
I find it's easier to understand, once you understand the reason it exists.
But anyway, RWH could really use an update. I know one of the authors was thinking about it a few months back, but I'm not sure what the status is.
 
 
21 hours later…
10:05 PM
Anybody here?
 
10:34 PM
Often I come across code that Looks like this:
fun = ... go
` where go =`
Is there something special about the name "go" or is that just some kind of convention for functions defined after a where clause that you can't thing of a name for?
**think
 
10:52 PM
@ExternalReality There's a really good answer to question of 'go' convention here: stackoverflow.com/q/5844653/331473 (Not sure if you've read it yet or not)
 
11:21 PM
very simple question: I want to count the number of items r coming in here: r <- recv socket 1024 , that is ping responses sent by a server, how do I do this easiest?
 
11:56 PM
@JFritsch Strictly speaking, that number is equivalent to the number of times you run that statement. Having looked at your code some more, I'm guessing you would rather like to either have a cumulative count of how many you've received at a certain time, or you'll want to add some sort of timeout and count how many was received before that time.
 

« first day (50 days earlier)      last day (330 days later) »