4 ms·
I'm probably way OT, but this seems like a decent place to get some opinions and this article doesn't address my issue: Here's my problem with Haskell: I want
by blacktriangle 6y ago
I'm probably way OT, but this seems like a decent place to get some opinions and this article doesn't address my issue:
Here's my problem with Haskell: I want to model my domain as collections of heterogeneous maps. I work in the B2B world where our databases go back years but every week either the sales dept or our customers are throwing totally new requirements at us changing the way we think about our domain. We also do a ton of work with SQL which is trivial with such a mindset as relations are just sets of maps, but working with relations in Haskell, or any strongly typed language requires mapping layers that become their own source of unnecessary complexity.
I love the idea of the compiler doing more work for me and really do miss the advantages of type systems for communicating intent to other developers. I've had positive experiences with C# in game dev and Scala in scientific computing, but in my current role shoving the real world into a typed box has been an exercise in futility. Am I missing something about Haskell that supports this world or is it just a bad fit for my org?
- thethimble 6y agoMaybe your domain can’t be modeled better than heterogenous maps. But Haskell’s type safety extends beyond your immediate domain. Writing a web server, interfacing to a database, etc. all have well formulated domains and Haskell’s type safety provides a lot of value there. Finally, I’m not denying that some domains are too chaotic and fast changing to be modeled statically. But there’s like some subset of your domain that is indeed static. Can you represent that statically and represent the other subset dynamically?
- blacktriangle 6y agoTrue, and that's where it feels like the Haskell side would be powerful. I did a small demo app with Yesod and loved it, and we have a ton of state machine type logic that would hugely benefit from ADTs. You're right the hybrid approach seems better, but there it seems more like that Python/Ruby with their new gradual typing seems like the way to go, adding strong on top of dynamic rather than trying to poke a hole in strong typing to let you be dynamic.
- travv0 6y agoHave you looked into using a heterogeneous map library in Haskell? I haven't used any myself, but a quick search shows that they do at least exist.
- blacktriangle 6y agoI looked a bit, but the variety of libraries itself is somewhat concerning. There's this article https://wiki.haskell.org/Heterogenous_collections https://wiki.haskell.org/Heterogenous_collections that points to some good resources but the general feel I get from reading is that heterogeneous collections in Haskell are a bit of a rabbit hole with no clear answer yet.
- lenkite 6y agoYou would probably love Clojure then. It is the language to deal with data maps and their manipulation.
- blacktriangle 6y agoI do love Clojure. But it's always interesting to listen to the experience of the Haskeller's and I keep trying to find the motivation to dig deeper into it. The responses I've received have me thinking I need to give up finding a way to directly map Haskell into my day to day work and more just approach it on its own terms and then take from it what I can.
- mightybyte 6y agoNo matter how heterogeneous the map seems to be, there's always some underlying structure. If you have written code to work with it, then you've encoded that structure...by definition. Haskell gives you fantastic tools for managing this structure at whatever level of specificity you want. At the end of the day everything in a computer always boils down to bytes, so in the absolute worst case, you can always drop out to the escape hatch of: Map ByteString ByteString This can represent any heterogeneous map that any other language can represent. Sum types can allow us to add another layer of structure to this if we want. For example, take the classic example of JSON. Map ByteString JValue ...where data JValue = JObject (Map Text JValue) | JArray Array | JString Text | JNumber Scientific | JBool Bool | JNull This is just one example of a way you could structure things. Sum types are super powerful for this kind of thing. And no matter what structure you come up with, you can always escape hatch that structure by adding a catch-all constructor like this: data MyValue = MyThingA A | MyThingB B | ... more things | Unexpected ByteString That's actual valid code btw, and it even reads really nicely!