Skip to content

Instantly share code, notes, and snippets.

@michalrus
Created August 19, 2018 17:31
Show Gist options
  • Save michalrus/67fbf9be1a187677e1d6ffa5a7a7a09f to your computer and use it in GitHub Desktop.
Save michalrus/67fbf9be1a187677e1d6ffa5a7a7a09f to your computer and use it in GitHub Desktop.
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE StrictData #-}
{-
Something very similar to this works on 8.2.2, I have it in a
(non-free) codebase, but can’t quite minimize it… Hmm.
It stopped working when I updated that codebase’s compiler to 8.4.3.
-}
module Main where
data AB = A | B
class SomeClass (ab :: AB) where
data SomeData ab
instance SomeClass 'A where
data SomeData 'A = SomeData'A{someField :: Int} deriving Show
instance SomeClass 'B where
data SomeData 'B = SomeData'B{someField :: Int}
main :: IO ()
main = print SomeData'A{someField = 5}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment