
3 Nov
2015
3 Nov
'15
5:24 p.m.
I've made a new datatype data Visibility a = Hidden a | Shown a I want to create a type that's a list of hidden and visible integers. So something like this: type possiblyVisibleInts = [Visibility Int] The idea is that some of the ints will be hidden and some will be shown. But it doesn't work. Why not? This seemed even odder to me after poking around in ghci: :t [Just 5, Nothing] gives [Just 5, Nothing] :: Num a => [Maybe a] So clearly it's possible to have a list of a type that has 2 constructors--you're not restricted to having a list that only contains Just, for example. ghci is also OK with e.g. :t [Hidden 5, Shown 6] [Hidden 5, Shown 6] :: Num a => [Visibility a]