Skip to content

Instantly share code, notes, and snippets.

@chisui
Last active June 23, 2021 11:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chisui/7b558c2d63e3a7fcffc67ae714b69714 to your computer and use it in GitHub Desktop.
Save chisui/7b558c2d63e3a7fcffc67ae714b69714 to your computer and use it in GitHub Desktop.
user-specified instance
src/Some.hs:17:16-77: error:
• Class ‘Typeable’ does not support user-specified instances
• In the quantified constraint ‘forall x. c x => Typeable x’
In the type signature:
extractSome :: (Typeable a, forall x. c x => Typeable x) =>
Some c -> Maybe a
|
26 | extractSome :: (Typeable a, forall x. c x => Typeable x) => Some c -> Maybe a
|
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE QuantifiedConstraints #-}
{-# LANGUAGE ConstraintKinds #-}
module Some where
import Data.Typeable
import Data.Kind
data Some c where
Some :: c a => a -> Some c
extractSome :: (Typeable a, forall x. c x => Typeable x) => Some c -> Maybe a
extractSome (Some a) = cast a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment