Created
June 7, 2019 10:41
-
-
Save neongreen/1605c5f91c35def30207bb1ecd89910d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
{-# 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