3 ms·
I had to implement this in Haskell while in university, we started with an interpreter for a Scheme-like language, then added static typing and inference. Pars
by FPreallyHurts 6y ago
I had to implement this in Haskell while in university, we started with an interpreter for a Scheme-like language, then added static typing and inference.
Parser combinators, monads, monad transformers, curry-howard.
Think for 15 minutes, write 5 lines of code, repeat. What I remember is that was code was really elegant but brain hurt so much.
- mcbuilder 6y agoEventually you program enough FP, and then imperative starts to hurt your brain. Programming is much like a muscle. As your program in one paradigm, you brain starts to reason that way, then switch paradigms and you're suddenly struck with a bunch of programming atrophy.
- DaiPlusPlus 6y agoImperative doesn’t hurt my brain, but because many operations in FP are generally much more succinct and expressive than in an imperative style - writing in imperative instead just makes me groan about all the manual keyboard-typing I’ll have to do (e.g. Linq vs foreach). I really wish I could do more FP, but the languages and libraries I use for my day-job aren’t as-accommodating (mostly C#) - while C# has some FP features, it’s really held-back by the CLR’s type-system - so until that fundamental plumbing gets done we’ll never see features like type-classes, true immutable types, algebraic-types, and so on. Without those features we’ll have to keep on writing more code than is necessary. <digress>Heck, it’s bad enough that IDictionary doesn’t implement IReadOnlyDictionary - or that none of the IReadOnly* types make any guarantees about immutability, which means having to review documentation or disassembly in ILSpy. And the famed non-nullable-reference-types in C# 8.0 is actually all just syntactic sugar for yet more attributes rather than true code-contracts, a built-in Option type, or extending the CLR’s type-system to understand nullability. Grumble.</digress>
- Multicomp 6y ago> while C# has some FP features....we’ll never see features like type-classes, true immutable types, algebraic-types, and so on. IIRC you just described some features of F#, excepting type classes. Or at least F# gets you closer to the goal. Maybe the ever elusive F* has that stuff?