[Haskell-cafe] type level function with different return kinds
Tom Ellis
tom-lists-haskell-cafe-2023 at jaguarpaw.co.uk
Sun Apr 6 16:07:49 UTC 2025
On Sun, Apr 06, 2025 at 12:27:04AM +0200, Zoran BoĆĄnjak wrote:
> is it possible to write a type/kind level function that returns types of
> different kinds for different inputs. Either by using open/closed type
> families, a typeclass, extensions or any other type level magic.
The way you do this at the type level is with Dynamic:
https://www.stackage.org/haddock/lts-23.17/base-4.19.2.0/Data-Dynamic.html#t:Dynamic
Or equivalently, something like
data SomeTypeable where
MkSomeTypeable :: Typeable a => a -> SomeTypeable
So if you can work out how to promote one of those to the kind level
then yes. If not then probably no!
Tom
More information about the Haskell-Cafe
mailing list