
A few months ago, there was a discussion here about defining Set to be a Monad, starting with: [1] http://www.haskell.org/pipermail/haskell-cafe/2004-March/005988.html in response to which, SPJ pointed out that a Set cannot be a Monad: [2] http://www.haskell.org/pipermail/haskell-cafe/2004-March/005995.html I found myself treading a path which led me to asking the same question as [1]. Given the answer [2], I'd like to stand back a little and ask if there's another way to tackle my niggle: what I'm interested in is a set comprehension expression that is analogous to a list comprehension expression; e.g. in: [[
import Data.Set
type AtomicConcept = String -- named atomic concept type AtomicRole = String -- named atomic role
type AtomicConcepts a :: AtomicConcept -> (Set a) type AtomicRoles a :: AtomicRole -> (Set (a,a))
type Interpretation a :: (Set a,AtomicConcepts a,AtomicRoles a)
...
iAL (idom,ic,ir) (ALAll r c) = mkSet [ a | (a,b) <- setToList (ir r) , b `elementOf` ir c ] ]]
is there a common or similar idiom to achieve the same effect without converting the set to a list and back? I did also find myself wondering if there was a role for unfold (or similar) here. #g ------------ Graham Klyne For email: http://www.ninebynine.org/#Contact

On Tue, Jul 20, 2004 at 04:42:24PM +0100, Graham Klyne wrote:
I found myself treading a path which led me to asking the same question as [1]. Given the answer [2], I'd like to stand back a little and ask if there's another way to tackle my niggle: what I'm interested in is a set comprehension expression that is analogous to a list comprehension expression; e.g. in:
Though I do not have an answer for you, I do occasionally feel the need (ehm, need is a bit too strong a word) for some-kind-of-collection-comprehensions too. Also, GHC has the parallel array extension which adds array-comprehensions; although I think it's impossible to fit in haskell 98, it would be nice to have some general mechanism on which "collection-comprehensions" (and enumerations: [1..5], [:1..5:], ...) could be based. Groetjes, Remi -- Nobody can be exactly like me. Even I have trouble doing it.
participants (2)
-
Graham Klyne
-
Remi Turk