简体   繁体   中英

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?

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] .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM