Re:Show HN: I built a poker site with Haskell
by platz on Friday August 09, 2019 @01:14PM
(#20656330)
i like it, for some reason my brain dislikes switching from left/right a lot, so that's why i often avoid the $ operator, so instead I'd write:
[ Parent
| on HN ]
Re:Show HN: I built a poker site with Haskell
by dllthomas on Friday August 09, 2019 @06:57PM
(#20658878)
"Have the data flow in one direction" is a good rule of thumb in writing clear Haskell code.
That said, your conversion away from $ changes the meaning here (in a way that doesn't typecheck, I think - remember that regular function application binds tightest whereas dollar binds loosest) and you still don't achieve your goal.
Instead, maybe
return . fromMaybe defaultPort $ readMaybe =<< maybeEnvPort
or even return $ fromMaybe defaultPort $ readMaybe =<< maybeEnvPort
If you still don't like the dollar signs, we can parenthesize instead in two correct ways, although I don't find them more readable: (return . fromMaybe defaultPort) (readMaybe =<< maybeEnvPort)
return (fromMaybe defaultPort (readMaybe =<< maybeEnvPort))