Using a few extensions, I can do something like this:
{-# LANGUAGE GADTs #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE DataKinds #-}
type family TF (a :: Bool) where
TF 'True = Int
TF 'False = Double
data D a where
D :: TF a -> D a
Notice the constructor D
can work in two ways. Either:
D :: Int -> D 'True
or
D :: Double -> D 'False
Using this pattern, I can completely change the arguments to the constructor depending on it's type, whilst reusing it's name.
However, I'd also like the number of arguments to depend on it's name.
I know I could just replace some arguments with ()
or Void
but I'd rather remove them entirely.
Is there anyway to do this?