Understanding Random monad in Scala

后端 未结 1 1433
天涯浪人
天涯浪人 2020-12-29 07:39

This a follow-up to my previous question

Travis Brown pointed out that java.util.Random is side-effecting and suggested a random monad Rng

相关标签:
1条回答
  • 2020-12-29 08:29

    Your approach is quite nice although it is a little bit complicated. I also suggested you to take a look at Chapter 6 of Functional Programming in Scala By Paul Chiusano and Runar Bjarnason. The chapter is called Purely Functional State and it shows how to create purely functional random generator and define its data type algebra on top of that to have full function composition support.

    0 讨论(0)
提交回复
热议问题