Solve cyclic dependencies in haskell data records

前端 未结 1 1035
梦如初夏
梦如初夏 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)
提交回复
热议问题