Skip to content

Instantly share code, notes, and snippets.

@JakobBruenker
Last active November 19, 2020 01:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JakobBruenker/a1b8c66abcb1c05e9bf4ff55e73fa6c8 to your computer and use it in GitHub Desktop.
Save JakobBruenker/a1b8c66abcb1c05e9bf4ff55e73fa6c8 to your computer and use it in GitHub Desktop.
{-# LANGUAGE DataKinds
, ScopedTypeVariables
, TypeApplications
, TypeFamilies
, PolyKinds
, StandaloneKindSignatures
#-}
module MaybeBug where
type family Undefined where
data Relation n m = MkR
type Fam :: forall a b c . Relation a b -> Relation b c -> Relation a c
type family Fam lt o where
Fam @a @b @c alt MkR = Undefined -- @a @b @c are not a problem on their own
Fam alt MkR = alt -- this is fine (but isn't (alt :: Relation a b)?)
-- Fam @a @b @c alt MkR = alt
-- Produces error - Why does this work without @a @b @c but not with?
-- ANSWER: The `alt` return value makes ghc infer the invisible arguments as @a @b @b, so
-- this equation ends up matching fewer cases than if it were @a @b @c
{-
MaybeBug.hs:21:26: error:
• Expected kind ‘Relation a c’, but ‘alt’ has kind ‘Relation a b’
• In the type ‘alt’
In the type family declaration for ‘Fam’
|
21 | Fam @a @b @c alt MkR = alt
|
-}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment