News for hackers. Stuff that matters.
Re:A philosophical difference between Haskell and Lisp (2015) by GuB-42 on Sunday August 02, 2020 @06:10PM (#24032213)
A small note: composition is not better than monolithism. The article makes it feel like it is but it is not. They are two perfectly valid approaches when it comes to solving problems. Often a mix of both is used.

Monoliths tend to be better at solving common real life problems efficiently while composition is better suited for unexpected abstract problems. We need both.

For example GNU binutils are not very "unixy", with plenty of "monolithic" options but they still work well with pipelines.

Re:A philosophical difference between Haskell and Lisp (2015) by xixixao on Sunday August 02, 2020 @09:09PM (#24033191)
I did find it ironic that composition was called UNIX philosophy, when most UNIX tools are complicated functions with many options much more akin to the lisp function examples. (Of course it's the "UNIX pipes" part of the philosophy that's being alluded to, but it's still a funny twist)
Re:A philosophical difference between Haskell and Lisp (2015) by sukilot on Monday August 03, 2020 @12:10AM (#24034156)
Yeah and the US is a democracy, and Christians are Christlike. We don't always live up to our ideals.
Re:A philosophical difference between Haskell and Lisp (2015) by quickthrower2 on Monday August 03, 2020 @05:18AM (#24035611)
cat -v
Re:A philosophical difference between Haskell and Lisp (2015) by greg7mdp on Sunday August 02, 2020 @06:16PM (#24032258)
I disagree. With composition we have general building blocks which can be combined in an infinity of ways, and remain available to combine with newly added functions. The monolith way provides a fixed, non upgradable set of possibilities, so if your need does not fall into what already exists you need to add yet another monolith (see remove-if vs remove-if-not).
Re:A philosophical difference between Haskell and Lisp (2015) by schemy on Sunday August 02, 2020 @07:01PM (#24032532)
Change the Haskell example to read 3 and 5 as n and m from an external file. All of a sudden your beautiful code is now a huge mess and you need to refactor the one liner into at least three separate functions to try and keep the Maybe types from taking everything over.

Meanwhile in lisp I would have written a special drop3-take5 function in the first place. Then refactoring it would just take replacing 3 with n and 5 with m, adding n and m as arguments and writing a function to read whatever the config file is.

Re:A philosophical difference between Haskell and Lisp (2015) by Gajurgensen on Sunday August 02, 2020 @10:53PM (#24033772)
Let's say getting those n and m values has a nasty type like `getNM :: IO (Maybe (Int, Int))`. All you need to do is map twice when using the original function.

  foo (n, m) = take n . filter p . drop m

  bar = fmap (fmap foo) getNM
It's a little awkward, but no major refactor. A small price to pay for the nice types we get. I'd argue that if other languages make dealing with IO and optional values easier, its because they don't bother restricting IO (not necessarily criticizing that), or they don't bother checking completeness over optionals (i.e. a stray `null` can show up anywhere and derail the program, which I do think is a bad thing). Overall, Haskell provides many powerful tools for composing complex types, such as the functor/applicative/monad classes.
Re:A philosophical difference between Haskell and Lisp (2015) by chongli on Sunday August 02, 2020 @07:49PM (#24032783)
keep the Maybe types from taking everything over.

Pattern matching on Maybe types is rather unidiomatic Haskell. Much better to take advantage of the type classes to which Maybe belongs: Functor, Applicative, Monad. In particular, there's no need to unwrap/wrap the Maybe value when you have `fmap`.

Re:A philosophical difference between Haskell and Lisp (2015) by vore on Sunday August 02, 2020 @07:15PM (#24032622)
Isn't that the exact same thing you would do in Haskell? How you read from a config file in Haskell seems irrelevant here, and troubles with it are more related to purity than composition.

  dropNTakeM p n m = take m . filter p . drop n
Re:A philosophical difference between Haskell and Lisp (2015) by tester89 on Sunday August 02, 2020 @06:59PM (#24032521)
I mean the -if vs -if-not is really more for typing convenience, the current CL standard actually recommends against -if-not functions because you can do composition `(remove-if (complement #’predicate) sequence)`