Skip to content
GitLab
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 5,244
    • Issues 5,244
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 567
    • Merge requests 567
  • 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 CompilerGlasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #14131
Closed
Open
Issue created Aug 16, 2017 by Icelandjack@IcelandjackReporter

Difference between newtype and newtype instance

This works

{-# Language RankNTypes, PolyKinds, GADTs #-}

newtype Nat :: (k -> *) -> (k -> *) -> * where
  Nat :: (forall xx. f xx -> g xx) -> Nat f g

but this

{-# Language RankNTypes, PolyKinds, GADTs, TypeFamilies #-}

data family Nat :: k -> k -> *

newtype instance Nat :: (k -> *) -> (k -> *) -> * where
  Nat :: (forall xx. f xx -> g xx) -> Nat f g

fails on GHC 8.3.20170815, and requires a forall k. to work

$ ./ghc-stage2 -ignore-dot-ghci --interactive /tmp/kind.hs 
GHCi, version 8.3.20170815: http://www.haskell.org/ghc/  :? for help
[1 of 1] Compiling Main             ( /tmp/kind.hs, interpreted )

/tmp/kind.hs:5:26: error: Not in scope: type variable ‘k’
  |
5 | newtype instance Nat :: (k -> *) -> (k -> *) -> * where
  |                          ^

/tmp/kind.hs:5:38: error: Not in scope: type variable ‘k’
  |
5 | newtype instance Nat :: (k -> *) -> (k -> *) -> * where
  |                                      ^
Failed, 0 modules loaded.

Related to #12369 (closed)?

Trac metadata
Trac field Value
Version 8.2.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking