MR K P SCHUPKE wrote:
[...] It just tidies up a few long instances.
... and results in far better documentation when Haddock is used. That's just
another use for the oh-so-ugly cpp. :-] A small excerpt from my OpenGL
binding:
-- OpenGL/include/HsOpenGLTypes.h -------------------------------------------
...
/* Using a type synonym in an instance head is not Haskell98, but it is much
better for a useful documentation. */
#ifdef __HADDOCK__
#define GLbyte_ GLbyte
#define GLdouble_ GLdouble
#define GLfloat_ GLfloat
#define GLint_ GLint
#define GLshort_ GLshort
#define GLubyte_ GLubyte
#define GLuint_ GLuint
#define GLushort_ GLushort
#else
#define GLbyte_ HTYPE_GLBYTE
#define GLdouble_ HTYPE_GLDOUBLE
#define GLfloat_ HTYPE_GLFLOAT
#define GLint_ HTYPE_GLINT
#define GLshort_ HTYPE_GLSHORT
#define GLubyte_ HTYPE_GLUBYTE
#define GLuint_ HTYPE_GLUINT
#define GLushort_ HTYPE_GLUSHORT
#endif
-- -OpenGL/Graphics/Rendering/OpenGL/GL/BasicTypes.hs -----------------------
...
-- | Signed 2\'s complement binary integer (min. 32 bits)
type GLint = HTYPE_GLINT
-- OpenGL/Graphics/Rendering/OpenGL/GL/Rectangles.hs ------------------------
...
instance Rect GLint_ where
...
-----------------------------------------------------------------------------
The HTYPE_FOO are autoconf-detected types like Int32 etc. Without this cpp-trickery
the documentation for the classes/instances/types involved would be much worse.
It would be nice if the next Haskell standard supported this more directly.
Cheers,
S.
_______________________________________________
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users