I am trying to understand the Constr type of Data.Data package. Consider the session below. dataTypeConstrs
returns a list of Constr
, both zero- and one-argument constructors of Maybe. Attempting to re-create the list fails due to obvious type error. Is it a special behavior of GHC regarding to Constr value?
$ ghci
GHCi, version 7.10.2: http://www.haskell.org/ghc/ :? for help
Prelude> :set -XScopedTypeVariables
Prelude> :module +Data.Data
Prelude Data.Data> dataTypeConstrs (dataTypeOf (Nothing :: Maybe ()))
[Nothing,Just]
Prelude Data.Data> :i it
it :: [Constr] -- Defined at <interactive>:4:1
Prelude Data.Data> let i2 :: [Constr] = [Nothing,Just]
<interactive>:6:23:
Couldn't match expected type ‘Constr’ with actual type ‘Maybe a0’
In the expression: Nothing
In the expression: [Nothing, Just]