I am currently writing my own structurewhich can handle ints and strings at the same time:
Something like
data Collection = One Int | Two String | Three(Collection)(Collection)
However, I was trying to write a function which could convert my structure into a list.
Am I right in thinking this is impossible because, by default doing:
[1,2,”test”]
in the console doesn’t work and therefore my function is bound to always fail?
You should probably just define
Then, instead of doing
you can do
If you want more than two types, you’ll need to define your own member type. So you would do something like this aswell
The
deriving Showisn’t necessary, but it’s nice to be able to simply doprint lto print the list in a nice way.