Last active
August 7, 2021 13:31
-
-
Save tfausak/2cc0d684af132c2b4c2a8189107e5ead to your computer and use it in GitHub Desktop.
Example of unexpected ambiguity.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env stack | |
-- stack --resolver ghc-9.0.1 script | |
-- https://github.com/tfausak/witch/issues/19 | |
{-# language AllowAmbiguousTypes #-} | |
{-# language ScopedTypeVariables #-} | |
{-# language TypeApplications #-} | |
{-# language TypeFamilies #-} | |
data Break | |
type family Ambiguous a where | |
Ambiguous Break = () | |
Ambiguous a = a | |
as :: forall a b . Ambiguous a ~ b => b -> b | |
as = id | |
identity :: forall a . a -> a | |
identity = as @a | |
{- | |
• Couldn't match type ‘a’ with ‘Ambiguous a’ | |
arising from a use of ‘as’ | |
‘a’ is a rigid type variable bound by | |
the type signature for: | |
identity :: forall a. a -> a | |
at /tmp/tmp.vkOEgTlyHU/Main.hs:17:1-29 | |
• In the expression: as @a | |
In an equation for ‘identity’: identity = as @a | |
• Relevant bindings include | |
identity :: a -> a (bound at /tmp/tmp.vkOEgTlyHU/Main.hs:18:1) | |
-} | |
main :: IO () | |
main = pure $ identity () |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment