Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,868
    • Issues 4,868
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 456
    • Merge requests 456
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #18150
Closed
Open
Created May 06, 2020 by Koz Ross@kozross

QuantifiedConstraints cannot refer to KnownNat

Summary

If you attempt to write a quantified constraint involving KnownNat, GHC will inform you that Class KnownNat does not support user-specified instances. Given that no instances are being defined here (see 'Steps to reproduce' for an example), this is at least an unclear error message. It's also strange that it's not possible to express quantified constraints with KnownNat.

Steps to reproduce

Attempt to compile the following code:

{-# LANGUAGE DataKinds #-}
{-# LANGUAGE QuantifiedConstraints #-}
{-# LANGUAGE TypeFamilies #-}

module Baz where

import Data.Kind (Type)
import GHC.TypeNats (KnownNat, Nat)

class (forall n. KnownNat n => KnownNat (f n)) => Foo (f :: Nat -> Nat) where
  type Bar n :: Nat

This will emit the error message described in the summary.

Expected behavior

Either to compile, or to give an error message more indicative of what the true problem is.

Environment

  • GHC version used: 8.10.1

Optional:

  • Operating System: GNU/Linux
  • System Architecture: x86_64
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking