[Haskell-beginners] DataKinds and GADTs question?
coot at coot.me
coot at coot.me
Sat Jun 12 11:13:01 UTC 2021
There isn't. GHC will infer kind `Type -> Type` for `MyType2`. You can check that in `ghci` with `:kind MyType` and `:kind MyType2`. There's also third way to write it by adding a standalone kind signature:
```
{-# LANGUAGE StandalondKindSignatures, GADTs #-}
type MyType3 :: Type -> Type
data MyType3 a where
MkT3 :: Int -> MyType3 Int
```
A polykinded version would look like this:
```
{-# LANGUAGE PolyKinds #-}
type MyType4 :: forall a -> Type
data MyType4 a where
MkT3 :: MyType4 Int
```
in `ghci` the kind of `MyType4` is:
```
:kind MyType4
MyType4 :: forall k. forall (a :: k) -> Type
```
Best regards,
Marcin
Sent with ProtonMail Secure Email.
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Thursday, June 10th, 2021 at 13:15, Velichko Lefterov <velichko.lefterov at gmail.com> wrote:
> I tried to understand DataKinds and GADTs...Is there a difference between:
>
> data MyType :: Type -> Type where
>
> MyTypeConstructor :: Int -> MyType Int
>
> data MyType2 a where
>
> MyTypeConstructor2 :: Int -> MyType2 Int
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20210612/cca51f6f/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 509 bytes
Desc: OpenPGP digital signature
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20210612/cca51f6f/attachment.sig>
More information about the Beginners
mailing list