[Haskell-cafe] throwing sugar into the void.

Einar Karttunen ekarttun at cs.helsinki.fi
Sun May 7 03:53:27 EDT 2006


On 07.05 01:12, Marc A. Ziegert wrote:
> data Type a
> typeOf :: a -> Type a
> typeOf = undefined
> #define TYPE(a) (undefined::Type (a))
> ...
> sizeOf :: (Storable a) => Type a -> Int

I think the name Proxy is used for this in other places.

data Proxy a = Proxy
class Storable a where
    ...
    sizeOf :: Proxy a -> Int

proxy :: a -> Proxy a
proxy _ = Proxy

Note here that there are no undefined values used thus one does not need to be
careful with evaluation.

- Einar Karttunen


More information about the Haskell-Cafe mailing list