Created
April 7, 2018 15:22
-
-
Save jchia/8bc3eb2f1bf37962592cc1be35d6b4e5 to your computer and use it in GitHub Desktop.
Trying to make instance of HasField
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
| /home/jchia/hs/test/test-a/src/Lib.hs:8:10: error: | |
| • Illegal instance declaration for ‘HasField field (Identity r) a’ | |
| The coverage condition fails in class ‘HasField’ | |
| for functional dependency: ‘x r -> a’ | |
| Reason: lhs types ‘field’, ‘Identity r’ | |
| do not jointly determine rhs type ‘a’ | |
| Un-determined variable: a | |
| Using UndecidableInstances might help | |
| • In the instance declaration for ‘HasField field (Identity r) a’ | |
| | | |
| 8 | instance forall (field :: Symbol) r a. HasField field r a => HasField field (Identity r) a where | |
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
| /home/jchia/hs/test/test-a/src/Lib.hs:8:62: error: | |
| • Illegal instance declaration for ‘HasField field (Identity r) a’ | |
| Identity has fields | |
| • In the instance declaration for ‘HasField field (Identity r) a’ | |
| | | |
| 8 | instance forall (field :: Symbol) r a. HasField field r a => HasField field (Identity r) a where | |
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
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 DataKinds, KindSignatures, FlexibleInstances, MultiParamTypeClasses, TypeApplications #-} | |
| module Lib where | |
| import ClassyPrelude | |
| import GHC.Records | |
| import GHC.TypeLits (Symbol) | |
| instance forall (field :: Symbol) r a. HasField field r a => HasField field (Identity r) a where | |
| getField (Identity x) = getField @field x |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment