All Projects â†’ isovector â†’ Same Same

isovector / Same Same

Licence: mit
🤳 ignore the differences between `a` and `Identity a`

Programming Languages

haskell
3896 projects

same-same: ignore the differences between a and Identity a.

Build Status | Hackage

Dedication

The ego is only an illusion, but a very influential one. Letting the ego-illusion become your identity can prevent you from knowing your true self. Ego, the false idea of believing that you are what you have or what you do, is a backwards way of assessing and living life.

Wayne Dyer

Synopsis

I think higher-kinded data is a pretty cool guy. eh reuses datatypes and doesn't afraid of anything. But working with HKD isn't everything it's cracked up to be -- it makes deriving instances hard, requires janky type families, and in general doesn't fill you with any sense of joy.

Enter same-same: a compiler plugin that provides proofs of a ~ Identity a and makes working with HKD a little less shit. Armed with this proof, we're able to get rid of the HKD type family, and thus regain our derived instances.

Unsoundness

This plugin is a teensy little bit completely unsound and when used for evil, is capable of producing forall a b. a ~ b proofs. Fortunately, you need to be actively trying to accomplish such a feat, and so you're probably going to be a-ok.

Modules that haven't loaded the plugin are not affected by this "feature."

Example

{-# OPTIONS_GHC -fplugin=Data.Functor.Identity.Plugin #-}

module Test where

import Data.Functor.Identity

data X f = X
  { foo :: f Int
  }

getFoo :: X Identity -> Int
getFoo = foo

Contact

Please reports bugs and missing features at the GitHub bugtracker. This is also where you can find the source code.

same-same was written by Sandy Maguire and is licensed under a permissive MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].