Zulip Chat Archive

Stream: mathlib4

Topic: mapM'


Ruben Van de Velde (Dec 01 2022 at 20:25):

The following are #aligned in Mathlib/Init/Control/Combinators.lean - is that right?

def list.mmap' {m : Type  Type v} [monad m] {α : Type u} {β : Type} (f : α  m β) : list α  m unit
def mapM' [Monad m] (f : α  m β) : List α  m (List β)

Yakov Pechersky (Dec 01 2022 at 21:17):

I might have slipped in an extra apostrophe somewhere

Scott Morrison (Dec 01 2022 at 21:23):

Yes, usually the primed versions are the "return nothing" versions.

Arien Malec (Dec 02 2022 at 17:14):

really? not the Haskell convention of lazy vs strict?

Scott Morrison (Dec 02 2022 at 17:24):

Nope. There's no such distinction here.

Mario Carneiro (Dec 02 2022 at 17:37):

The naming convention for "return nothing" map functions is forM

Mario Carneiro (Dec 02 2022 at 17:38):

e.g docs4#List.forM

Eric Wieser (Dec 02 2022 at 17:41):

Is there a "return nothing" version of docs4#List.foldrM / docs#list.foldrm?

Mario Carneiro (Dec 02 2022 at 17:42):

No, I don't think there is a more efficient implementation than l.reverse.forM ... anyway

Mario Carneiro (Dec 02 2022 at 17:44):

actually I guess foldrM is a bit more different than that

Mario Carneiro (Dec 02 2022 at 17:45):

Unlike discard <| mapM, I don't really see the advantage of having a separate function for discard <| foldrM since you have to construct the final state s anyway because you have to pass it through the list

Trebor Huang (Dec 04 2022 at 11:02):

Haskell uses underlines for the "return nothing" version, iirc.


Last updated: Dec 20 2023 at 11:08 UTC