Last active
April 26, 2020 23:39
-
-
Save greatBigDot/06f5bf85e01689e4132d48cb95ab593c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {-# LANGUAGE PolyKinds, DataKinds, TypeApplications, TypeOperators, KindSignatures, GADTs, TypeFamilies, ScopedTypeVariables #-} | |
| {-# LANGUAGE TemplateHaskell #-} | |
| -- ^ more extensions might be needed to do what I want to do, idk | |
| -- Defunctionalized higher-order data constructors--are they possible? | |
| module DefunHigherDataCons where | |
| import Data.Kind | |
| import Data.Singletons.TH | |
| data Endo :: Type -> Type where | |
| -- A higher-order data constructor: | |
| MkEndo :: (a -> a) -> Endo a | |
| -- ^ Because of -XDataKinds, this also creates the /type constructor/ `'MkEndo :: (a -> a) -> Endo a`. | |
| -- But when doing type-level programming, a more useful type constructor would be `MkEndoSym1 :: (a ~> a) -> Endo a`. | |
| -- Wrapping the above in `$(singletons [d| ... |])` causes errors, as do both of these: | |
| -- $(genSingletons [''Endo]) | |
| -- $(genDefunSymbols [''Endo]) | |
| -- Which makes sense, since actually writing it out seems impossible. Is it? | |
| type family MkEndoSym1 (f :: a ~> a) :: a where | |
| MkEndoSym1 f = ??? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment