Exercise 6.2

You Could Have Invented Monads! (And Maybe You Already Have.)

f :: a -> b
f' :: a -> m a
unit :: a -> m a

f' * g' = (bind f') . (bind g')

bind f xs = concat (map f xs)

bind unit xs = concat (map unit xs)

unit x = [x]

bind unit xs
= concat (map unit xs)
= concat (map unit [x1, x2, ...])
= concat [unit x1, unit x2, ...]
= concat [[x1], [x2], ...]
= [x1, x2, ...]
= xs

f' = lift f

lift f = unit . f

unit (or return) can directly act on an ordinary value only, but not on a monadic value. To act on a monadic value, you need to bind it.

How come we do not need to lift return?

f :: a -> b

liftM :: Monad m => (a -> b) -> m a -> m b

return :: a -> m a

(liftM f) :: m a -> m b

(>>=) :: Monad m => m a -> (a -> m b) -> m b

lifeM cannot be applied to return at all.

unit (or return) is neither a pure function nor a monadic function. Instead, it is an half-monadic function, meaning that while its input is an ordinary value, its output is a monadic value.

(bind return xs) -> ys

(bind return) applies to xs.

return applies to x.

liftM is merely fmap implemented with (>>=) and return

— Wikibooks on Haskell/Understanding monads
 

— Me@2016-01-26 03:05:50 PM

2016.01.30 Saturday (c) All rights reserved by ACHK

More College Advice – GPA

I know this has been discussed before here, but I find Joel’s comments about having a high GPA questionable. I’ve never paid much attention to GPA scores when hiring, except to wonder why some candidates with mediocre GPAs in the 3.0 – 3.3 range brag them up. If anything, I’m interested in people who have quirky grades all over the map due to taking strange, challenging, and diverse courses.

It’s hard for me to believe that people in hiring positions really care much about high GPAs, unless they themselves have high GPAs (ignoring HR drone filters). If so, that’s already a minority. Even in this group, though, especially those with very high GPAs, my experience has been that its not really a factor.

At best, it’s a slight positive in the general hiring world, and can actually count against one when seeking employment, as in Bs don’t hire As. I tend toward very high GPAs myself (3.9 in my just completed graduate work, albeit it’s business strategy).

So I’m curious, does anyone here agree with Joel on this to the extent that the GPA counts (or would count) as important if you were hiring someone? Are you a high GPA yourself? I’m curious if there’s a correlation between high GPA and this attitude.

— Mongo

— Monday, January 03, 2005

You know the old saying, “The world is run by C students”[.]

— ted knight

— Monday, January 03, 2005

From my experience from college (and this is just my experience, so don’t flame me), the people with high GPAs were generally hard working and responsible, while the people with low GPAs were either slackers, people that made excuses (“oh, I had sooo much work to do”) or just not good enough to get high grades. I wouldn’t really want to hire most of the people I knew with poor GPAs. Some were very good, but I wouldn’t trust them to do be responsible and do their job even when things got boring.

I got a 3.91 from a top 10 CS program, and that helped tremendously when I was looking for jobs and internships. Companies were contacting me and asking me to apply, I didn’t have to seek them out. A friend of mine who graduated at the same time as me, from the same program, just found a job recently almost two years after graduating. He said a lot of companies wouldn’t even look at him because of his low GPA.

Other friends decided they couldn’t find a good job, so they’re going to grad school. Well, big surprise, they can’t get into a good grad school either with their low GPAs.

So yeah, I think it matters a great deal. One thing I noticed was that the people that had to pay for college themselves and had to work through college (like me) took it more seriously and got better grades, while those whose parents paid for it oftentimes didn’t care too much, took way too long to graduate, etc.

— sloop

— Monday, January 03, 2005

— The Joel on Software Discussion Group (CLOSED)

2016.01.19 Tuesday ACHK

注定外傳 2.3

Can it be Otherwise? 2.3

如果沒有明確指出,那個『必然』,是相對於哪個『觀測準確度』(觀察者解像度)而言的話,問一件事是不是『必然』,是沒有意思的,因為,無論那一件事,是在過去還是未來,往往既可以解釋成『必然』,又可以解釋為『非必然』。

除此之外,剛才亦提到:

對於過去的事,例如,在剛才甲和乙『這次數學考試我不合格,是不是必然』的討論中,當一方說那件事是『必然』時,另一方可以立刻,走深一個層次, 到達下一個『觀測解像度』,把同一件事,說成是『偶然』的;然後,原方又可以再走到,再下一個層次,把那事說成是『必然』的;如此類推。

對於未來之事,都有類似的情形,例如:

甲:明早我可以選擇七時起床,亦可以選擇不七時起床。那就證明,我有自由。

乙:不一定。你沒有那樣的自由。例如,如果你之前一晚,深夜兩時才睡,你可以肯定,你想七時起床也起不來。

甲:我可以選擇,之前一晚早一點睡。所以,我還是有自由。

乙:未必。假設你有要事,例如,明早有畢業論文要交,但尚未完成;那樣,你也沒有自由,去選擇早一點睡。

甲:但是,在再早一點之前,我可以選擇,早一點開始寫論文,早一點完成。那就可以避免,趕工夜睡的情況。

然後,乙又可以指出,甲並不是想早一點開始寫論文,就一定可以早一點,因為,甲會受到其他事務的牽制;如此類推。

這是一個沒有意義的討論,因為沒有止境,不會有結論。

每當甲指出,做某一件事(事件一)有自由、有選擇時,乙總可以質疑,那件事會,受制於之前的事件,例如事件二。然後,甲再指出,之前的事(事件二)本身,其實甲有某程度上的自由,所以,間接來說,甲對事件一,都有選擇。但是,乙又可以再質疑,事件二都會,受再之前的事件(事件三)的影響,其實事件二,也不算是自由的。

因為沒有指定,追溯到哪一件事,或者哪一刻為止,所以討論會沒完沒了。

— Me@2016-01-06 03:17:54 PM

2016.01.06 Wednesday (c) All rights reserved by ACHK