[Haskell-cafe] Stack ADT?

Daniel Fischer daniel.is.fischer at web.de
Thu Feb 4 17:40:07 EST 2010


Am Donnerstag 04 Februar 2010 23:18:34 schrieb Daniel Peebles:
> > data Stack a   = EmptyStk | Stk a (Stack a)
>
> I find it amusing that the book defined a type that is exactly
> isomorphic to the standard list (EmptyStk === [] and Stk === (:)). I
> guess it's just for clarity?

Also type safety, I think.
However, I prefer

newtype Stack a = Stack [a]


More information about the Haskell-Cafe mailing list