Knows Not Much
Knows Not Much

Reputation: 31526

Scala Cats Pure on List with Multiple Items

With cats library. I can easily do

1.pure[List]

but how do I do create a list with multiple items using pure?

Upvotes: 2

Views: 128

Answers (1)

ziggystar
ziggystar

Reputation: 28680

A monad M must obey some laws. One of them is

pure[M](x).flatMap(f) = f(x)

for arbitrary functions f: A -> M[A].

With the common implementation of List.flatMap, this leaves not much room for different implementations of pure[List].

Upvotes: 1

Related Questions