Last active
July 30, 2019 14:49
-
-
Save parsonsmatt/41b0dd381928549d3156cb00a7325e20 to your computer and use it in GitHub Desktop.
I'm upset
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
{-# language DuplicateRecordFields, TypeApplications #-} | |
module DuplicateRecordFields where | |
data User = User { name :: String } | |
data Dog = Dog { name :: String } | |
-- Works | |
nameAlias :: User -> String | |
nameAlias = name | |
-- Error: | |
-- drf.hs:9:15-18: error: | |
-- Ambiguous occurrence ‘name’ | |
-- It could refer to either the field ‘name’, defined at drf.hs:6:18 | |
-- or the field ‘name’, defined at drf.hs:5:20 | |
-- | | |
-- 9 | nameAlias2 u = name u | |
-- | ^^^^ | |
-- nameAlias2 :: User -> String | |
-- nameAlias2 u = name u | |
r :: (r -> a) -> r -> a | |
r f = f | |
-- works | |
nameAlias3 :: User -> String | |
nameAlias3 = r @User name | |
-- what in the hell | |
nameAlias4 :: User -> String | |
nameAlias4 u = r @User name u |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment