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,251
    • Issues 4,251
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 391
    • Merge Requests 391
  • 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
  • #18828

Closed
Open
Opened Oct 11, 2020 by Icelandjack@IcelandjackReporter

:kind! fails to expand type synonyms

Let me know if this is expected behaviour, I want to return the object type of a category Cat ob which is what I use as a shorthand for ob -> ob -> Type.

I want to be able to write Object (->) and get out Type, when written as a type synonym the call to Object (->) gets stuck:

{-# Language ConstraintKinds          #-}
{-# Language DataKinds                #-}
{-# Language GADTs                    #-}
{-# Language PolyKinds                #-}
{-# Language RankNTypes               #-}
{-# Language StandaloneKindSignatures #-}
{-# Language TypeFamilies             #-}
{-# Language TypeOperators            #-}

import Data.Kind

type Cat :: Type -> Type
type Cat ob = ob -> ob -> Type

type Dict :: Constraint -> Type
data Dict cls where
 Dict :: cls => Dict cls

type    (:-) :: Cat Constraint
newtype cls1 :- cls2 where
 Sub :: (cls1 => Dict cls2) -> (cls1 :- cls2)

-- > :k! Object ((->) :: Cat Type)
-- = Object (->)
--
-- > import Data.Type.Equality
-- > :k! Object (:~:)
-- = Object (:~:)
--
-- > :k! Object Op
-- = Object Op
--
-- > :k! Object (:-)
-- = Object (:-)
type Object :: Cat ob -> Type
type Object (cat :: ob -> ob -> Type) = ob

It works with a type family, what is the difference here?

-- > :k! Object (->)
-- = *
--
-- > :k! forall ob. Object ((:~:) :: Cat ob)
-- = ob
--
-- > :k! Object Op
-- = *
--
-- > :k! Object (:-)
-- = Constraint
type
  Object :: Cat ob -> Type
type family
  Object cat where
  Object @ob cat = ob

Tested with GHC 9.0.0.20200925.

Edited Oct 12, 2020 by Simon Peyton Jones
Assignee
Assign to
9.2.1
Milestone
9.2.1
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#18828