Skip to content

Instantly share code, notes, and snippets.

@dmwit
Created October 25, 2019 20:17
Show Gist options
  • Save dmwit/0bf2b43eaf537066d7c1493a2beeb7e8 to your computer and use it in GitHub Desktop.
Save dmwit/0bf2b43eaf537066d7c1493a2beeb7e8 to your computer and use it in GitHub Desktop.
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE TypeFamilies #-}
import GHC.Types
class Foo f where
type Ctx f i :: Constraint
extract :: Ctx f i => i -> f i -> String
newtype Los i = Los [String] deriving (Eq, Ord, Read, Show)
instance Foo Los where
type Ctx Los i = i ~ Int
extract i (Los ss) = ss !! i
data Extractor f i = Extractor
{ idx :: i
, unrelated :: f i
} deriving (Eq, Ord, Read, Show)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment