Our great sponsors
-
SurveyJS
Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.
I am not here to start a debate about OOPS vs Functional programming. So if you are not doing functional programming and don't like it simply ignore this thread.
This thread is for everyone who uses functional programming in their day to day life and have gone through the struggle of building mental models about functional way of doing things.
I am not looking for a guide to learn haskell syntax and any other programming syntax. I am looking for how to really learn functional programming. So that even if a language is not functional by nature, i can model my functions and data in functional way of building programs.
I myself write JS and Typescript for living and i came across this library https://github.com/gcanti/fp-ts
But not even 1% of this library make sense to me. So if anyone of you have gone through the struggle and overcome it and using it your code. Please share the knowledge to fellow learner.
Thanks <3 !!
So, this is going to be an uphill battle for you. I suggest you actually learn Haskell first, and then you'll be able to apply its lessons to TypeScript.
Its tricky because these are patterns that are familiar in Haskell but are not really taught in other settings.
Additionally, to really learn these, you need to experiment with them. Use them. etc. That's pretty hard to do if the learning resources are mostly in haskell and you don't really understand it.
Alternatively, this might help: https://github.com/MostlyAdequate/mostly-adequate-guide
Also alternatively, what I would do is just go slowly through the fp-ts code. Look at it a piece at a time and slowly grow your understanding.
This may also help https://www.amazon.com/Domain-Modeling-Made-Functional-Domai...
fp-ts is hard to learn. Its docs, whilst improving, aren't great and it's applying pure functional concepts to a language which isn't designed for it. The outcome is surprisingly good but it's hard to understand as a newcomer why certain design decisions have been made, or what patterns are and are not idiomatic.
I'd recommend learning Haskell in your free time. It's a major paradigm shift but once it clicks you'll find it a lot easier to translate those concepts into fp-ts.
I went through this journey a couple of years ago, and now write heavy fp-ts code full-time - including maintaining fp-ts-std[1] - as well as some paid Haskell gigs on the side. Do feel free to reach out if you want any guidance at all, you'll find my email on my personal site[2]. The FP Slack is also a great place to ask for help with anything FP, including fp-ts - if you send me an email I can have an invitation sent to you.
[1]: https://github.com/samhh/fp-ts-std
Related posts
- TypeScript: why you shouldn't throw errors to control the program flow
- ts-belt - Fast, modern, and practical utility library for FP in TypeScript / Flow / JavaScript. (Faster than ramda, rambda, remeda and lodash/fp.)
- Question about error handling in Typescript
- How to use advanced Typescript to define a `pipe` function
- Why doesn't typescript have a throws type to annotate functions that can throw an error?