【发布时间】:2015-10-29 17:38:35
【问题描述】:
是否有任何可能性(例如语言扩展)使用Data.Set 集合的列表推导语法的语法?
示例:
f :: Set a -> Set b -> Set (a,b)
f xs ys = [(x,y) | x <- xs , y <- ys] -- this is the set comprehension
由于集合是启发列表推导的数学结构,所以没有任何可能在集合上使用它们会有点奇怪。
是的,我知道MonadComprehensions 可以将list-comp 语法与任何Monad/MonadPlus 类型一起使用,但是由于大多数函数中的Ord 约束,AFAIK 集甚至不能是单子。
【问题讨论】:
-
sets are the mathematical structure that inspired list comprehensions但是Data.Set不是那个结构because of the Ord constraint。
标签: list haskell set list-comprehension