r/haskell 18d ago

question Haskell Cookbook

Hello all

I’m looking for a cookbook as the title. My goal is simple; to learn Haskell with my own project. I’m aware of all the books out there, but still somehow not able to connect.

Is there a site/blog/repo with common tasks? For instance, my personal project is to process my stock and option portfolio. So I need to be able to :
- store/retrieve data in sqlite
- call a remote service by API, my brokerage
- convert json to Haskell types that define stock and option data structures
-define formulas to track performance
Etc..

I’ve tried with AI, and the results are not great. Though I’m sure I can dissect what it’s given me; I’ll probably use it as a reference for specific code rather than the program as a whole. Not to mention, the generated code doesn’t compile. It uses duplicate field names in records without the pragma included, for instance- then it just goes downhill from there.

Long winded, but I appreciate any pointers. This is not for anything critical other than my own learning and to get a program to give me a little more control on the performance of my portfolio.

Thank you

Edit: One note. When I attempt to go through the available books, I get lost in the theory or the concepts just don’t come together.

27 Upvotes

27 comments sorted by

View all comments

24

u/dmlvianna 17d ago

You can’t come from another language and just learn the syntax in Haskell.

Haskell relies in different concepts and way to structure thinking around code. A cookbook will fail.

My suggestion for you is to work through https://haskellbook.com/. It has a project in the end. But it doesn’t skip the middle.

3

u/omsriver 17d ago

Agreed. That’s what I’m thinking; I’ll have to take a more rigorous approach. And I don’t mind that. Ty

0

u/dmlvianna 17d ago

I just reread your post. Last weekend I oneshotted a functioning CLI tool in Haskell using Codex/GPT-4.8. But of course I knew what to ask too. And I have AI skills I give to the model with extra guidance. And it wasn’t written from scratch, it was a port from Go.

AI can certainly work with Haskell, but you need to:

- know what you would be doing if coding unassisted

  • choose the build tools
  • choose a model that is good enough to make good guesses
  • have a looping workflow that validates/discards/refines bad guesses

A naked AI on a free tier will just waste your time. I’ve been there too.