Use of Haskell state monad a code smell?

前端 未结 8 2084
悲哀的现实
悲哀的现实 2020-12-22 19:56

God I hate the term \"code smell\", but I can\'t think of anything more accurate.

I\'m designing a high-level language & compiler to Whitespace in my spare time

8条回答
  •  旧时难觅i
    2020-12-22 20:19

    let's be careful about the terminology here. State is not per se bad; functional languages have state. What is a "code smell" is when you find yourself wanting to assign variables values and change them.

    Of course, the Haskell state monad is there for just that reason -- as with I/O, it's letting you do unsafe and un-functional things in a constrained context.

    So, yes, it's probably a code smell.

提交回复
热议问题