Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
GHC
GHC
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,272
    • Issues 4,272
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 413
    • Merge Requests 413
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Security & Compliance
    • Security & Compliance
    • Dependency List
    • License Compliance
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #14763

Closed
Open
Opened Feb 05, 2018 by Ryan Scott@RyanGlScottMaintainer

GHC 8.4.1-alpha regression with FunctionalDependencies

This regression prevents esqueleto-2.5.3 from building with GHC 8.4.1. Here is a minimized example of the problem:

{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE MultiParamTypeClasses #-}
module Bug where

data Value a = Value a

data SomeValue expr where
  SomeValue :: Esqueleto query expr backend => expr (Value a) -> SomeValue expr

class Esqueleto (query :: * -> *) (expr :: * -> *) backend
        | query -> expr backend, expr -> query backend

data SqlQuery a

data SqlBackend

data SqlExpr a where
  ECompositeKey :: SqlExpr (Value a)

instance Esqueleto SqlQuery SqlExpr SqlBackend

match' :: SomeValue SqlExpr -> a
match' (SomeValue ECompositeKey) = undefined

On GHC 8.2.2, this typechecks without issue. On GHC 8.4.1-alpha (version 8.4.0.20180204), this fails with:

$ /opt/ghc/8.4.1/bin/ghci Bug.hs 
GHCi, version 8.4.0.20180204: http://www.haskell.org/ghc/  :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
[1 of 1] Compiling Bug              ( Bug.hs, interpreted )

Bug.hs:25:19: error:
    • Could not deduce: query ~ SqlQuery
        arising from a functional dependency between:
          constraint ‘Esqueleto query SqlExpr backend’
            arising from a pattern with constructor:
                           SomeValue :: forall (query :: * -> *) (expr :: * -> *) backend a.
                                        Esqueleto query expr backend =>
                                        expr (Value a) -> SomeValue expr,
                         in an equation for ‘match'’
          instance ‘Esqueleto SqlQuery SqlExpr SqlBackend’ at Bug.hs:22:10-46
      from the context: Value a1 ~ Value a2
        bound by a pattern with constructor:
                   ECompositeKey :: forall a. SqlExpr (Value a),
                 in an equation for ‘match'’
        at Bug.hs:25:19-31
      ‘query’ is a rigid type variable bound by
        a pattern with constructor:
          SomeValue :: forall (query :: * -> *) (expr :: * -> *) backend a.
                       Esqueleto query expr backend =>
                       expr (Value a) -> SomeValue expr,
        in an equation for ‘match'’
        at Bug.hs:25:9-31
      Inaccessible code in
        a pattern with constructor:
          ECompositeKey :: forall a. SqlExpr (Value a),
        in an equation for ‘match'’
    • In the pattern: ECompositeKey
      In the pattern: SomeValue ECompositeKey
      In an equation for ‘match'’:
          match' (SomeValue ECompositeKey) = undefined
   |
25 | match' (SomeValue ECompositeKey) = undefined
   |                   ^^^^^^^^^^^^^
Edited Mar 10, 2019 by Ryan Scott
Assignee
Assign to
8.4.1
Milestone
8.4.1 (Past due)
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#14763