[erlang-questions] Proposal: add lists:intersperse/2 and lists:intercalate/2

Loïc Hoguin <>
Mon Mar 7 17:04:12 CET 2016


On 03/07/2016 04:53 PM, Garrett Smith wrote:
> On Mon, Mar 7, 2016 at 9:28 AM Jesper Louis Andersen
> <
> <mailto:>> wrote:
>
>
>     On Mon, Mar 7, 2016 at 4:08 PM, Garrett Smith <
>     <mailto:>> wrote:
>
>         It's vague, as is intercalculate, but as it's superficially
>         doing what string "join" does with chars has some precedence
>         within Erlang. I wouldn't call it hopeless.
>
>
>     I'm probably leaning away from using 'join' at this point, since
>     'join' already have type
>
>     join :: Monad M => m (m a) -> m a
>
>     so from an FP perspective, that name is highly confusing since it is
>     in use in monadic context and is used to join monadic data into its
>     own monadic context. For a list, join is essentially 'append':
>
>     Prelude Control.Monad> join ["a", "b", "c"]
>     "abc"
>
>     But join is monadic, so `join $ Just Nothing` evaluates to `Nothing`.
>
>
> Sigh. Okay, so the future naming discussions will involve with word
> monad and monadic?
>
> You've seen the discussions around adoption and the disruptive influence
> of Elixir?
>
> For whatever reason FP pedantry is not a draw for me. When I need
> inspiration I look to Python. Maybe that's the wrong direction and we
> need to drive our community through more gates.

I am completely with you on that. If the function was called 
intercalculate I'd never find it and would continue writing my own.

Precision is important, but it's even more important to think about who 
the users are (or who you want them to be) and to lose some of this 
precision to make things clearer for them. And as far as I can tell, 
people don't go to Erlang because of their mathematical background.

Human languages are interesting like that, because the more you go for 
precision the less people understand what you mean. Specialized terms 
are only good for people with the same specialization. If you want the 
most people to get it, use terms that a fourth grader would understand.

-- 
Loïc Hoguin
http://ninenines.eu
Author of The Erlanger Playbook,
A book about software development using Erlang


More information about the erlang-questions mailing list