Skip to content

Instantly share code, notes, and snippets.

@ramirez7
Last active December 21, 2022 20:05
Show Gist options
  • Select an option

  • Save ramirez7/1fbcc07cf838bac7447ef7a566f9469c to your computer and use it in GitHub Desktop.

Select an option

Save ramirez7/1fbcc07cf838bac7447ef7a566f9469c to your computer and use it in GitHub Desktop.
TF effectively returning c => t
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE ConstraintKinds #-}
import Data.Kind (Type, Constraint)
data CT (c :: Type -> Constraint) t
type family TF t :: Type where
TF Int = CT Show Int
TF String = CT Read String
useIt :: forall t c a. TF t ~ CT c t => c a => a -> t
useIt = error "I can't actually do anything with this type signature"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment