Skip to content

Instantly share code, notes, and snippets.

@googleson78
Created November 18, 2020 17:17
Show Gist options
  • Save googleson78/842ae86a0d5d14674d2c21be6ce8fea5 to your computer and use it in GitHub Desktop.
Save googleson78/842ae86a0d5d14674d2c21be6ce8fea5 to your computer and use it in GitHub Desktop.
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TypeFamilies #-}
type family Ambiguous (a :: k) :: b where
Ambiguous x = x
all' :: Foldable (Ambiguous t) => (a -> Bool) -> Ambiguous t a -> Bool
all' = all
x :: Bool
x = all' (const True) []
-- ambig.hs:13:23: error:
-- • Couldn't match type ‘Ambiguous t0’ with ‘[]’
-- Expected type: Ambiguous t0 b0
-- Actual type: [b0]
-- The type variable ‘t0’ is ambiguous
-- • In the second argument of ‘all'’, namely ‘[]’
-- In the expression: all' (const True) []
-- In an equation for ‘x’: x = all' (const True) []
-- |
-- 13 | x = all' (const True) []
-- | ^^
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment