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,867
    • Issues 4,867
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 457
    • Merge requests 457
  • 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
  • #21328
Closed
Open
Created Apr 01, 2022 by Krzysztof Gogolewski@monoidalDeveloper

withDict and casts

This works:

{-# LANGUAGE TypeFamilies #-}
module M where

import GHC.Exts
import Type.Reflection

type family Id x
type instance Id x = x

cast :: forall a. TypeRep a -> (Typeable a => Int) -> Int
cast = withDict @(TypeRep a) @(Typeable a)

If I replace the type of cast with

cast :: forall a. Id (TypeRep a) -> (Typeable a => Int) -> Int

I get an error:

    Invalid instantiation of ‘withDict’ at type:
        Id (TypeRep a) -> (Typeable a -> Int) -> Int

Two problems:

(1) I understand withDict might not work with casts, but this code is explicitly passing type arguments to withDict. See also #19915 / #20000.

(2) Typeable a -> in the error message should be Typeable a =>.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking