0

Let's say I have these datatypes:

data A = A1 | A2 | A3 | A4 | A5 deriving (Enum)
data B = B1 | B2 | B3 | B4 deriving (Enum)

data C = C {a :: A, b :: B} 

And then I want to create a list of [C], that contains all possible variants of combinations of As and Bs, with As at least A3. I thought it would work if I write it like this:

myListC = [(C A3 B1) .. (C A5 B4)]

and Haskell would automatically enumerate all of them. But, obviously, no. Deriving Enum in data C definition is also impossible.

I understand that in this case, it isn't that hard to do it manually, but what if I have more variants in my data C? Is there some way to do it quickly? Would appreciate your help!

arryn
  • 329
  • 2
  • 9
  • Thanks, it really is a duplicate. Not sure if I have to delete it now or not according to StackOverflow policy. – arryn Sep 26 '19 at 18:29
  • No need to delete it. This question can serve as a search engine waypoint for people having the same problem. – AJF Sep 26 '19 at 18:32

0 Answers0