3 ms·
How are you using this zipped list later? That could influence the design of the parsing function and the intermediary data structure.
by kqr 4y ago
How are you using this zipped list later? That could influence the design of the parsing function and the intermediary data structure.
- kazinator 4y agoThat's the sort of thing I worry about when I'm coding in C. Here, the parsing is done; the intermediate data structure is built in. For now, it's printed to the console and thrown away (becomes garbage), but if anything else is done with it, it will be in that same form.
- kqr 4y agoIf you want a language where the compiler does not care about how you use your data (and will not help you avoid silly mistakes) then Haskell is not the language for you. It's possible to ask the Haskell compiler to not care, but this would be so far from idiomatic Haskell that it wouldn't help you if I wrote that code here, I don't think.
- tlavoie 4y agoIs the question not just one of defining the sets of "things" that are being accepted here? It's not that the compiler shouldn't care, but that you have defined an appropriate data structure and set of acceptable types that you would nicely pattern-match on when using them later. To @kazinator's point, it's not quite going to be just lists of random things, in that Haskell's list elements are all the same type, unlike what Common Lisp lets you do. I'd be more curious whether this could be lists of "Thing", where that Thing type is a typeclass that is inclusive of all the sorts of data you would expect to handle.