Skip to content

Instantly share code, notes, and snippets.

@eamsden
Created April 24, 2019 15:20
Show Gist options
  • Save eamsden/2d6c89f899b84b3ad9d5b24d15995fac to your computer and use it in GitHub Desktop.
Save eamsden/2d6c89f899b84b3ad9d5b24d15995fac to your computer and use it in GitHub Desktop.
Nested/Recursive Barbie Example

Trying it out

If you have Nix installed, then just running nix-shell in the directory with the gist will start an environment with ghci 8.6.4 with the barbies package registered.

You can then do $ ghci BarbieIssue.hs to see the type error mess.

{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE UndecidableInstances #-}
module BarbieIssue where
import Data.Barbie
import GHC.Generics
data OuterBarbie f
= OuterBarbie
{ innerBarbie :: f (InnerBarbie f)
} deriving ( Generic
, FunctorB, TraversableB, ProductB, ConstraintsB, ProductBC
)
deriving instance (AllBF Eq f OuterBarbie) => Eq (OuterBarbie f)
data InnerBarbie f
= InnerBarbie
{ innerData :: f String
} deriving ( Generic
, FunctorB, TraversableB, ProductB, ConstraintsB, ProductBC
)
deriving instance (AllBF Eq f InnerBarbie) => Eq (InnerBarbie f)
data RecursiveBarbie f
= MoreBarbie (f (RecursiveBarbie f))
| ABarbie
deriving ( Generic
, FunctorB, TraversableB, ProductB, ConstraintsB, ProductBC
)
deriving instance (AllBF Eq f InnerBarbie) => Eq (RecursiveBarbie f)
BarbieIssue.hs:14:7: error:
• No instance for (barbies-1.1.2.1:Data.Barbie.Internal.Functor.GFunctorB
f
g
(Rec
(barbies-1.1.2.1:Data.Generics.GenericN.Param
0
f
(InnerBarbie (barbies-1.1.2.1:Data.Generics.GenericN.Param 0 f)))
(f (InnerBarbie f)))
(Rec
(barbies-1.1.2.1:Data.Generics.GenericN.Param
0
g
(InnerBarbie (barbies-1.1.2.1:Data.Generics.GenericN.Param 0 g)))
(g (InnerBarbie g))))
arising from the 'deriving' clause of a data type declaration
Possible fix:
use a standalone 'deriving instance' declaration,
so you can specify the instance context yourself
• When deriving the instance for (FunctorB OuterBarbie)
|
14 | , FunctorB, TraversableB, ProductB, ConstraintsB, ProductBC
| ^^^^^^^^
BarbieIssue.hs:14:17: error:
• Could not deduce (barbies-1.1.2.1:Data.Barbie.Internal.Traversable.GTraversableB
f
g
(Rec
(barbies-1.1.2.1:Data.Generics.GenericN.Param
0
f
(InnerBarbie (barbies-1.1.2.1:Data.Generics.GenericN.Param 0 f)))
(f (InnerBarbie f)))
(Rec
(barbies-1.1.2.1:Data.Generics.GenericN.Param
0
g
(InnerBarbie (barbies-1.1.2.1:Data.Generics.GenericN.Param 0 g)))
(g (InnerBarbie g))))
arising from the 'deriving' clause of a data type declaration
from the context: Applicative t
bound by the deriving clause for ‘TraversableB OuterBarbie’
at BarbieIssue.hs:14:17-28
Possible fix:
use a standalone 'deriving instance' declaration,
so you can specify the instance context yourself
• When deriving the instance for (TraversableB OuterBarbie)
|
14 | , FunctorB, TraversableB, ProductB, ConstraintsB, ProductBC
| ^^^^^^^^^^^^
BarbieIssue.hs:14:31: error:
• No instance for (barbies-1.1.2.1:Data.Barbie.Internal.Product.GProductB
f
g
(Rec
(barbies-1.1.2.1:Data.Generics.GenericN.Param
0
f
(InnerBarbie (barbies-1.1.2.1:Data.Generics.GenericN.Param 0 f)))
(f (InnerBarbie f)))
(Rec
(barbies-1.1.2.1:Data.Generics.GenericN.Param
0
g
(InnerBarbie (barbies-1.1.2.1:Data.Generics.GenericN.Param 0 g)))
(g (InnerBarbie g)))
(Rec
(barbies-1.1.2.1:Data.Generics.GenericN.Param
0
(Data.Functor.Product.Product f g)
(InnerBarbie
(barbies-1.1.2.1:Data.Generics.GenericN.Param
0 (Data.Functor.Product.Product f g))))
(Data.Functor.Product.Product
f g (InnerBarbie (Data.Functor.Product.Product f g)))))
arising from the 'deriving' clause of a data type declaration
Possible fix:
use a standalone 'deriving instance' declaration,
so you can specify the instance context yourself
• When deriving the instance for (ProductB OuterBarbie)
|
14 | , FunctorB, TraversableB, ProductB, ConstraintsB, ProductBC
| ^^^^^^^^
BarbieIssue.hs:14:31: error:
• No instance for (barbies-1.1.2.1:Data.Barbie.Internal.Product.GProductB
f
f
(Rec
(barbies-1.1.2.1:Data.Generics.GenericN.Param
0
f
(InnerBarbie (barbies-1.1.2.1:Data.Generics.GenericN.Param 0 f)))
(f (InnerBarbie f)))
(Rec
(barbies-1.1.2.1:Data.Generics.GenericN.Param
0
f
(InnerBarbie (barbies-1.1.2.1:Data.Generics.GenericN.Param 0 f)))
(f (InnerBarbie f)))
(Rec
(barbies-1.1.2.1:Data.Generics.GenericN.Param
0
(Data.Functor.Product.Product f f)
(InnerBarbie
(barbies-1.1.2.1:Data.Generics.GenericN.Param
0 (Data.Functor.Product.Product f f))))
(Data.Functor.Product.Product
f f (InnerBarbie (Data.Functor.Product.Product f f)))))
arising from the 'deriving' clause of a data type declaration
Possible fix:
use a standalone 'deriving instance' declaration,
so you can specify the instance context yourself
• When deriving the instance for (ProductB OuterBarbie)
|
14 | , FunctorB, TraversableB, ProductB, ConstraintsB, ProductBC
| ^^^^^^^^
BarbieIssue.hs:14:41: error:
• Could not deduce (barbies-1.1.2.1:Data.Barbie.Internal.Constraints.GConstraintsB
c
f
(Rec
(barbies-1.1.2.1:Data.Generics.GenericN.Param
0
barbies-1.1.2.1:Data.Barbie.Internal.Constraints.X
(InnerBarbie
(barbies-1.1.2.1:Data.Generics.GenericN.Param
0 barbies-1.1.2.1:Data.Barbie.Internal.Constraints.X)))
(barbies-1.1.2.1:Data.Barbie.Internal.Constraints.X
(InnerBarbie barbies-1.1.2.1:Data.Barbie.Internal.Constraints.X)))
(Rec
(barbies-1.1.2.1:Data.Generics.GenericN.Param
0
f
(InnerBarbie (barbies-1.1.2.1:Data.Generics.GenericN.Param 0 f)))
(f (InnerBarbie f)))
(Rec
(barbies-1.1.2.1:Data.Generics.GenericN.Param
0
(Data.Functor.Product.Product
(barbies-1.1.2.1:Data.Barbie.Internal.Dicts.Dict c) f)
(InnerBarbie
(barbies-1.1.2.1:Data.Generics.GenericN.Param
0
(Data.Functor.Product.Product
(barbies-1.1.2.1:Data.Barbie.Internal.Dicts.Dict c) f))))
(Data.Functor.Product.Product
(barbies-1.1.2.1:Data.Barbie.Internal.Dicts.Dict c)
f
(InnerBarbie
(Data.Functor.Product.Product
(barbies-1.1.2.1:Data.Barbie.Internal.Dicts.Dict c) f)))))
arising from the 'deriving' clause of a data type declaration
from the context: AllB c OuterBarbie
bound by the deriving clause for ‘ConstraintsB OuterBarbie’
at BarbieIssue.hs:14:41-52
Possible fix:
use a standalone 'deriving instance' declaration,
so you can specify the instance context yourself
• When deriving the instance for (ConstraintsB OuterBarbie)
|
14 | , FunctorB, TraversableB, ProductB, ConstraintsB, ProductBC
| ^^^^^^^^^^^^
BarbieIssue.hs:14:55: error:
• Could not deduce (barbies-1.1.2.1:Data.Barbie.Internal.ProductC.GProductBC
c
(Rec
(barbies-1.1.2.1:Data.Generics.GenericN.Param
0
barbies-1.1.2.1:Data.Barbie.Internal.Constraints.X
(InnerBarbie
(barbies-1.1.2.1:Data.Generics.GenericN.Param
0 barbies-1.1.2.1:Data.Barbie.Internal.Constraints.X)))
(barbies-1.1.2.1:Data.Barbie.Internal.Constraints.X
(InnerBarbie barbies-1.1.2.1:Data.Barbie.Internal.Constraints.X)))
(Rec
(barbies-1.1.2.1:Data.Generics.GenericN.Param
0
(barbies-1.1.2.1:Data.Barbie.Internal.Dicts.Dict c)
(InnerBarbie
(barbies-1.1.2.1:Data.Generics.GenericN.Param
0 (barbies-1.1.2.1:Data.Barbie.Internal.Dicts.Dict c))))
(barbies-1.1.2.1:Data.Barbie.Internal.Dicts.Dict
c
(InnerBarbie
(barbies-1.1.2.1:Data.Barbie.Internal.Dicts.Dict c)))))
arising from the 'deriving' clause of a data type declaration
from the context: AllB c OuterBarbie
bound by the deriving clause for ‘ProductBC OuterBarbie’
at BarbieIssue.hs:14:55-63
Possible fix:
use a standalone 'deriving instance' declaration,
so you can specify the instance context yourself
• When deriving the instance for (ProductBC OuterBarbie)
|
14 | , FunctorB, TraversableB, ProductB, ConstraintsB, ProductBC
| ^^^^^^^^^
BarbieIssue.hs:32:7: error:
• No instance for (barbies-1.1.2.1:Data.Barbie.Internal.Functor.GFunctorB
f
g
(Rec
(barbies-1.1.2.1:Data.Generics.GenericN.Param
0
f
(RecursiveBarbie
(barbies-1.1.2.1:Data.Generics.GenericN.Param 0 f)))
(f (RecursiveBarbie f)))
(Rec
(barbies-1.1.2.1:Data.Generics.GenericN.Param
0
g
(RecursiveBarbie
(barbies-1.1.2.1:Data.Generics.GenericN.Param 0 g)))
(g (RecursiveBarbie g))))
arising from the 'deriving' clause of a data type declaration
Possible fix:
use a standalone 'deriving instance' declaration,
so you can specify the instance context yourself
• When deriving the instance for (FunctorB RecursiveBarbie)
|
32 | , FunctorB, TraversableB, ProductB, ConstraintsB, ProductBC
| ^^^^^^^^
BarbieIssue.hs:32:17: error:
• Could not deduce (barbies-1.1.2.1:Data.Barbie.Internal.Traversable.GTraversableB
f
g
(Rec
(barbies-1.1.2.1:Data.Generics.GenericN.Param
0
f
(RecursiveBarbie
(barbies-1.1.2.1:Data.Generics.GenericN.Param 0 f)))
(f (RecursiveBarbie f)))
(Rec
(barbies-1.1.2.1:Data.Generics.GenericN.Param
0
g
(RecursiveBarbie
(barbies-1.1.2.1:Data.Generics.GenericN.Param 0 g)))
(g (RecursiveBarbie g))))
arising from the 'deriving' clause of a data type declaration
from the context: Applicative t
bound by the deriving clause for ‘TraversableB RecursiveBarbie’
at BarbieIssue.hs:32:17-28
Possible fix:
use a standalone 'deriving instance' declaration,
so you can specify the instance context yourself
• When deriving the instance for (TraversableB RecursiveBarbie)
|
32 | , FunctorB, TraversableB, ProductB, ConstraintsB, ProductBC
| ^^^^^^^^^^^^
BarbieIssue.hs:32:31: error:
• No instance for (barbies-1.1.2.1:Data.Barbie.Internal.Product.GProductB
f
g
(M1
C
('MetaCons "MoreBarbie" 'PrefixI 'False)
(M1
S
('MetaSel
'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy)
(Rec
(barbies-1.1.2.1:Data.Generics.GenericN.Param
0
f
(RecursiveBarbie
(barbies-1.1.2.1:Data.Generics.GenericN.Param 0 f)))
(f (RecursiveBarbie f))))
:+: M1 C ('MetaCons "ABarbie" 'PrefixI 'False) U1)
(M1
C
('MetaCons "MoreBarbie" 'PrefixI 'False)
(M1
S
('MetaSel
'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy)
(Rec
(barbies-1.1.2.1:Data.Generics.GenericN.Param
0
g
(RecursiveBarbie
(barbies-1.1.2.1:Data.Generics.GenericN.Param 0 g)))
(g (RecursiveBarbie g))))
:+: M1 C ('MetaCons "ABarbie" 'PrefixI 'False) U1)
(M1
C
('MetaCons "MoreBarbie" 'PrefixI 'False)
(M1
S
('MetaSel
'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy)
(Rec
(barbies-1.1.2.1:Data.Generics.GenericN.Param
0
(Data.Functor.Product.Product f g)
(RecursiveBarbie
(barbies-1.1.2.1:Data.Generics.GenericN.Param
0 (Data.Functor.Product.Product f g))))
(Data.Functor.Product.Product
f g (RecursiveBarbie (Data.Functor.Product.Product f g)))))
:+: M1 C ('MetaCons "ABarbie" 'PrefixI 'False) U1))
arising from the 'deriving' clause of a data type declaration
Possible fix:
use a standalone 'deriving instance' declaration,
so you can specify the instance context yourself
• When deriving the instance for (ProductB RecursiveBarbie)
|
32 | , FunctorB, TraversableB, ProductB, ConstraintsB, ProductBC
| ^^^^^^^^
BarbieIssue.hs:32:31: error:
• No instance for (barbies-1.1.2.1:Data.Barbie.Internal.Product.GProductB
f
f
(M1
C
('MetaCons "MoreBarbie" 'PrefixI 'False)
(M1
S
('MetaSel
'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy)
(Rec
(barbies-1.1.2.1:Data.Generics.GenericN.Param
0
f
(RecursiveBarbie
(barbies-1.1.2.1:Data.Generics.GenericN.Param 0 f)))
(f (RecursiveBarbie f))))
:+: M1 C ('MetaCons "ABarbie" 'PrefixI 'False) U1)
(M1
C
('MetaCons "MoreBarbie" 'PrefixI 'False)
(M1
S
('MetaSel
'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy)
(Rec
(barbies-1.1.2.1:Data.Generics.GenericN.Param
0
f
(RecursiveBarbie
(barbies-1.1.2.1:Data.Generics.GenericN.Param 0 f)))
(f (RecursiveBarbie f))))
:+: M1 C ('MetaCons "ABarbie" 'PrefixI 'False) U1)
(M1
C
('MetaCons "MoreBarbie" 'PrefixI 'False)
(M1
S
('MetaSel
'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy)
(Rec
(barbies-1.1.2.1:Data.Generics.GenericN.Param
0
(Data.Functor.Product.Product f f)
(RecursiveBarbie
(barbies-1.1.2.1:Data.Generics.GenericN.Param
0 (Data.Functor.Product.Product f f))))
(Data.Functor.Product.Product
f f (RecursiveBarbie (Data.Functor.Product.Product f f)))))
:+: M1 C ('MetaCons "ABarbie" 'PrefixI 'False) U1))
arising from the 'deriving' clause of a data type declaration
Possible fix:
use a standalone 'deriving instance' declaration,
so you can specify the instance context yourself
• When deriving the instance for (ProductB RecursiveBarbie)
|
32 | , FunctorB, TraversableB, ProductB, ConstraintsB, ProductBC
| ^^^^^^^^
BarbieIssue.hs:32:41: error:
• Could not deduce (barbies-1.1.2.1:Data.Barbie.Internal.Constraints.GConstraintsB
c
f
(Rec
(barbies-1.1.2.1:Data.Generics.GenericN.Param
0
barbies-1.1.2.1:Data.Barbie.Internal.Constraints.X
(RecursiveBarbie
(barbies-1.1.2.1:Data.Generics.GenericN.Param
0 barbies-1.1.2.1:Data.Barbie.Internal.Constraints.X)))
(barbies-1.1.2.1:Data.Barbie.Internal.Constraints.X
(RecursiveBarbie
barbies-1.1.2.1:Data.Barbie.Internal.Constraints.X)))
(Rec
(barbies-1.1.2.1:Data.Generics.GenericN.Param
0
f
(RecursiveBarbie
(barbies-1.1.2.1:Data.Generics.GenericN.Param 0 f)))
(f (RecursiveBarbie f)))
(Rec
(barbies-1.1.2.1:Data.Generics.GenericN.Param
0
(Data.Functor.Product.Product
(barbies-1.1.2.1:Data.Barbie.Internal.Dicts.Dict c) f)
(RecursiveBarbie
(barbies-1.1.2.1:Data.Generics.GenericN.Param
0
(Data.Functor.Product.Product
(barbies-1.1.2.1:Data.Barbie.Internal.Dicts.Dict c) f))))
(Data.Functor.Product.Product
(barbies-1.1.2.1:Data.Barbie.Internal.Dicts.Dict c)
f
(RecursiveBarbie
(Data.Functor.Product.Product
(barbies-1.1.2.1:Data.Barbie.Internal.Dicts.Dict c) f)))))
arising from the 'deriving' clause of a data type declaration
from the context: AllB c RecursiveBarbie
bound by the deriving clause for ‘ConstraintsB RecursiveBarbie’
at BarbieIssue.hs:32:41-52
Possible fix:
use a standalone 'deriving instance' declaration,
so you can specify the instance context yourself
• When deriving the instance for (ConstraintsB RecursiveBarbie)
|
32 | , FunctorB, TraversableB, ProductB, ConstraintsB, ProductBC
| ^^^^^^^^^^^^
BarbieIssue.hs:32:55: error:
• Could not deduce (barbies-1.1.2.1:Data.Barbie.Internal.ProductC.GProductBC
c
(M1
C
('MetaCons "MoreBarbie" 'PrefixI 'False)
(M1
S
('MetaSel
'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy)
(Rec
(barbies-1.1.2.1:Data.Generics.GenericN.Param
0
barbies-1.1.2.1:Data.Barbie.Internal.Constraints.X
(RecursiveBarbie
(barbies-1.1.2.1:Data.Generics.GenericN.Param
0 barbies-1.1.2.1:Data.Barbie.Internal.Constraints.X)))
(barbies-1.1.2.1:Data.Barbie.Internal.Constraints.X
(RecursiveBarbie
barbies-1.1.2.1:Data.Barbie.Internal.Constraints.X))))
:+: M1 C ('MetaCons "ABarbie" 'PrefixI 'False) U1)
(M1
C
('MetaCons "MoreBarbie" 'PrefixI 'False)
(M1
S
('MetaSel
'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy)
(Rec
(barbies-1.1.2.1:Data.Generics.GenericN.Param
0
(barbies-1.1.2.1:Data.Barbie.Internal.Dicts.Dict c)
(RecursiveBarbie
(barbies-1.1.2.1:Data.Generics.GenericN.Param
0 (barbies-1.1.2.1:Data.Barbie.Internal.Dicts.Dict c))))
(barbies-1.1.2.1:Data.Barbie.Internal.Dicts.Dict
c
(RecursiveBarbie
(barbies-1.1.2.1:Data.Barbie.Internal.Dicts.Dict c)))))
:+: M1 C ('MetaCons "ABarbie" 'PrefixI 'False) U1))
arising from the 'deriving' clause of a data type declaration
from the context: AllB c RecursiveBarbie
bound by the deriving clause for ‘ProductBC RecursiveBarbie’
at BarbieIssue.hs:32:55-63
Possible fix:
use a standalone 'deriving instance' declaration,
so you can specify the instance context yourself
• When deriving the instance for (ProductBC RecursiveBarbie)
|
32 | , FunctorB, TraversableB, ProductB, ConstraintsB, ProductBC
|
{ nixpkgs ? import <nixpkgs> {}, compiler ? "ghc865" }:
let
inherit (nixpkgs) pkgs;
ghc = pkgs.haskell.packages.${compiler}.ghcWithPackages (ps: with ps; [
barbies
]);
in
pkgs.stdenv.mkDerivation {
name = "barbies-env";
buildInputs = [ ghc ];
shellHook = "eval $(egrep ^export ${ghc}/bin/ghc)";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment