Skip to content

Instantly share code, notes, and snippets.

@neongreen
Created June 7, 2019 10:41
Show Gist options
  • Save neongreen/1605c5f91c35def30207bb1ecd89910d to your computer and use it in GitHub Desktop.
Save neongreen/1605c5f91c35def30207bb1ecd89910d to your computer and use it in GitHub Desktop.
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE TypeApplications #-}
class Voodoo tag where
-- Let's define an operation that requires TypeApplications in order to work
voodoo :: Int -> String
-- Let's also have an instance (we could have more, of course)
data Tag
instance Voodoo Tag where
voodoo = show
-- This works:
--
test1 = voodoo @Tag 3
-- This doesn't:
--
-- test2 = voodoo 3 @Tag
--
-- • Cannot apply expression of type ‘String’
-- to a visible type argument ‘Tag’
-- Can we define voodoo' that will work?
voodoo' :: Int -> (forall tag. Voodoo tag => String)
voodoo' = _
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment