inferring datatypes
play

Inferring Datatypes Ningning Xie HIW 2019.08.23 data Maybe a = - PowerPoint PPT Presentation

Inferring Datatypes Ningning Xie HIW 2019.08.23 data Maybe a = Nothing | Just a data List a = Nil | Cons a ( List a) data Either a b = Left a | Right b Wh Which da datatype ype de declarations ns sh should be e ac accepted? Wh What ki


  1. Inferring Datatypes Ningning Xie HIW 2019.08.23

  2. data Maybe a = Nothing | Just a data List a = Nil | Cons a ( List a) data Either a b = Left a | Right b

  3. Wh Which da datatype ype de declarations ns sh should be e ac accepted? Wh What ki kinds do do accep accepted ed da datatypes pes ha have? e?

  4. Haskell98 data AppInt f = Mk (f Int ) AppInt :: ?

  5. Haskell98 data AppInt f = Mk (f Int ) AppInt :: ? AppInt :: ∗ → ∗ → ∗

  6. data Q1 a = MkQ1 data Q2 = MkQ2 ( Q1 Maybe )

  7. data Q1 a = MkQ1 -- Q1 ∷ ∗ → ∗ data Q2 = MkQ2 ( Q1 Maybe )

  8. data Q1 a = MkQ1 -- Q1 ∷ ∗ → ∗ data Q2 = MkQ2 ( Q1 Maybe ) -- Rejected!

  9. data Q1 a = MkQ1 Q2 data Q2 = MkQ2 ( Q1 Maybe )

  10. data Q1 a = MkQ1 Q2 -- Q1 ∷ (∗ → ∗) → ∗ data Q2 = MkQ2 ( Q1 Maybe )

  11. data Q1 a = MkQ1 Q2 -- Q1 ∷ (∗ → ∗) → ∗ data Q2 = MkQ2 ( Q1 Maybe ) -- Accepted!

  12. Modern Haskell

  13. {-# LANGUAGE ExplicitForAll , PolyKinds , ExistentialQuantification , TypeInType , TypeApplications #-}

  14. data X :: forall a (b::*->*). a b -> * data Y :: forall (c :: Maybe Bool ). X c -> *

  15. data X :: forall a (b::*->*). a b -> * data Y :: forall (c :: Maybe Bool ). X c -> *

  16. data X :: forall a (b::*->*). a b -> * data Y :: forall (c :: Maybe Bool ). X c -> * a :: (∗ → ∗) → ∗ Kind mismatch!

  17. data Q :: forall (a :: f b) (c :: k) . f c -> *

  18. data Q :: forall (a :: f b) (c :: k) . f c -> *

  19. data Q :: forall (a :: f b) (c :: k) . f c -> * data Q :: forall (f::?) (b::?) (k::?) forall (a :: f b) (c :: k) . f c -> *

  20. data Q :: forall (a :: f b) (c :: k) . f c -> * c :: k k :: *

  21. data Q :: forall (a :: f b) (c :: k) . f c -> * c :: k k :: * f :: k -> *

  22. data Q :: forall (a :: f b) (c :: k) . f c -> * c :: k k :: * f :: k -> * b :: k

  23. data Q :: forall (a :: f b) (c :: k) . f c -> * k :: * f :: k -> * b :: k

  24. data Q :: forall (a :: f b) (c :: k) . f c -> * data Q :: forall (f::?) (b::?) (k::?) forall (a :: f b) (c :: k) . f c -> *

  25. data Q :: forall (a :: f b) (c :: k) . f c -> * data Q :: forall (k::?) (f::?) (b::?) forall (a :: f b) (c :: k) . f c -> *

  26. data Q :: forall (a :: f b) (c :: k) . f c -> * data Q :: forall (k::*) (f::k->*) (b::k) forall (a :: f b) (c :: k) . f c -> *

  27. Inferring Datatypes

  28. Inferring Datatypes • If you are a type theorist…

  29. Inferring Datatypes • If you are a GHC hacker/developer… • Further language extensions • How our work relates to GHC

Recommend


More recommend