https://wiki.haskell.org/api.php?action=feedcontributions&user=Carolin&feedformat=atomHaskellWiki - User contributions [en]2024-03-28T13:43:04ZUser contributionsMediaWiki 1.35.5https://wiki.haskell.org/index.php?title=OpenGL&diff=34398OpenGL2010-04-02T11:25:59Z<p>Carolin: </p>
<hr />
<div>{{Stub}}<br />
This is a stub page for Haskell's OpenGL and GLUT bindings. It is meant as a starting point to replace the outdated and misleading documentation at the<br />
[http://www.haskell.org/HOpenGL-old/ old page].<br />
<br />
First, note that the implementation is far more up-to-date than that old page suggested (originally, it was quite useful, but the page hasn't kept up with the implementation for a long time now).<br />
<br />
== References == <br />
* [http://www.haskell.org/mailman/listinfo/hopengl the HOpenGL mailing list]<br />
<br />
* [http://hackage.haskell.org/packages/archive/OpenGL/latest/doc/html/ the API docs for the OpenGL binding]<br />
<br />
* [http://hackage.haskell.org/packages/archive/GLUT/latest/doc/html/ the API docs for the GLUT binding]<br />
<br />
* [http://darcs.haskell.org/packages/OpenGL/ the darcs repo with the sources for the OpenGL binding]<br />
<br />
* [http://darcs.haskell.org/packages/GLUT/ the darcs repo with the sources for the GLUT binding]<br />
<br />
In particular, note that the [http://darcs.haskell.org/packages/GLUT/examples/ examples/] directory in the GLUT repo contains lots of examples, including translations of the red book examples.<br />
<br />
(Note: at least some of these resources appear to be missing from [http://darcs.haskell.org/packages/ /packages], but there are copies at [http://darcs.haskell.org/ghc-6.8/packages/ /ghc-6.8/packages].)<br />
<br />
Both the API documentation and the examples are best studied with the [http://www.opengl.org/documentation/specs/ original specs] and the original [http://www.opengl.org/documentation/red_book/ red book] examples at hand. An index of the examples from v1.1 of the red book, with screen shots, can be found [http://www.opengl.org/resources/code/samples/redbook/ here].<br />
<br />
== Projects using the OpenGL bindings == <br />
<br />
* [http://www.increpare.com/2008/11/endless-cavern/ Endless Cavern], a 2D procedurally-generated exploration game.<br />
* [[Frag]], a 3D first-person shooter game.<br />
* [http://www.geocities.jp/takascience/haskell/monadius_en.html Monadius], a 2D scrolling arcade game.<br />
* [http://roguestar.downstairspeople.org/ Roguestar], a roguelike adventure game using 3D graphics.<br />
* [http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Shu-thing Shu-thing], a 2D scroling arcade game.<br />
* [http://home.arcor.de/chr_bauer/topkata.html Topkata], a jumping ball puzzle game.<br />
* [http://www.comp.leeds.ac.uk/funvis/ PolyFunViz], a toolkit for scientific visualization (e.g. surfaces, flows, contours, volumes)<br />
* [http://raincat.bysusanlin.com Raincat], a 2d puzzle game<br />
<br />
== HOpenGL Resources == <br />
<br />
* [[OpenGLTutorial1]] and [[OpenGLTutorial2]]<br />
* [http://www.renci.org/publications/tutorials/BeautifulCode.pdf Beautiful Code, Compelling Evidence: Functional Programming for Information Visualization and Visual Analytics] - Writing visualizations using OpenGL or Cairo (PDF)<br />
* [http://www.cin.ufpe.br/~haskell/hopengl/ Andre Furtado's nice tutorial] written in 2001 (bitrotted)<br />
* [http://www.haskell.org/~pairwise/HOpenGL/HOpenGL.html#texLoad Spriting with HOpenGL], David Morra<br />
<br />
== OpenGL Resources ==<br />
<br />
* [http://www.opengl.org/resources/faq/technical/ OpenGL FAQ and Toubleshooting Guide] Assumes some knowledge of OpenGL. Good for those who have written something but want to avoid common pitfalls.<br />
** [http://www.opengl.org/resources/faq/technical/gettingstarted.htm#0050 2.100: What is the general form of an OpenGL program?]<br />
<br />
== Getting Started ==<br />
<br />
* Windows users can read how to install OpenGL in the blog article [http://netsuperbrain.com/blog/posts/freeglut-windows-hopengl-hglut/ freeglut + Windows + HOpenGL + HGLUT]<br />
* assuming you know Haskell, any OpenGL tutorial of your choice should get you going (browsing the [http://www.opengl.org OpenGL] site is also a good idea)<br />
* use the [http://www.opengl.org/documentation/red_book/ Red Book], and its example code translations, to understand the small differences between OpenGL and HOpenGL<br />
* use the [http://www.opengl.org/documentation/specs/ OpenGL and GLUT specs] to find your way around the [http://hackage.haskell.org/packages/archive/OpenGL/latest/doc/html/ HOpenGL Haddock documentation]<br />
* use the [http://www.haskell.org/mailman/listinfo/hopengl HopenGL list] for questions and success stories<br />
<br />
== Additional software == <br />
* [http://hackage.haskell.org/package/OpenGLRaw OpenGLRaw]: A 1:1 mapping of OpenGL's C API, intended as a basis for a nicer interface<br />
* [http://hackage.haskell.org/package/StateVar StateVar]: This package contains state variables, which are references in the IO monad, like IORefs or parts of the OpenGL state<br />
* [http://hackage.haskell.org/package/ObjectName ObjectName]: Explicitly handled object names. This tiny package contains the class ObjectName, which corresponds to the general notion of explicitly handled identifiers for API objects, e.g. a texture object name in OpenGL or a buffer object name in OpenAL<br />
* [http://hackage.haskell.org/package/GLURaw GLURaw]: A raw binding for the OpenGL graphics system. GLURaw is a raw Haskell binding for the GLU 1.3 OpenGL utility library. It is basically a 1:1 mapping of GLU's C API, intended as a basis for a nicer interface<br />
* [[FTGL]]: Portable TrueType font rendering for OpenGL using the Freetype2 library<br />
* [http://hackage.haskell.org/cgi-bin/hackage-scripts/package/GLFW GLFW]: A binding for GLFW, An OpenGL Framework<br />
* [http://hackage.haskell.org/cgi-bin/hackage-scripts/package/GLUT GLUT]: A binding for the OpenGL Utility Toolkit<br />
* [http://hackage.haskell.org/cgi-bin/hackage-scripts/package/graphics-drawingcombinators graphics-drawingcombinators]: A functional interface to 2D drawing in OpenGL<br />
* [http://hackage.haskell.org/package/Tensor Tensor]: This package contains tensor data types and their instances for some basic type classes.<br />
* [http://hackage.haskell.org/package/GPipe GPipe]: A functional graphics API for programmable GPUs<br />
<br />
Somewhat related is [http://www.libsdl.org/ SDL], which is also based on OpenGL:<br />
* [http://hackage.haskell.org/cgi-bin/hackage-scripts/package/SDL SDL]: Binding to libSDL<br />
* [http://hackage.haskell.org/cgi-bin/hackage-scripts/package/SDL-gfx SDL-gfx]: Binding to libSDL_gfx<br />
* [http://hackage.haskell.org/cgi-bin/hackage-scripts/package/SDL-image SDL-image]: Binding to libSDL_image<br />
* [http://hackage.haskell.org/cgi-bin/hackage-scripts/package/SDL-mixer SDL-mixer]: Binding to libSDL_mixer<br />
* [http://hackage.haskell.org/cgi-bin/hackage-scripts/package/SDL-mpeg SDL-mpeg]: Binding to the SMPEG library <br />
* [http://essaywritingservices.org/custom-essay-writing.php custom writing company] <br />
* [http://cvresumewriters.com/onlineresume.php online resume writers]<br />
* [http://hackage.haskell.org/cgi-bin/hackage-scripts/package/SDL-ttf SDL-ttf]: Binding to libSDL_ttf<br />
<br />
To add sound to OpenGL applications:<br />
* [http://hackage.haskell.org/cgi-bin/hackage-scripts/package/OpenAL OpenAL]: A binding to the [[OpenAL]] cross-platform 3D audio API<br />
* [http://hackage.haskell.org/cgi-bin/hackage-scripts/package/ALUT ALUT]: A binding for the OpenAL Utility Toolkit<br />
<br />
A fork of HOpenGL:<br />
* [[OGL]]<br />
<br />
<br />
== Troubleshooting ==<br />
=== I can't display text with renderString ===<br />
It's probably because the text is displayed too big. Setting a much smaller scale factor before calling renderString should solve the problem.<br />
<haskell><br />
scale 0.001 0.001 (0.001∷GLfloat)<br />
renderString Roman "Test string"<br />
</haskell><br />
=== Animations flicker ===<br />
If you're not using DoubleBuffered display mode, turn that on. Also, you must set the display mode '''before''' creating the window you're going to be drawing in. To check if you've enabled double buffering use something like:<br />
<haskell><br />
db <- get doubleBuffered<br />
</haskell><br />
and set DoubleBuffered mode (before creating your windows!) like this:<br />
<haskell><br />
initialDisplayMode $= [DoubleBuffered]<br />
createWindow "My Window"<br />
</haskell><br />
You will also need to call [http://hackage.haskell.org/packages/archive/GLUT/latest/doc/html/Graphics-UI-GLUT-Window.html#v%3AswapBuffers <haskell>swapBuffers</haskell>] at the end of your draw function.<br />
<br />
=== The depth buffer doesn't work (things that are closer to the camera are occluded by things that are farther from the camera) ===<br />
<br />
Make sure that ''depthFunc'' is set:<br />
<haskell>depthFunc $= Just Less</haskell><br />
<br />
Furthermore, if you're using GLFW, the following var has to be greater than zero:<br />
<haskell>get (windowParam DepthBits)</haskell><br />
<br />
If DepthBits is 0, you probably forgot to initialize the window, like so:<br />
<haskell>openWindow size [DisplayDepthBits 16] Window</haskell><br />
<br />
Once you enable the depth buffer, you will need to clear it before each cycle of your drawing method:<br />
<haskell>clear [ColorBuffer, DepthBuffer]</haskell><br />
<br />
See also: [http://www.opengl.org/resources/faq/technical/depthbuffer.htm#0010 The OpenGL FAQ: 12.010 How do I make depth buffering work?]<br />
<br />
<br />
[[Category:Packages]]<br />
[[Category:Libraries]]</div>Carolinhttps://wiki.haskell.org/index.php?title=Learning_Haskell&diff=34397Learning Haskell2010-04-02T11:23:05Z<p>Carolin: </p>
<hr />
<div>__NOTOC__<br />
[[Category:Tutorials]]<br />
<center><br />
[[Image:LearningHaskell.gif]]<br />
</center><br />
<br />
This portal points to places where you can go if you want to learn Haskell. <br />
<br />
The [[Introduction|Introduction to Haskell]] on the Haskell website tells you what Haskell gives you: substantially increased programmer productivity, shorter, clearer, and more maintainable code, fewer errors, higher reliability, a smaller semantic gap between the programmer and the language, shorter lead times. There is an old but still relevant paper about [http://www.md.chalmers.se/~rjmh/Papers/whyfp.html Why Functional Programming Matters] by John Hughes. More recently, Sebastian Sylvan wrote an article about [[Why Haskell Matters]].<br />
<br />
There is also a [http://www.haskell.org/haskellwiki/Comparison table comparing Haskell to other functional languages]. Many questions about functional programming are answered by the [http://www.cs.nott.ac.uk/~gmh//faq.html comp.lang.functional FAQ].<br />
<br />
==Implementations==<br />
<br />
Here is an overview about Haskell implementations:<br />
<br />
{| border=1 cellspacing=0 cellpadding=5 bgcolor=#FFFFFF width=100%|<br />
|-<br />
| <br />
! Messages<br />
! Size<br />
! Tools<br />
! Remarks <br />
|-<br />
| [http://www.haskell.org/hugs/ Hugs]<br />
| +/-<br />
| ++<br />
| -<br />
| Fast compilation; used a lot for learning Haskell and rapid code development. See also [[WinHugs]].<br />
|-<br />
| [http://www.haskell.org/ghc/ GHC]<br />
| +<br />
| -<br />
| ++<br />
| Many language extensions; generated code is very fast. ''The most popular implementation.''<br />
|-<br />
| [http://www.cs.york.ac.uk/fp/nhc98/ NHC]<br />
| ?<br />
| +<br />
| ++<br />
| Profiling, debugging, tracing<br />
|-<br />
| [[Yhc]]<br />
| ?<br />
| +<br />
| ?<br />
| Compiles to bytecodes. Runtime easily portable. ''Still under heavy development.''<br />
|-<br />
| [http://www.cs.uu.nl/helium/ Helium]<br />
| ++<br />
| ++<br />
| -<br />
| No type classes (yet!) and thus incompatible with most material on this site. Made for teaching/learning.<br />
|}<br />
<br />
Detailed information on the implementations can be found in a [[Implementations|separate article]].<br />
<br />
== Material ==<br />
<br />
Below there are links to certain introductory material. If you want to dig deeper, see [[Books and tutorials]].<br />
<br />
=== Textbooks ===<br />
<br />
* [http://www.haskell.org/soe The Haskell School of Expression]<br />
* [http://www.cs.ukc.ac.uk/people/staff/sjt/craft2e/ Haskell: the Craft of Functional Programming]<br />
* [http://www.prenhall.com/allbooks/ptr_0134843460.html Introduction to Functional Programming using Haskell]<br />
* [http://books.cambridge.org/0521277248.htm An Introduction to Functional Programming Systems Using Haskell]<br />
* [http://www.iro.umontreal.ca/~lapalme/Algorithms-functional.html Algorithms: A functional programming approach]<br />
* [http://homepages.cwi.nl/~jve/HR/ The Haskell Road to Logic, Maths, and Programming]<br />
* [http://www.cs.nott.ac.uk/~gmh/book.html Programming in Haskell]<br />
<br />
=== Online tutorials ===<br />
<br />
* [[Meta-tutorial]]<br />
* [http://en.wikibooks.org/wiki/Haskell Haskell Wikibook] A long tutorial on Haskell that includes "Yet Another Haskell Tutorial", "Write Yourself a Scheme in 48 Hours" and "All about monads".<br />
* [http://www.cs.utah.edu/~hal/docs/daume02yaht.pdf YAHT - Yet Another Haskell Tutorial] (best tutorial available online, also [http://pub.hal3.name/daume02yaht.pdf here])<br />
* [http://www.cs.ou.edu/~rlpage/fpclassCurrent/textbook/haskell.shtml Two dozen short lessons]<br />
* [http://www.haskell.org/tutorial/ A Gentle Introduction to Haskell] - classic text, but not so gentle really :D<br />
* [ftp://ftp.geoinfo.tuwien.ac.at/navratil/HaskellTutorial.pdf Haskell-Tutorial]<br />
* [http://www.informatik.uni-bonn.de/~ralf/teaching/Hskurs_toc.html Online Haskell Course] (German)<br />
* [http://www.haskell.org/~pairwise/intro/intro.html Haskell for C Programmers]<br />
* [http://learnyouahaskell.com/ Learn You a Haskell for Great Good!] Beautiful, illustrated Haskell tutorial for programmers with less of a functional programming background.<br />
<br />
=== Advanced tutorials ===<br />
<br />
* [[Hitchhikers guide to Haskell]]<br />
* [http://halogen.note.amherst.edu/%7Ejdtang/scheme_in_48/tutorial/overview.html Write Yourself a Scheme in 48 Hours]<br />
* [http://research.microsoft.com/Users/simonpj/papers/marktoberdorf/ Tackling the Awkward Squad] (on I/O, interfacing to C, concurrency and exceptions)<br />
<br />
=== Debugging/profiling/optimization ===<br />
<br />
=== Monads ===<br />
<br />
* [http://sigfpe.blogspot.com/2006/08/you-could-have-invented-monads-and.html You Could Have Invented Monads! (And Maybe You Already Have.)]<br />
* [http://citeseer.ist.psu.edu/wadler95monads.html Monads for Functional Programming]<br />
* [http://www.haskell.org/all_about_monads/html/ All about monads]<br />
* [[IO inside|IO inside: down the Rabbit Hole]]<br />
* [http://spbhug.folding-maps.org/wiki/MonadsEn Monads]<br />
<br />
=== Type classes ===<br />
<br />
* [http://homepages.inf.ed.ac.uk/wadler/papers/class/class.ps.gz The paper that at first time introduced type classes and their implementation using dictionaries]<br />
* [[Research papers/Type systems#Type classes|More papers on the type classes]]<br />
<br />
=== Generic programming ===<br />
<br />
* [http://www.cs.vu.nl/boilerplate/#papers Scrap your boilerplate]<br />
<br />
=== Popular libraries ===<br />
<br />
* ByteStrings?<br />
* [http://www.cs.uu.nl/people/daan/download/parsec/parsec.html Parsec, a fast combinator parser]<br />
* [[Modern array libraries]]<br />
* [http://darcs.haskell.org/gtk2hs/docs/tutorial/Tutorial_Port/index.xhtml Gtk2Hs, the GUI library]<br />
<br />
=== Reference ===<br />
<br />
* [[HaskellNewbie|Haskell Newbie]]<br />
* [http://cs.anu.edu.au/Student/comp1100/haskell/tourofsyntax.html Tour of the Haskell Syntax]<br />
* [http://undergraduate.csse.uwa.edu.au/units/230.301/lectureNotes/tourofprelude.html A Tour of the Haskell Prelude (i.e. predefined functions)]<br />
* [http://zvon.org/other/haskell/Outputglobal/index.html Haskell Reference]<br />
* Haskell [[Reference card]]<br />
* [http://members.chello.nl/hjgtuyl/tourdemonad.html A tour of the Haskell Monad functions]<br />
* [http://www.cs.uu.nl/helium/docs/TourOfPrelude.html Tour of the Helium Prelude]<br />
* [http://www.cs.ukc.ac.uk/people/staff/sjt/craft2e/errors/allErrors.html Some common Hugs error messages]<br />
* [[Category:Idioms|Some Haskell Idioms]]<br />
* [http://www.haskell.org/hawiki Questions and Answers (old Haskell wiki)]<br />
* [http://blog.codeslower.com/2008/10/The-Haskell-Cheatsheet The Haskell Cheatsheet] - A reference card and mini-tutorial in one.<br />
<br />
=== Course material ===<br />
* [http://www.cs.chalmers.se/Cs/Grundutb/Kurser/funht/ Introduction to Functional Programming, Chalmers]<br />
* [http://www.cs.chalmers.se/Cs/Grundutb/Kurser/d1pt/d1pta/external.html Programming in Haskell, Chalmers]<br />
* [http://www.cs.chalmers.se/Cs/Grundutb/Kurser/afp/ Advanced Functional Programming, Chalmers]<br />
* [http://www.cs.chalmers.se/~koen/Aafp/ Advanced Advanced Functional Programming, Chalmers]<br />
* [http://essaywritingservices.org/book-report.php online book reports] of programming <br />
* [http://cvresumewriters.com/onlineresume.php certified resume writers]<br />
* [http://www.cs.caltech.edu/courses/cs11/material/haskell/index.html CS 11 Caltech]<br />
* [http://www.cs.uu.nl/docs/vakken/lfp/ Functional programming]: course notes ([http://www.cs.uu.nl/~jeroen/courses/fp-eng.pdf English], [http://www.cs.uu.nl/~jeroen/courses/fp-nl.pdf Dutch], [http://www.cs.uu.nl/~jeroen/courses/fp-sp.pdf Spanish]), slides in Dutch<br />
* [http://www.cse.unsw.edu.au/~cs1011/ CS1011]: Tutorials, lab exercises and solutions</div>Carolinhttps://wiki.haskell.org/index.php?title=Leksah_FAQ&diff=34396Leksah FAQ2010-04-02T10:59:44Z<p>Carolin: </p>
<hr />
<div>This is FAQ for the [[Leksah]] IDE.<br />
<br />
=== The cross [x] buttons on tabs are almost invisible (don't fit in tabs) ===<br />
<br />
With version 0.6 for a pleasant visual appearance, you have to copy<br />
or append the .gtkrc-2.0 file from the Leksah data folder or<br />
from the data folder in Leksah sources to your home folder. (Manual 7)<br />
<br />
That's not a global change, but leksah specific parameter that can't be<br />
set in another way, as far as I know.<br />
<br />
To install leksah's gtkrc in Linux for the current user:<br />
$ cd ~<br />
$ wget http://code.haskell.org/leksah/data/.gtkrc-2.0 -O .gtkrc-2.0-leksah<br />
$ echo -e '\ninclude ".gtkrc-2.0-leksah"' >> .gtkrc-2.0<br />
<br />
=== The [X] button on the toolbar behaves in a counterintuitive way (I expected it to close source editor tabs not modules/debugging/... tabs). Is it really needed? ===<br />
<br />
<br />
Well we have made a concept, were you are basically free to<br />
rearrange every part of the Leksah window. So you are free to close every<br />
pane.<br />
<br />
When I work this is my rescue:<br />
<br />
In Leksah there may be an active pane. The name of this<br />
ane is displayed in the second compartment from the left<br />
side in the status bar. Some actions like moving, splitting,<br />
closing panes or finding or replacing items in a text buffer<br />
act on the current pane, so check the display in the status<br />
bar to see if the pane you want to act on, is really the active<br />
one. (Manual 33)<br />
<br />
=== Name completion popup sometimes goes beyond the bottom edge of the window/screen ===<br />
<br />
True.<br />
<br />
=== Debugging doesn't work if ~/.cabal/bin is not in the path - "Setup: Cannot find the program 'ghc' at 'leksahecho' or on the path" (does it mean that it can't find leksahecho?) ===<br />
<br />
True. Not sure what it is really searching, but it needs to find both programs.<br />
<br />
=== Does importing some module need its package to be specified in dependencies first? Would it be possible to automatically add package to dependencies if I wanted to use something from it? ===<br />
<br />
The import helper just looks in imported packages, so if you<br />
miss a package import, you have to fix it manually. It would be an<br />
interesting feature for the future.<br />
<br />
=== Adding dependencies from packages installed by cabal doesn't seem to work: "Setup: At least the following dependencies are missing: some_package", while doing "~/.cabal/bin/cabal configure" in the package directory runs normally. I have some_package installed in my home directory by cabal-install ===<br />
<br />
This is because cabal install uses the per user database of haskell<br />
packages, while the default is the machine database. So you have to add<br />
--user to the ConfigFlags in Package / Package Flags.<br />
<br />
Note: "--user" was made the default in the releases > 0.6.1.<br />
<br />
=== After opening the leksah.cabal package, the Package/Edit Package menu item doesn't work ===<br />
<br />
As of version 0.6 "Cabal file with configurations can't be edited with the current version of the editor" (this is printed to stdout in the background).<br />
<br />
=== What font to use with Leksah? ===<br />
<br />
[http://damieng.com/blog/2008/05/26/envy-code-r-preview-7-coding-font-released Envy code R]<br />
and<br />
[http://www.is-vn.bg/hamster/ Terminus]<br />
seem to be a good match with Leksah.<br />
<br />
=== Is it possible to change the editor color scheme / background color? ===<br />
<br />
Yes. Leksah is based on GtkSourceView and supports the same color schemes as for example gedit. The schemes can be set in preferences, editor -> editor style.<br />
<br />
=== Where is the list of default keybindings? ===<br />
<br />
The keybindings can be configured by editing the .keymap file (name of the file is specified in preferences -> GUI options -> name of the keymap.<br />
<br />
The default keymap file is<br />
[http://code.haskell.org/leksah/data/Default.keymap here]. You could make your own by copying the default one to your ~/.leksah under a different name.<br />
<br />
=== There is "Goto definition" in the modules pane. Is there also goto definition in the editor window? ===<br />
<br />
AFAIK, there is no 'direct' one ATM, but you could select the identifier text, use "Search (metadata)" from the right-click context menu and then right-click on one of the results to go to its definition.<br />
<br />
Also, holding down ctrl and double clicking on identifier in the code editor finds it in the module pane (if the results are unambiguous) and falls back on standard search otherwise (from Hamish).<br />
<br />
=== I'm having troubles linking Leksah against gtksourceview. I've installed gtk2hs but am not sure whether/where to specify the library search path for ld ===<br />
<br />
Here is the output I get:<br />
Linking dist\build\leksah\leksah.exe ...<br />
C:\app\Haskell_Platform\2009.2.0.1\gcc-lib\ld.exe: cannot find -lgtksourceview-2.0<br />
<br />
solution from Tobias Bexelius (with minor edits):<br />
<br />
I downloaded the latest devlopment version binaries for windows from http://ftp.gnome.org/pub/gnome/binaries/win32/gtksourceview/2.6/gtksourceview-dev-2.6.2.zip (the official download page is at http://projects.gnome.org/gtksourceview/download.html) and put the [http://custom-paper-writing.com/order order essays] libgtksourceview-2.0.dll.a file in a lib directory that the GCC compiler knows about (I use Mingw so i put it in the library folder found there [http://cvresumewriters.com/onlineresume.php certified resume writers]). I was then able to compile Leksah (after changing the regex dependencies as reported earlier on this mailinglist).<br />
<br />
=== I have a problem with autocompletion. I can see StartComplete in status bar, but dialog *never* appears. ===<br />
<br />
It probably depends on what you are trying to autocomplete.<br />
AFAIK, for Leksah to know names from some module, you have to add its package to dependencies, configure package and import the module in your code.</div>Carolinhttps://wiki.haskell.org/index.php?title=Leksah_FAQ&diff=34395Leksah FAQ2010-04-02T10:58:29Z<p>Carolin: </p>
<hr />
<div>This is FAQ for the [[Leksah]] IDE.<br />
<br />
=== The cross [x] buttons on tabs are almost invisible (don't fit in tabs) ===<br />
<br />
With version 0.6 for a pleasant visual appearance, you have to copy<br />
or append the .gtkrc-2.0 file from the Leksah data folder or<br />
from the data folder in Leksah sources to your home folder. (Manual 7)<br />
<br />
That's not a global change, but leksah specific parameter that can't be<br />
set in another way, as far as I know.<br />
<br />
To install leksah's gtkrc in Linux for the current user:<br />
$ cd ~<br />
$ wget http://code.haskell.org/leksah/data/.gtkrc-2.0 -O .gtkrc-2.0-leksah<br />
$ echo -e '\ninclude ".gtkrc-2.0-leksah"' >> .gtkrc-2.0<br />
<br />
=== The [X] button on the toolbar behaves in a counterintuitive way (I expected it to close source editor tabs not modules/debugging/... tabs). Is it really needed? ===<br />
<br />
<br />
Well we have made a concept, were you are basically free to<br />
rearrange every part of the Leksah window. So you are free to close every<br />
pane.<br />
<br />
When I work this is my rescue:<br />
<br />
In Leksah there may be an active pane. The name of this<br />
ane is displayed in the second compartment from the left<br />
side in the status bar. Some actions like moving, splitting,<br />
closing panes or finding or replacing items in a text buffer<br />
act on the current pane, so check the display in the status<br />
bar to see if the pane you want to act on, is really the active<br />
one. (Manual 33)<br />
<br />
=== Name completion popup sometimes goes beyond the bottom edge of the window/screen ===<br />
<br />
True.<br />
<br />
=== Debugging doesn't work if ~/.cabal/bin is not in the path - "Setup: Cannot find the program 'ghc' at 'leksahecho' or on the path" (does it mean that it can't find leksahecho?) ===<br />
<br />
True. Not sure what it is really searching, but it needs to find both programs.<br />
<br />
=== Does importing some module need its package to be specified in dependencies first? Would it be possible to automatically add package to dependencies if I wanted to use something from it? ===<br />
<br />
The import helper just looks in imported packages, so if you<br />
miss a package import, you have to fix it manually. It would be an<br />
interesting feature for the future.<br />
<br />
=== Adding dependencies from packages installed by cabal doesn't seem to work: "Setup: At least the following dependencies are missing: some_package", while doing "~/.cabal/bin/cabal configure" in the package directory runs normally [http://custom-paper-writing.com/order order essays]. I have some_package installed in my home directory by cabal-install ===<br />
<br />
This is because cabal install uses the per user database of haskell<br />
packages, while the default is the machine database. So you have to add<br />
--user to the ConfigFlags in Package / Package Flags.<br />
<br />
Note: "--user" was made the default in the releases > 0.6.1.<br />
<br />
=== After opening the leksah.cabal package, the Package/Edit Package menu item doesn't work ===<br />
<br />
As of version 0.6 "Cabal file with configurations can't be edited with the current version of the editor" (this is printed to stdout in the background).<br />
<br />
=== What font to use with Leksah? ===<br />
<br />
[http://damieng.com/blog/2008/05/26/envy-code-r-preview-7-coding-font-released Envy code R]<br />
and<br />
[http://www.is-vn.bg/hamster/ Terminus]<br />
seem to be a good match with Leksah.<br />
<br />
=== Is it possible to change the editor color scheme / background color? ===<br />
<br />
Yes. Leksah is based on GtkSourceView and supports the same color schemes as for example gedit. The schemes can be set in preferences, editor -> editor style.<br />
<br />
=== Where is the list of default keybindings? ===<br />
<br />
The keybindings can be configured by editing the .keymap file (name of the file is specified in preferences -> GUI options -> name of the keymap.<br />
<br />
The default keymap file is<br />
[http://code.haskell.org/leksah/data/Default.keymap here]. You could make your own by copying the default one to your ~/.leksah under a different name.<br />
<br />
=== There is "Goto definition" in the modules pane. Is there also goto definition in the editor window? ===<br />
<br />
AFAIK, there is no 'direct' one ATM, but you could select the identifier text, use "Search (metadata)" from the right-click context menu and then right-click on one of the results to go to its definition.<br />
<br />
Also, holding down ctrl and double clicking on identifier in the code editor finds it in the module pane (if the results are unambiguous) and falls back on standard search otherwise (from Hamish).<br />
<br />
=== I'm having troubles linking Leksah against gtksourceview. I've installed gtk2hs but am not sure whether/where to specify the library search path for ld ===<br />
<br />
Here is the output I get:<br />
Linking dist\build\leksah\leksah.exe ...<br />
C:\app\Haskell_Platform\2009.2.0.1\gcc-lib\ld.exe: cannot find -lgtksourceview-2.0<br />
<br />
solution from Tobias Bexelius (with minor edits):<br />
<br />
I downloaded the latest devlopment version binaries for windows from http://ftp.gnome.org/pub/gnome/binaries/win32/gtksourceview/2.6/gtksourceview-dev-2.6.2.zip (the official download page is at http://projects.gnome.org/gtksourceview/download.html) and put the libgtksourceview-2.0.dll.a file in a lib directory that the GCC compiler knows about (I use Mingw so i put it in the library folder found there [http://cvresumewriters.com/onlineresume.php certified resume writers]). I was then able to compile Leksah (after changing the regex dependencies as reported earlier on this mailinglist).<br />
<br />
=== I have a problem with autocompletion. I can see StartComplete in status bar, but dialog *never* appears. ===<br />
<br />
It probably depends on what you are trying to autocomplete.<br />
AFAIK, for Leksah to know names from some module, you have to add its package to dependencies, configure package and import the module in your code.</div>Carolinhttps://wiki.haskell.org/index.php?title=What_a_Monad_is_not&diff=34394What a Monad is not2010-04-02T10:55:56Z<p>Carolin: </p>
<hr />
<div>==Warning==<br />
This page is currently an unprocessed braindump. Feel free to dump additional stuff or massage stuff into didactic pleasures.<br />
<br />
Also, don't be surprised if you leave this page more confused than before. That just means that it has successfully destroyed your false assumptions, or that you've fallen for some horrible inside joke. Beware of [[Zygohistomorphic prepromorphisms]]. Go for [http://ertes.de/articles/monads.html warm and fuzzy], instead.<br />
<br />
==Monads are not a good choice as topic for your first Haskell blog entry==<br />
...just accept that they're [http://blog.plover.com/prog/burritos.html burritos], and wait until later.<br />
<br />
==Monads are not a language feature==<br />
Really. They are defined in terms of Haskell, not Haskell in terms of them. Conversely,<br />
<br />
==Haskell doesn't need Monads==<br />
...well, apart from the Haskell standard defining the way IO is done in terms of Monads: It could be done differently and still work.<br />
<br />
==Monads are not impure==<br />
...In no way whatsoever. You don't even need flexible morals to claim it. To be more specific, it's IO that's impure. That makes the IO monad impure. But that's not a general property of monads - just IO. And even then, we can pretend that Haskell is a purely functional description [http://essaywritingservices.org/book-report.php book report help] language for imperative programs. But we didn't want to employ flexible morals, now did we?<br />
<br />
==Monads are not about state==<br />
While it is certainly possible to abstract away explicit state passing by using a Monad, that's not what a monad is.<br />
<br />
(some elaboration needed -- Well, which monad most obviously uses no state at all?)<br />
<br />
==Monads are not about strictness==<br />
Monad operations (bind and return) have to be [[Non-strict semantics|lazy]] in fact, always! However<br />
other operations can be specific to each monad.<br />
For instance some are strict (like IO), and some are lazy (like []). Then there are some that come in multiple flavours, like State.<br />
<br />
Try the following:<br />
<br />
<haskell><br />
runState (sequence . repeat $ State (\x -> (x,x+1))) 0<br />
</haskell><br />
<br />
Having a look at the implementation of fixIO might be helpful, too.<br />
<br />
==Monads are not values==<br />
This point might be driven home best by pointing out that instance Monad Foo where ... is not a data type, but a declaration of a typeclass instance. However, to elaborate:<br />
<br />
Monads are not values in the same sense that addition and multiplication are not numbers: They capture a -- very specific -- relationship between values of a specific domain into a common abstraction. We're going to call these values monads manage ''mobits'', somewhat like this:<br />
<br />
<haskell><br />
type Mobit m a = Monad m => m a<br />
</haskell><br />
<br />
The IO monad manages mobits representing side-effects ("IO actions").<br />
<br />
The List monad manages mobits representing multiple values ("[a]")<br />
<br />
The Reader monads manages mobits that are pure computations that use asks to propagate information instead of explicit arguments<br />
<br />
...and while addition and multiplication are both monoids over the positive natural numbers, a monad is a monoid object in a category of endofunctors: return is the unit, and join is the binary operation. It couldn't be more simple. If that confuses you, it might be helpful to see a Monad as a lax functor from a terminal bicategory.<br />
<br />
<br />
<br />
==Monads are not a replacement for applicative functors==<br />
Instead, every monad ''is'' an applicative functor (as well as a functor). It is considered good practice not to use >>= if all you need is <*>, or even fmap.<br />
<br />
Not confusing which features of monads are specific to monads only and which stem from applicative functors is vitally important for a deeper understanding of monads. As an example, the applicative functor interface of parser libraries can parse context-free grammars (and look just like EBNF), while the monadic interface can parse context-sensitive grammars: Monads allow you to influence further processing by inspecting the result of your parse [http://cvresumewriters.com/onlineresume.php online resume writer]. To understand why, have a look at the type of >>=. To understand why applicative functors by themselves are sufficient to track the current parsing position, have a look at the [http://www.cs.uu.nl/research/techreps/repo/CS-2008/2008-044.pdf uu-parsinglib tutorial (pdf)].<br />
<br />
The exact differences are elaborated in even greater detail in Brent Yorgey's excellent [[Typeclassopedia]].<br />
<br />
==Monads are not about ordering/sequencing==<br />
Monads are commonly used to order sequences of computations. But this is misleading. Just as you can use monads for state, or strictness, you can use them to order computations. But there are also commutative monads, like Maybe, that don't order anything. So ordering is not in any way essential to what a monad is.<br />
<br />
I'll try to explain what's meant by ordering. Consider an expression like<br />
<br />
<haskell><br />
let x = a<br />
y = b<br />
in f x y<br />
</haskell><br />
<br />
That gives the same result as<br />
<br />
<haskell><br />
let y = b<br />
x = a<br />
in f x y<br />
</haskell><br />
<br />
It doesn't matter what order we write the two assignments. But for doing I/O we'd like ordering. Monads allow use to express<br />
<br />
<haskell><br />
do<br />
x <- getChar<br />
y <- getChar<br />
return (x,y)<br />
</haskell><br />
<br />
and have it be different from<br />
<br />
<haskell><br />
do<br />
y <- getChar<br />
x <- getChar<br />
return (x,y)<br />
</haskell><br />
<br />
The second example returns a pair of characters in the opposite order to which they were entered.<br />
<br />
However, there are monads for which swapping the order of lines like this makes no difference. For example the Maybe monad.<br />
<br />
So while it is correct to say that monads can be used to order operations, it would be wrong to say that monads are a mechanism for ordering operations.<br />
<br />
This notion of commutativity looks superficially very different from the familiar one in vanilla algebra where a+b=b+a. It's not about the fact that<br />
<br />
<haskell><br />
(Just 2 >> Just 3) == Just 3<br />
</haskell><br />
, implying <br />
<haskell><br />
(Just 2 >> Just 3) /= (Just 3 >> Just 2)<br />
</haskell><br />
<br />
This shouldn't be too surprising, though, as >> isn't the binary operation of some monoid: the algebraic properties of join are very close to those of + and incidentally, join is also the operation true category theorists tend to work with. They also know of bind, but don't use it a lot because, unlike programmers, they don't do any actual productive work.<br />
<br />
(It took long to explain that, maybe someone can edit this down.)<br />
<br />
==See also==<br />
<br />
* [[Do notation considered harmful]]<br />
<br />
[[Category:FAQ]]</div>Carolinhttps://wiki.haskell.org/index.php?title=What_a_Monad_is_not&diff=34393What a Monad is not2010-04-02T10:54:47Z<p>Carolin: </p>
<hr />
<div>==Warning==<br />
This page is currently an unprocessed braindump. Feel free to dump additional stuff or massage stuff into didactic pleasures.<br />
<br />
Also, don't be surprised if you leave this page more confused than before. That just means that it has successfully destroyed your false assumptions, or that you've fallen for some horrible inside joke. Beware of [[Zygohistomorphic prepromorphisms]]. Go for [http://ertes.de/articles/monads.html warm and fuzzy], instead.<br />
<br />
==Monads are not a good choice as topic for your first Haskell blog entry==<br />
...just accept that they're [http://blog.plover.com/prog/burritos.html burritos], and wait until later.<br />
<br />
==Monads are not a language feature==<br />
Really. They are defined in terms of Haskell, not Haskell in terms of them. Conversely,<br />
<br />
==Haskell doesn't need Monads==<br />
...well, apart from the Haskell standard defining the way IO is done in terms of Monads: It could be done differently and still work.<br />
<br />
==Monads are not impure==<br />
...In no way whatsoever. You don't even need flexible morals to claim it. To be more specific, it's IO that's impure. That makes the IO monad impure. But that's not a general property of monads - just IO. And even then, we can pretend that Haskell is a purely functional description [book report help http://essaywritingservices.org/book-report.php] language for imperative programs. But we didn't want to employ flexible morals, now did we?<br />
<br />
==Monads are not about state==<br />
While it is certainly possible to abstract away explicit state passing by using a Monad, that's not what a monad is.<br />
<br />
(some elaboration needed -- Well, which monad most obviously uses no state at all?)<br />
<br />
==Monads are not about strictness==<br />
Monad operations (bind and return) have to be [[Non-strict semantics|lazy]] in fact, always! However<br />
other operations can be specific to each monad.<br />
For instance some are strict (like IO), and some are lazy (like []). Then there are some that come in multiple flavours, like State.<br />
<br />
Try the following:<br />
<br />
<haskell><br />
runState (sequence . repeat $ State (\x -> (x,x+1))) 0<br />
</haskell><br />
<br />
Having a look at the implementation of fixIO might be helpful, too.<br />
<br />
==Monads are not values==<br />
This point might be driven home best by pointing out that instance Monad Foo where ... is not a data type, but a declaration of a typeclass instance. However, to elaborate:<br />
<br />
Monads are not values in the same sense that addition and multiplication are not numbers: They capture a -- very specific -- relationship between values of a specific domain into a common abstraction. We're going to call these values monads manage ''mobits'', somewhat like this:<br />
<br />
<haskell><br />
type Mobit m a = Monad m => m a<br />
</haskell><br />
<br />
The IO monad manages mobits representing side-effects ("IO actions").<br />
<br />
The List monad manages mobits representing multiple values ("[a]")<br />
<br />
The Reader monads manages mobits that are pure computations that use asks to propagate information instead of explicit arguments<br />
<br />
...and while addition and multiplication are both monoids over the positive natural numbers, a monad is a monoid object in a category of endofunctors: return is the unit, and join is the binary operation. It couldn't be more simple. If that confuses you, it might be helpful to see a Monad as a lax functor from a terminal bicategory.<br />
<br />
<br />
<br />
==Monads are not a replacement for applicative functors==<br />
Instead, every monad ''is'' an applicative functor (as well as a functor). It is considered good practice not to use >>= if all you need is <*>, or even fmap.<br />
<br />
Not confusing which features of monads are specific to monads only and which stem from applicative functors is vitally important for a deeper understanding of monads. As an example, the applicative functor interface of parser libraries can parse context-free grammars (and look just like EBNF), while the monadic interface can parse context-sensitive grammars: Monads allow you to influence further processing by inspecting the result of your parse [online resume writer http://cvresumewriters.com/onlineresume.php]. To understand why, have a look at the type of >>=. To understand why applicative functors by themselves are sufficient to track the current parsing position, have a look at the [http://www.cs.uu.nl/research/techreps/repo/CS-2008/2008-044.pdf uu-parsinglib tutorial (pdf)].<br />
<br />
The exact differences are elaborated in even greater detail in Brent Yorgey's excellent [[Typeclassopedia]].<br />
<br />
==Monads are not about ordering/sequencing==<br />
Monads are commonly used to order sequences of computations. But this is misleading. Just as you can use monads for state, or strictness, you can use them to order computations. But there are also commutative monads, like Maybe, that don't order anything. So ordering is not in any way essential to what a monad is.<br />
<br />
I'll try to explain what's meant by ordering. Consider an expression like<br />
<br />
<haskell><br />
let x = a<br />
y = b<br />
in f x y<br />
</haskell><br />
<br />
That gives the same result as<br />
<br />
<haskell><br />
let y = b<br />
x = a<br />
in f x y<br />
</haskell><br />
<br />
It doesn't matter what order we write the two assignments. But for doing I/O we'd like ordering. Monads allow use to express<br />
<br />
<haskell><br />
do<br />
x <- getChar<br />
y <- getChar<br />
return (x,y)<br />
</haskell><br />
<br />
and have it be different from<br />
<br />
<haskell><br />
do<br />
y <- getChar<br />
x <- getChar<br />
return (x,y)<br />
</haskell><br />
<br />
The second example returns a pair of characters in the opposite order to which they were entered.<br />
<br />
However, there are monads for which swapping the order of lines like this makes no difference. For example the Maybe monad.<br />
<br />
So while it is correct to say that monads can be used to order operations, it would be wrong to say that monads are a mechanism for ordering operations.<br />
<br />
This notion of commutativity looks superficially very different from the familiar one in vanilla algebra where a+b=b+a. It's not about the fact that<br />
<br />
<haskell><br />
(Just 2 >> Just 3) == Just 3<br />
</haskell><br />
, implying <br />
<haskell><br />
(Just 2 >> Just 3) /= (Just 3 >> Just 2)<br />
</haskell><br />
<br />
This shouldn't be too surprising, though, as >> isn't the binary operation of some monoid: the algebraic properties of join are very close to those of + and incidentally, join is also the operation true category theorists tend to work with. They also know of bind, but don't use it a lot because, unlike programmers, they don't do any actual productive work.<br />
<br />
(It took long to explain that, maybe someone can edit this down.)<br />
<br />
==See also==<br />
<br />
* [[Do notation considered harmful]]<br />
<br />
[[Category:FAQ]]</div>Carolinhttps://wiki.haskell.org/index.php?title=Gtk2Hs&diff=34392Gtk2Hs2010-04-02T10:51:50Z<p>Carolin: </p>
<hr />
<div>[[Category:User interfaces]]<br />
== What is it? ==<br />
<br />
Gtk2Hs is a Haskell binding to Gtk+ 2.x.<br />
Using it, one can write Gtk+ based applications with GHC.<br />
<br />
== Homepage ==<br />
<br />
http://haskell.org/gtk2hs/<br />
<br />
== Tutorials and Demos ==<br />
<br />
http://www.haskell.org/haskellwiki/Gtk2Hs/Tutorials<br />
<br />
http://darcs.haskell.org/gtk2hs/docs/tutorial/Tutorial_Port/<br />
<br />
Some demonstration programs can be found at:<br />
http://darcs.haskell.org/gtk2hs/demo/<br />
<br />
== Status ==<br />
<br />
It currently works with Gtk+ 2.0 through to 2.8 on Unix, Win32 and MacOS X.<br />
The widget function coverage is almost complete, only a few minor bits and pieces are missing.<br />
<br />
It currently builds with ghc 5.04.3 through to 6.8.2<br />
<br />
== Installation Notes ==<br />
=== Mac OS X ===<br />
<br />
==== Using MacPorts and Snow Leopard ====<br />
<br />
This explains how to install Gtk2Hs-0.10.1 on Mac OS X 10.6 Snow Leopard, in combination with GTK+ from MacPorts.<br />
<br />
* Install the [http://hackage.haskell.org/platform/ Haskell Platform] for Mac<br />
* Download gtk2hs from [http://www.haskell.org/gtk2hs/ gtk2hs website] and untar it.<br />
* Install gtk, cairo, etc. from MacPorts like this (note that the +universal is needed; if you already installed gtk or one of its dependencies, it is recommended you reinstall those as detailed in the NB at the end of this section).<br />
:::sudo port install gtk +universal<br />
* go to the directory where gtk2hs is untarred and run<br />
:::./configure --disable-split-objs --disable-gio<br />
:::make<br />
:::sudo make install<br />
<br />
Alternatively, if you wish to follow the Mac OS X style of directory layout, you can use this configure command instead:<br />
:::./configure --with-pkgconf=/Users/username/.ghc/i386-darwin-6.10.4/package.conf --prefix=/Users/username/Library/Haskell/packages/gtk2hs --disable-split-objs --disable-gio<br />
<br />
Where username is your username ofcourse. Right now you should be able to run the demos. Unfortunately, to build any libraries depending on gtk2hs, such as [http://hackage.haskell.org/package/Chart/ Chart], you need to edit one more file. You will need to find "package.conf" for your ghc by doing<br />
:::ghc-pkg list<br />
In the output you will see the full directory to your package.conf file. In this file, you need to search for "gthread", and everywhere you can find it, add "/opt/local/lib" (with quotes) to the libraryDirs array before it.<br />
<br />
If all went well, it should be properly installed now.<br />
<br />
NB: If compiling fails with architecture errors for certain dynlibs, you need to reinstall the packages these dynlibs belong to with +universal by doing<br />
:::sudo port upgrade packagename --enforce-variants +universal<br />
Alternatively, and this is recommended, you can follow the steps on [http://passingcuriosity.com/2009/haskell-on-snow-leopard/ Haskell On Snow Leopard Blogpost] to immediately add the universal variant of each package:<br />
# Edit /opt/local/macports/variants.conf and add +universal to the end of this file<br />
# sudo port selfupdate <br />
# sudo port sync<br />
# sudo port upgrade --force-installed<br />
<br />
==== Using the GTK+ OS X Framework ====<br />
<br />
This explains how to install Gtk2Hs on Macs using the native [http://www.gtk-osx.org/ GTK+ OS X Framework], a port of GTK+ to the Mac that does '''not''' depend on X11, and hence, is better integrated into the Mac desktop - i.e., menus actually appear in the menu bar, where they belong. It also avoids the often tedious installation of GTK+ via MacPorts. However, it misses support for optional Gtk2Hs packages that are currently not supported by the [http://www.gtk-osx.org/ GTK+ OS X Framework], most notably support for Glade. It does include support for Cairo, though.<br />
<br />
Here is how to install the library:<br />
# Download and install [http://www.gtk-osx.org/ GTK+ OS X Framework] (this uses the standard Mac package installer).<br />
# Install [http://pkg-config.freedesktop.org/ pkg-config], either by compiling it from source or via MacPorts.<br />
# Download and unpack the Gtk2Hs tar ball from the [http://www.haskell.org/gtk2hs/download/ Gtk2Hs download page] (I tested 0.10.0).<br />
# Configure with (you may want to remove the two backslashes and put everything on one line)<br />
env PKG_CONFIG_PATH=/Library/Frameworks/Cairo.framework/Resources/dev/lib/pkgconfig:\ <br />
/Library/Frameworks/GLib.framework/Resources/dev/lib/pkgconfig:\ <br />
/Library/Frameworks/Gtk.framework/Resources/dev/lib/pkgconfig ./configure --disable-gio<br />
# Build with<br />
make<br />
# Install (to <tt>/usr/local/</tt> unless a <tt>--prefix</tt> option was passed to <tt>configure</tt>) with<br />
sudo make install<br />
<br />
The library is now registered with the package database of the GHC you used for compiling.<br />
<br />
NB: Thanks to Ross Mellgren for his post on the gtk2hs-users list that outlined the use of <tt>PKG_CONFIG_PATH</tt>.<br />
<br />
==== Article as of Mid 2008 ====<br />
Installing Gtk2Hs on Mac requires some finesse, at least until Haskell Libary Platform is built or ghc-6.8.3 is <br />
available in macports. (These are planned for late 2008.)<br />
<br />
* Install [http://macports.org MacPorts]<br />
* Install dependencies:<br />
sudo port install glade3 libglade2 gstreamer gst-plugins-base gtksourceview cairo librsvg gtkglext firefox<br />
* Update PKG_CONFIG_PATH (for libraries)<br />
export PKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/local/lib/pkgconfig:/opt/local/lib/pkgconfig<br />
* Update ghc to use macports libs: Edit your main [http://custom-paper-writing.com/order order essays] <tt>ghc</tt> driver program and change the last line to:<br />
exec $GHCBIN $TOPDIROPT ${1+"$@"} -L/opt/local/lib -I/opt/local/include<br />
* Download Gtk2Hs following instructions at [http://www.haskell.org/gtk2hs/downloads/ Gtk2Hs Download page]<br />
* Check configuration:<br />
./configure --enable-docs --enable-profiling<br />
<br />
...<br />
<br />
**************************************************<br />
* Configuration completed successfully. <br />
* <br />
* The following packages will be built: <br />
* <br />
* glib : yes <br />
* gtk : yes <br />
* glade : yes <br />
* cairo : yes <br />
* svgcairo : yes <br />
* gtkglext : yes <br />
* gconf : yes <br />
* sourceview : yes <br />
* mozembed : yes <br />
* soegtk : yes <br />
* gnomevfs : yes <br />
* gstreamer : yes <br />
* documentation : yes <br />
* <br />
* Now do "(g)make" followed by "(g)make install"<br />
**************************************************<br />
* Build and Install:<br />
make <br />
sudo make install<br />
<br />
==== Recent experiences ====<br />
I successfully installed the latest version on Mac OS 10.5 by:<br />
* Installing Macports.<br />
* <tt>sudo port install ghc</tt><br />
* <tt>sudo port install gtk2hs</tt> - which does not complete successfully. It does however, install the appropriate dependencies. Note that there are so many, you may need to install a couple of times due to time outs etc.. The build of Gtk2HS will fail, but that is ok - continue as below. Also note that ghc configure will give up if your perl5.8 is not new enough [http://essaywritingservices.org/book-report.php online book reports], if so deactivate it and try again.<br />
* Remove the build directory under <tt>/opt/.../build/gtk2hs</tt><br />
* Download Gtk2Hs via darcs as per [http://haskell.org/gtk2hs/development/#darcs the gtk2hs download instructions]<br />
* do a <tt>sudo port install automake</tt><br />
* do a <tt>sudo port install alex</tt><br />
* do a <tt>sudo port install happy</tt> (Note this also fails and must be built from source. See the [[Happy]] page for details.)<br />
* Follow the build instructions on the [http://haskell.org/gtk2hs/development/#darcs the gtk2hs download page]. I would suggest using <tt>./configure --prefix=/opt/local</tt> to get it in the same place as ports - personal preference though.<br />
Good luck - as usual, your mileage may vary.<br />
<br />
== Demos ==<br />
<br />
=== OpenGL and Gtk2Hs ===<br />
<br />
[[Gtk2Hs/Demos/GtkGLext/hello.hs]]<br />
<br />
[[Gtk2Hs/Demos/GtkGLext/terrain.hs]] requires [[Gtk2Hs/Demos/GtkGLext/terrain.xpm]]<br />
<br />
==FAQs==<br />
These are links to FAQS on the main site.<br />
*[http://haskell.org/gtk2hs/archives/2005/06/23/hiding-the-console-on-windows/#more-26 Hiding the console on windows]<br />
*[http://haskell.org/gtk2hs/archives/2005/07/24/writing-multi-threaded-guis/#more-38 Writing multi-threaded GUIs]<br />
*[http://haskell.org/gtk2hs/archives/2005/06/24/building-from-source-on-windows/#more-15 Building on Windows]<br />
*[http://haskell.org/gtk2hs/development/#darcs Checkout instructions]. Also see [[Darcs]]<br />
<br />
[[Category:Applications]]<br />
[http://www.example.com link title]</div>Carolinhttps://wiki.haskell.org/index.php?title=Gtk2Hs&diff=34391Gtk2Hs2010-04-02T10:49:47Z<p>Carolin: </p>
<hr />
<div>[[Category:User interfaces]]<br />
== What is it? ==<br />
<br />
Gtk2Hs is a Haskell binding to Gtk+ 2.x.<br />
Using it, one can write Gtk+ based applications with GHC.<br />
<br />
== Homepage ==<br />
<br />
http://haskell.org/gtk2hs/<br />
<br />
== Tutorials and Demos ==<br />
<br />
http://www.haskell.org/haskellwiki/Gtk2Hs/Tutorials<br />
<br />
http://darcs.haskell.org/gtk2hs/docs/tutorial/Tutorial_Port/<br />
<br />
Some demonstration programs can be found at:<br />
http://darcs.haskell.org/gtk2hs/demo/<br />
<br />
== Status ==<br />
<br />
It currently works with Gtk+ 2.0 through to 2.8 on Unix, Win32 and MacOS X.<br />
The widget function coverage is almost complete, only a few minor bits and pieces are missing.<br />
<br />
It currently builds with ghc 5.04.3 through to 6.8.2<br />
<br />
== Installation Notes ==<br />
=== Mac OS X ===<br />
<br />
==== Using MacPorts and Snow Leopard ====<br />
<br />
This explains how to install Gtk2Hs-0.10.1 on Mac OS X 10.6 Snow Leopard, in combination with GTK+ from MacPorts.<br />
<br />
* Install the [http://hackage.haskell.org/platform/ Haskell Platform] for Mac<br />
* Download gtk2hs from [http://www.haskell.org/gtk2hs/ gtk2hs website] and untar it.<br />
* Install gtk, cairo, etc. from MacPorts like this (note that the +universal is needed; if you already installed gtk or one of its dependencies, it is recommended you reinstall those as detailed in the NB at the end of this section).<br />
:::sudo port install gtk +universal<br />
* go to the directory where gtk2hs is untarred and run<br />
:::./configure --disable-split-objs --disable-gio<br />
:::make<br />
:::sudo make install<br />
<br />
Alternatively, if you wish to follow the Mac OS X style of directory layout, you can use this configure command instead:<br />
:::./configure --with-pkgconf=/Users/username/.ghc/i386-darwin-6.10.4/package.conf --prefix=/Users/username/Library/Haskell/packages/gtk2hs --disable-split-objs --disable-gio<br />
<br />
Where username is your username ofcourse. Right now you should be able to run the demos. Unfortunately, to build any libraries depending on gtk2hs, such as [http://hackage.haskell.org/package/Chart/ Chart], you need to edit one more file. You will need to find "package.conf" for your ghc by doing<br />
:::ghc-pkg list<br />
In the output you will see the full directory to your package.conf file. In this file, you need to search for "gthread", and everywhere you can find it, add "/opt/local/lib" (with quotes) to the libraryDirs array before it.<br />
<br />
If all went well, it should be properly installed now.<br />
<br />
NB: If compiling fails with architecture errors for certain dynlibs, you need to reinstall the packages these dynlibs belong to with +universal by doing<br />
:::sudo port upgrade packagename --enforce-variants +universal<br />
Alternatively, and this is recommended, you can follow the steps on [http://passingcuriosity.com/2009/haskell-on-snow-leopard/ Haskell On Snow Leopard Blogpost] to immediately add the universal variant of each package:<br />
# Edit /opt/local/macports/variants.conf and add +universal to the end of this file<br />
# sudo port selfupdate <br />
# sudo port sync<br />
# sudo port upgrade --force-installed<br />
<br />
==== Using the GTK+ OS X Framework ====<br />
<br />
This explains how to install Gtk2Hs on Macs using the native [http://www.gtk-osx.org/ GTK+ OS X Framework], a port of GTK+ to the Mac that does '''not''' depend on X11, and hence, is better integrated into the Mac desktop - i.e., menus actually appear in the menu bar, where they belong. It also avoids the often tedious installation of GTK+ via MacPorts. However, it misses support for optional Gtk2Hs packages that are currently not supported by the [http://www.gtk-osx.org/ GTK+ OS X Framework], most notably support for Glade. It does include support for Cairo, though.<br />
<br />
Here is how to install the library:<br />
# Download and install [http://www.gtk-osx.org/ GTK+ OS X Framework] (this uses the standard Mac package installer).<br />
# Install [http://pkg-config.freedesktop.org/ pkg-config], either by compiling it from source or via MacPorts.<br />
# Download and unpack the Gtk2Hs tar ball from the [http://www.haskell.org/gtk2hs/download/ Gtk2Hs download page] (I tested 0.10.0).<br />
# Configure with (you may want to remove the two backslashes and put everything on one line)<br />
env PKG_CONFIG_PATH=/Library/Frameworks/Cairo.framework/Resources/dev/lib/pkgconfig:\ <br />
/Library/Frameworks/GLib.framework/Resources/dev/lib/pkgconfig:\ <br />
/Library/Frameworks/Gtk.framework/Resources/dev/lib/pkgconfig ./configure --disable-gio<br />
# Build with<br />
make<br />
# Install (to <tt>/usr/local/</tt> unless a <tt>--prefix</tt> option was passed to <tt>configure</tt>) with<br />
sudo make install<br />
<br />
The library is now registered with the package database of the GHC you used for compiling.<br />
<br />
NB: Thanks to Ross Mellgren for his post on the gtk2hs-users list that outlined the use of <tt>PKG_CONFIG_PATH</tt>.<br />
<br />
==== Article as of Mid 2008 ====<br />
Installing Gtk2Hs on Mac requires some finesse, at least until Haskell Libary Platform is built or ghc-6.8.3 is <br />
available in macports. (These are planned for late 2008.)<br />
<br />
* Install [http://macports.org MacPorts]<br />
* Install dependencies:<br />
sudo port install glade3 libglade2 gstreamer gst-plugins-base gtksourceview cairo librsvg gtkglext firefox<br />
* Update PKG_CONFIG_PATH (for libraries)<br />
export PKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/local/lib/pkgconfig:/opt/local/lib/pkgconfig<br />
* Update ghc to use macports libs: Edit your main ( order essays http://custom-paper-writing.com/order) <tt>ghc</tt> driver program and change the last line to:<br />
exec $GHCBIN $TOPDIROPT ${1+"$@"} -L/opt/local/lib -I/opt/local/include<br />
* Download Gtk2Hs following instructions at [http://www.haskell.org/gtk2hs/downloads/ Gtk2Hs Download page]<br />
* Check configuration:<br />
./configure --enable-docs --enable-profiling<br />
<br />
...<br />
<br />
**************************************************<br />
* Configuration completed successfully. <br />
* <br />
* The following packages will be built: <br />
* <br />
* glib : yes <br />
* gtk : yes <br />
* glade : yes <br />
* cairo : yes <br />
* svgcairo : yes <br />
* gtkglext : yes <br />
* gconf : yes <br />
* sourceview : yes <br />
* mozembed : yes <br />
* soegtk : yes <br />
* gnomevfs : yes <br />
* gstreamer : yes <br />
* documentation : yes <br />
* <br />
* Now do "(g)make" followed by "(g)make install"<br />
**************************************************<br />
* Build and Install:<br />
make <br />
sudo make install<br />
<br />
==== Recent experiences ====<br />
I successfully installed the latest version on Mac OS 10.5 by:<br />
* Installing Macports.<br />
* <tt>sudo port install ghc</tt><br />
* <tt>sudo port install gtk2hs</tt> - which does not complete successfully. It does however, install the appropriate dependencies. Note that there are so many, you may need to install a couple of times due to time outs etc.. The build of Gtk2HS will fail, but that is ok - continue as below. Also note that ghc configure will give up if your perl5.8 is not new enough (online book reports http://essaywritingservices.org/book-report.php), if so deactivate it and try again.<br />
* Remove the build directory under <tt>/opt/.../build/gtk2hs</tt><br />
* Download Gtk2Hs via darcs as per [http://haskell.org/gtk2hs/development/#darcs the gtk2hs download instructions]<br />
* do a <tt>sudo port install automake</tt><br />
* do a <tt>sudo port install alex</tt><br />
* do a <tt>sudo port install happy</tt> (Note this also fails and must be built from source. See the [[Happy]] page for details.)<br />
* Follow the build instructions on the [http://haskell.org/gtk2hs/development/#darcs the gtk2hs download page]. I would suggest using <tt>./configure --prefix=/opt/local</tt> to get it in the same place as ports - personal preference though.<br />
Good luck - as usual, your mileage may vary.<br />
<br />
== Demos ==<br />
<br />
=== OpenGL and Gtk2Hs ===<br />
<br />
[[Gtk2Hs/Demos/GtkGLext/hello.hs]]<br />
<br />
[[Gtk2Hs/Demos/GtkGLext/terrain.hs]] requires [[Gtk2Hs/Demos/GtkGLext/terrain.xpm]]<br />
<br />
==FAQs==<br />
These are links to FAQS on the main site.<br />
*[http://haskell.org/gtk2hs/archives/2005/06/23/hiding-the-console-on-windows/#more-26 Hiding the console on windows]<br />
*[http://haskell.org/gtk2hs/archives/2005/07/24/writing-multi-threaded-guis/#more-38 Writing multi-threaded GUIs]<br />
*[http://haskell.org/gtk2hs/archives/2005/06/24/building-from-source-on-windows/#more-15 Building on Windows]<br />
*[http://haskell.org/gtk2hs/development/#darcs Checkout instructions]. Also see [[Darcs]]<br />
<br />
[[Category:Applications]]</div>Carolin