[Haskell-cafe] Identity operator for types

Juan Miguel Vilar jvilar at uji.es
Fri May 17 09:48:33 UTC 2019

Hi, Café:

I am not sure how to make the question, but the idea is to have a type
operator that returns the same type. Let me show what I need. I have
some type like this:

data Example f t = Example (f t)

So if I want a type variable that contains a list of integers, I can use
Example [] Int and then treat the content like a list:

f :: Example [] Int -> Int
f (Example l) = length l

Now, the problem is what can I do to have a type that contains a
single Int? Is there a sort of id for types so that I can write

f :: Example ?? Int -> Int
f (Example i) = 2 * i

Thanks in advance

Juan Miguel Vilar

Juan Miguel Vilar Torres
Profesor titular de universidad
Departamento de Lenguajes y Sistemas Informáticos
Escuela Superior de Tecnología y Ciencias Experimentales
Universitat Jaume I
Av. de Vicent Sos Baynat s/n
12071 Castelló de la Plana (Spain)
Tel: +34 964 72 8365
Fax: +34 964 72 8435
jvilar at uji.es

More information about the Haskell-Cafe mailing list