You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{-# LANGUAGE OverloadedLabels #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE MonoLocalBinds #-}
importData.Generics.Product (HasField', field')
importData.Generics.Labels ()
g:: (HasField'"outer"st, HasField'"inner"ta) =>forallf.Functorf=> (a->fa) ->s->fs
g =#outer .#inner
g':: (HasField'"outer"st, HasField'"inner"ta) =>forallf.Functorf=> (a->fa) ->s->fs
g' = field' @"outer". field' @"inner"
g' typechecks, but g doesn't:
Collapsed error
blademaster::~»stackghcigeneric-labels.hs--package generic-lens --package microlens
[1of1] CompilingMain ( /home/googleson78/generic-labels.hs, interpreted )
/home/googleson78/generic-labels.hs:11:5:error:•Overlapping instances for HasField"outer" s s s0 t0
arising from the overloaded label ‘#outer’Matching instances:instance (HasTotalFieldPfield (Reps) ~~ 'Just a,
HasTotalFieldPfield (Rept) ~~ 'Just b,
HasTotalFieldPfield (Rep (Indexeds)) ~~ 'Just a',
HasTotalFieldPfield (Rep (Indexedt)) ~~ 'Just b',
t~~Infersa'b, s~~Infertb'a, HasField0fieldstab) =>HasFieldfieldstab-- Defined in ‘Data.Generics.Product.Fields’...plus one instance involving out-of-scope types
(use -fprint-potential-instances to see them all)
(The choice depends on the instantiation of‘s, s0, t0’To pick the first instance above, use IncoherentInstances
when compiling the other instance declarations)
•In the first argument of‘(.)’, namely ‘#outer’In the expression:#outer .#inner
In an equation for ‘g’: g =#outer .#inner
|11| g =#outer .#inner
|^^^^^^/home/googleson78/generic-labels.hs:11:14:error:•Overlapping instances for HasField"inner" s0 t0 a a
arising from the overloaded label ‘#inner’Matching instances:instance (HasTotalFieldPfield (Reps) ~~ 'Just a,
HasTotalFieldPfield (Rept) ~~ 'Just b,
HasTotalFieldPfield (Rep (Indexeds)) ~~ 'Just a',
HasTotalFieldPfield (Rep (Indexedt)) ~~ 'Just b',
t~~Infersa'b, s~~Infertb'a, HasField0fieldstab) =>HasFieldfieldstab-- Defined in ‘Data.Generics.Product.Fields’...plus one instance involving out-of-scope types
(use -fprint-potential-instances to see them all)
(The choice depends on the instantiation of‘s0, t0, a’To pick the first instance above, use IncoherentInstances
when compiling the other instance declarations)
•In the second argument of‘(.)’, namely ‘#inner’In the expression:#outer .#inner
In an equation for ‘g’: g =#outer .#inner
|11| g =#outer .#inner
|^^^^^^
Is this some known issue, and can it be worked around somehow? I think Lens'/HasField' is much more understandable to someone not familiar with optics, and really prefer using it whenever possible.
The text was updated successfully, but these errors were encountered:
I doubt that it's fixable. It's similar to the problem of show . read. show . read can't compile because read gives a polymorphic output while show takes a polymorphic input, and there's no way for the compiler to infer the intermediate type.
In this example:
g'
typechecks, butg
doesn't:Collapsed error
Is this some known issue, and can it be worked around somehow? I think
Lens'
/HasField'
is much more understandable to someone not familiar with optics, and really prefer using it whenever possible.The text was updated successfully, but these errors were encountered: