Opened 18 months ago

Last modified 16 months ago

#14983 new task

Have custom type errors imply Void

Reported by: Iceland_jack Owned by:
Priority: lowest Milestone:
Component: Compiler Version: 8.5
Keywords: CustomTypeErrors QuantifiedConstraints Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description (last modified by Iceland_jack)

This is a very minor issue, but TypeError (CustomTypeErrors) should entail a constraint like

import Data.Void

class (forall x. x) => No where
  no :: Void

so users don't have to use undefined or error ..:

instance TypeError (Text "Can't show functions") => Show (a -> b) where
  show :: (a -> b) -> String
  show = no & absurd

Change History (3)

comment:1 Changed 18 months ago by Iceland_jack

Description: modified (diff)

comment:2 Changed 18 months ago by RyanGlScott

Keywords: QuantifiedConstraints wipT2893 added

Can't you just do this?

{-# LANGUAGE DataKinds #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE QuantifiedConstraints #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE UndecidableSuperClasses #-}
module Foo where

import Data.Void
import GHC.TypeLits

class (forall x. x) => No where
  no :: Void

class (TypeError a, forall x. x) => MyTypeError a

instance MyTypeError (Text "Can't show functions") => Show (a -> b) where
  show = absurd no

comment:3 Changed 16 months ago by RyanGlScott

Keywords: wipT2893 removed
Note: See TracTickets for help on using tickets.