Skip to content

Instantly share code, notes, and snippets.

@jchia
Created April 7, 2018 15:22
Show Gist options
  • Select an option

  • Save jchia/8bc3eb2f1bf37962592cc1be35d6b4e5 to your computer and use it in GitHub Desktop.

Select an option

Save jchia/8bc3eb2f1bf37962592cc1be35d6b4e5 to your computer and use it in GitHub Desktop.
Trying to make instance of HasField
/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
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
{-# 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