RE: type synonyms in instances...

Actually I lied. You need the -fglasgow-exts flag.
Yes, I should have tried it before I posted, I just remembered reading in the manual that type synonyms were excluded... But on re reading it actually said partial applications of type synonyms were excluded, which does not affect what I wanted to do... It just tidies up a few long instances. Keean.

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.
participants (2)
-
MR K P SCHUPKE
-
Sven Panne