Solve cyclic dependencies in haskell data records

前端 未结 1 1034
梦如初夏
梦如初夏 2021-01-19 07:57

Imagine I want to write an application which deals with podcast feeds. To store the parsed information from such a feed, I would write something like this:

d         


        
相关标签:
1条回答
  • 2021-01-19 08:18

    Cyclic dependencies are actually really easy in Haskell. In a let statement, any binding's definition can refer to any other binding.

    let pc = Podcast "the name" [ep1, ep2]
        ep1 = Episode "first" pc
        ep2 = Episode "second" pc
    

    Laziness will take care of this for you.

    As a general rule though, a DBMS is the best choice for this sort of information.

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