https://github.com/nichoth/functional-friday
Learning about haskell
https://github.com/nichoth/functional-friday
Last synced: 10 months ago
JSON representation
Learning about haskell
- Host: GitHub
- URL: https://github.com/nichoth/functional-friday
- Owner: nichoth
- Created: 2017-08-21T04:40:45.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-08-22T03:53:41.000Z (almost 9 years ago)
- Last Synced: 2025-06-05T07:59:53.617Z (about 1 year ago)
- Language: Haskell
- Homepage:
- Size: 10.7 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# functional friday
This is where we learn about Haskell on friday evenings. As a learning project we can make a client for the SSB network.
## send a message on the ssb network
* how do you use command line args?
* how do you parse and encode json?
* how to send a network request?
## questions and stuff
Input is read lazily, meaning that a file is only buffered as it is needed, not all at once. This looks like a stream in node, but seems more baked into the language here. I think this means that *backpressure* is also the default, since the speed at which the input is buffered depends on the speed of it being processed.
----------------------------------------
The syntax for converting between IO and values is terse. This code prints the command line args. The type of `putStrLn` is `putStrLn :: String -> IO ()`. The type of `getArgs` is `getArgs :: IO [String]`. So `putStrLn` takes a string, but `getArgs` returns an IO of strings. `=<<` takes the IO action and gets the value and sends it to `putStrLn`. What happens if there is an error? Would `getArgs` need a different type signature?
```haskell
main = do
mapM_ putStrLn =<< getArgs
```
The JS equivalent I think would be like
```js
getArgs(args => console.log(args))
```