Live data from Hacker News

What programming languages are used late at night?

stackoverflow.blog

241–244 of 244 posts

Re: What programming languages are used late at night?

#241
post #238

Earlier quoted context omitted.

I made a more compact version closer to what I might write in a hurry. {-# LANGUAGE OverloadedStrings #-} module Main where import Prelude hiding (appendFile) import Data.Monoid (( )) import Network.Wreq import Control.Lens import Control.Concurrent.Async import Data.ByteString.Lazy (ByteString, appendFile) import Data.List main = do urls >= mapM_ (appendFile "output2.txt" . view responseBody) promptUserURLs :: IO [S…

Wow. Interesting. This is really cool, being able to learn like this :3 I must admit I have so many questions, like what the dot does, what fst and snd and >>= and OverloadedStrings and zip do... :) Oh, and what "snoc" means.

cons = prepend snoc = append fst = first item of tuple snd = second item of tuple

>>= is monadic bind... I won't try to explain it here. It's somewhat similiar to flatmap in Scala which has some easy explanations.

zip, I just remembered I explained already.

Re: What programming languages are used late at night?

#242
post #238

Earlier quoted context omitted.

Wow. Interesting. This is really cool, being able to learn like this :3 I must admit I have so many questions, like what the dot does, what fst and snd and >>= and OverloadedStrings and zip do... :) Oh, and what "snoc" means.

cons = prepend snoc = append fst = first item of tuple snd = second item of tuple >>= is monadic bind... I won't try to explain it here. It's somewhat similiar to flatmap in Scala which has some easy explanations. zip, I just remembered I explained already.

Ooooh. Thanks. :)

I definitely have no excuse, I need to go find a decent Haskell reference-tutorial-manual. Know of any good ones for people with no former experience with functional programming (and ADHD :P)? I'm aware of Learn You a Haskell, just wondered what your experiences were.

Re: What programming languages are used late at night?

#243
post #238

Earlier quoted context omitted.

I made a more compact version closer to what I might write in a hurry. {-# LANGUAGE OverloadedStrings #-} module Main where import Prelude hiding (appendFile) import Data.Monoid (( )) import Network.Wreq import Control.Lens import Control.Concurrent.Async import Data.ByteString.Lazy (ByteString, appendFile) import Data.List main = do urls >= mapM_ (appendFile "output2.txt" . view responseBody) promptUserURLs :: IO [S…

Wow. Interesting. This is really cool, being able to learn like this :3 I must admit I have so many questions, like what the dot does, what fst and snd and >>= and OverloadedStrings and zip do... :) Oh, and what "snoc" means.

OverloadedStrings is an extension that basically puts `fromString` in front of every string literal. This means that instead of having type `String`, string literals have type `IsString a => a` (meaning "for anything that implements `IsString`, this could be a that"). It's used here so that `"http:"` can be used as a `ByteString` without cluttering the code up with an explicit `fromString`.

Re: What programming languages are used late at night?

#244
post #236

Earlier quoted context omitted.

Eh, I had a mistake. {-# LANGUAGE OverloadedStrings #-} module Main where import Prelude hiding (appendFile) import Data.Monoid (( )) import Network.Wreq import Control.Lens import Control.Concurrent.Async import Data.ByteString.Lazy (ByteString, appendFile) main = do urls (take 5 url, body)) (zip urls responseBodys) httpUrls = fmap fst (filter (\(url,_) -> url == "http:") responseInfos) httpsResponses = fmap snd (fi…

Huh. So Haskell is the language of the missing apostrophe instead of the missing semicolon. (In all fairness, so is Lisp, but it puts the apostrophes on the other side.) I'm curious about "(zip urls response" though. Does that extend to the "responseInfos)" on the next line, or am I reading it wrong? (I noticed the "fmap fst" and "fmap snd".) Wonders where to start to figure out how this works

Hopefully the ticked version is a different type than the unticked version and would be caught by the typechecker. Failing that, hopefully the ticked version is now unused and will be caught by the linter. But yeah, this is definitely a thing that can happen.

If you're doing a lot of successive transformations of data of the same type, putting it in State will prevent you from messing up the ordering (or needing to come up with fresh names).

Post reply on HN