https://wiki.haskell.org/api.php?action=feedcontributions&user=Fuuzetsu&feedformat=atomHaskellWiki - User contributions [en]2024-03-28T09:22:27ZUser contributionsMediaWiki 1.35.5https://wiki.haskell.org/index.php?title=Yi/FAQ&diff=59120Yi/FAQ2014-11-24T00:17:15Z<p>Fuuzetsu: /* How to Configure Yi */</p>
<hr />
<div>=== Installation ===<br />
<br />
*How do I install Yi?<br />
:Get it from Hackage. Configure, compile and install Yi as you would do for any other Cabal package. See also above-mentioned (2.3 Platform Support).<br />
<br />
*Setup configure fails with<br />
Setup.hs: Package yi-0.4 can't be built on this system.<br />
:It means that you have no UI package available. You need VTY or GTK2hs installed. Get them from Hackage.<br />
<br />
*cabal install yi fails with dependency errors, e.g.:<br />
$ cabal install yi<br />
Resolving dependencies...<br />
cabal.exe: dependencies conflict: ghc-6.8.3 requires bytestring ==0.9.0.1.1<br />
however<br />
bytestring-0.9.0.1.1 was excluded because bytestring-0.9.0.1 was selected<br />
instead<br />
bytestring-0.9.0.1.1 was excluded because yi-0.3 requires bytestring =0.9.0.1<br />
:Try removing all your old yi packages, and do<br />
cabal update<br />
before attempting to install.<br />
<br />
*cabal install -fghcAPI fails<br />
:If you want GHC API special capabilities, you have to download, configure, build and copy separately:<br />
cd yi<br />
cabal configure -fghcAPI<br />
cabal build<br />
cabal copy<br />
<br />
* Compilation fails with a message about <tt>alex</tt> not being available?<br />
: Currently, Cabal doesn't track programs, just libraries, so it won't warn you if you are missing Alex (as many people are). The solution here is to just <tt>cabal install alex</tt> first. (Yi uses Alex to generate code for parsing stuff with syntax, like Haskell source.)<br />
<br />
* I can't install <tt>yi-gtk</tt> or <tt>yi-vty</tt>! It wants <tt>sourceview</tt> or something.<br />
: As the Hackage descriptions say, yi-gtk and yi-vty are ''only'' for versions of older than Yi 0.3. You really should be running the latest development (GitHub) or stable (Hackage) versions of Yi, so ''don't'' try to install these two packages. Yi supports VTY and Gtk2hs directly in the <tt>yi</tt> package now.<br />
*On Mac OS X if you get an error message similar to this:<br />
yi: can't load .so/.DLL for: gthread-2.0 (dlopen(libgthread-2.0.dylib, 10): image not found)<br />
<br />
:then your dynamic library search path variable is probably not set correctly. You can set it (in Bash) using:<br />
<br />
export DYLD_LIBRARY_PATH=/opt/local/lib<br />
<br />
:(Adjust the specific path to your system. You can find the right location using <tt>locate libgthread</tt>)<br />
<br />
*On Mac OS 10.6 (Snow Leopard) if you get the following error:<br />
Loading package cairo-0.11.1 ... <command line>: can't load .so/.DLL for: pixman-1 (dlopen(/opt/local/lib/libpixman-1.dylib, 9): no suitable image found. Did find:<br />
/opt/local/lib/libpixman-1.dylib: mach-o, but wrong architecture)<br />
cabal: Error: some packages failed to install:<br />
yi-0.6.2.4 failed during the building phase. The exception was:<br />
ExitFailure 1<br />
<br />
:then the problem is that GHC currently only supports linking against i386 libraries, and your ports are compiled for x86_64. To fix, recompile your ports with the +universal variant like so:<br />
<br />
port install installed +universal<br />
<br />
* Compilation fails with errors about template-haskell or data-accessor:<br />
Add constraints about which release of those libraries to use.<br />
$ cabal install yi --constraint="data-accessor < 0.2.1" --constraint="template-haskell < 2.4"<br />
<br />
=== Default key bindings ===<br />
<br />
==== CUA key bindings ====<br />
<br />
===== File operations =====<br />
{|<br />
| Ctrl-o<br />
| Open file.<br />
|-<br />
| Ctrl-s<br />
| Save the current file.<br />
|-<br />
| Ctrl-q<br />
| Quit the editor.<br />
|}<br />
<br />
===== Cursor/selection movement =====<br />
{|<br />
| &rarr;<br />
| Move cursor forward one character.<br />
|-<br />
| &larr;<br />
| Move cursor back one character.<br />
|-<br />
| &darr;<br />
| Move cursor down one line.<br />
|-<br />
| &uarr;<br />
| Move cursor down one line.<br />
|-<br />
| Shift+&rarr;<br />
| Extend selection forward one character.<br />
|-<br />
| Shift+&larr;<br />
| Extend selection back one character.<br />
|-<br />
| Shift+&darr;<br />
| Extend selection down one line.<br />
|-<br />
| Shift+&uarr;<br />
| Extend selection up one line.<br />
|-<br />
| Ctrl-&rarr;<br />
| Move cursor forward one word.<br />
|-<br />
| Ctrl-&larr;<br />
| Move cursor back one word.<br />
|-<br />
| Home<br />
| Move cursor to beginning of line.<br />
|-<br />
| End<br />
| Move cursor to end of line.<br />
|-<br />
| Ctrl-Home<br />
| Move cursor to beginning of document.<br />
|-<br />
| Ctrl-End<br />
| Move cursor to end of document.<br />
|}<br />
<br />
===== Miscellaneous operations =====<br />
<br />
{|<br />
| Ctrl-f<br />
| Incremental search.<br />
|-<br />
| Ctrl-x<br />
| Cut the selected area and save it to the clipboard<br />
|-<br />
| Ctrl-c<br />
| Copy the selected area to the clipboard<br />
|-<br />
| Ctrl-v<br />
| Paste contents of clipboard at cursor.<br />
|-<br />
| Ctrl-z<br />
| Undo last operation.<br />
|-<br />
| Ctrl-y<br />
| Redo last operation.<br />
|}<br />
<br />
==== Vim key bindings ====<br />
==== Emacs key bindings ====<br />
<br />
C = Control<br />
<br />
M = Meta = Alt|Esc<br />
<br />
===== Basics =====<br />
{|<br />
|C-x C-f<br />
|"Find" file i.e. open/create a file in buffer<br />
|-<br />
|C-x C-s<br />
|Save the file<br />
|-<br />
|C-x C-w<br />
|Write the text to an alternate name<br />
|-<br />
|C-x i<br />
|Insert file at cursor position<br />
|-<br />
|C-x b<br />
|Create/switch buffers<br />
|-<br />
|C-x C-b<br />
|Show buffer list<br />
|-<br />
|C-x k<br />
|Kill buffer<br />
|-<br />
|C-z<br />
|Suspend Yi<br />
|-<br />
|C-x C-c<br />
|Close down Yi<br />
|}<br />
<br />
===== Basic movement =====<br />
<br />
{|<br />
|C-f<br />
|Forward char<br />
|-<br />
|C-b<br />
|Backward char<br />
|-<br />
|C-p<br />
|Previous line<br />
|-<br />
|C-n<br />
|Next line<br />
|-<br />
|M-f<br />
|Forward one word<br />
|-<br />
|M-b<br />
|Backward one word<br />
|-<br />
|C-a<br />
|Beginning of line<br />
|-<br />
|C-e<br />
|End of line<br />
|-<br />
|C-v<br />
|One page up<br />
|-<br />
|M-v<br />
|Scroll down one page<br />
|-<br />
|M-<<br />
|Beginning of text<br />
|-<br />
|M-><br />
|End of text<br />
|}<br />
<br />
===== Editing =====<br />
<br />
{|<br />
|M-n<br />
|Repeat the following command n times<br />
|-<br />
|C-u<br />
|Repeat the following command 4 times<br />
|-<br />
|C-d<br />
|Delete a char<br />
|-<br />
|M-d<br />
|Delete word<br />
|-<br />
|M-Del<br />
|Delete word backwards<br />
|-<br />
|C-k<br />
|Kill line<br />
|-<br />
|C-Space<br />
|Set beginning mark (for region marking for example)<br />
|-<br />
|C-W<br />
|"Kill" (delete) the marked region region<br />
|-<br />
|M-W<br />
|Copy the marked region<br />
|-<br />
|C-y<br />
|"Yank" (paste) the copied/killed region/line<br />
|-<br />
|M-y<br />
|Yank earlier text (cycle through kill buffer)<br />
|-<br />
|C-x C-x<br />
|Exchange cursor and mark<br />
|-<br />
|C-t<br />
|Transpose two chars<br />
|-<br />
|M-t<br />
|Transpose two words<br />
|-<br />
|M-u<br />
|Make letters uppercase in word from cursor position to end<br />
|-<br />
|M-c<br />
|Simply make first letter in word uppercase<br />
|-<br />
|M-l<br />
|Opposite to M-u<br />
|}<br />
<br />
===== Important =====<br />
<br />
{|<br />
|C-g<br />
|Quit the running/entered command<br />
|-<br />
|C-x u<br />
|Undo previous action<br />
|-<br />
|M-/<br />
|Undo previous action<br />
|}<br />
<br />
===== Search/Replace =====<br />
<br />
{|<br />
|C-s<br />
|Search forward<br />
|-<br />
|C-r<br />
|Search backward<br />
|-<br />
|M-%<br />
|Query replace<br />
|-<br />
|Space or y<br />
|Replace this occurrence<br />
|-<br />
|Del or n<br />
|Don't replace<br />
|-<br />
|!<br />
|Replace all following occurrences<br />
|-<br />
|ENTER or q<br />
|Quit replace<br />
|}<br />
<br />
===== Window-Commands =====<br />
<br />
{|<br />
|C-x 2<br />
|Split window vertically<br />
|-<br />
|C-x o<br />
|Change to other window<br />
|-<br />
|C-x 0<br />
|Delete window<br />
|-<br />
|C-x 1<br />
|Close all windows except the one the cursors in<br />
|}<br />
<br />
===== DIRectory EDitor (dired) =====<br />
<br />
{|<br />
|C-x d<br />
|Start up dired<br />
|-<br />
|C (large C)<br />
|Copy<br />
|-<br />
|d<br />
|Mark for erase<br />
|-<br />
|D<br />
|Delete right away<br />
|-<br />
|e or f<br />
|Open file or directory<br />
|-<br />
|g<br />
|Re-read directory structure from file<br />
|-<br />
|m<br />
|Mark with *<br />
|-<br />
|n<br />
|Move to next line<br />
|-<br />
|q<br />
|Quit dired<br />
|-<br />
|R<br />
|Rename file<br />
|-<br />
|u<br />
|Remove mark<br />
|-<br />
|x<br />
|Delete files marked with D<br />
|-<br />
| +<br />
|Create directory<br />
|}<br />
<br />
===== Programming =====<br />
<br />
{|<br />
|M-m<br />
|Move to first (non-space) char in this line<br />
|-<br />
|M-^<br />
|Attach this line to previous<br />
|-<br />
|M-;<br />
|Formatize and indent comment<br />
|-<br />
<br />
===== C, C++ and Java Modes =====<br />
<br />
{|<br />
|M-a<br />
|Beginning of statement<br />
|-<br />
|M-e<br />
|End of statement<br />
|-<br />
|C-c C-c<br />
|Comment out marked area<br />
|}<br />
<br />
=== Development ===<br />
<br />
*How do I install Yi for development?<br />
:Fork the repository on GitHub, then clone your version to your machine. Push to your repo on GitHub, and then make merge requests.<br />
<br />
*What are some of the dependancies?<br />
:There is a rather long list of dependencies for Yi, check the yi.cabal file for a list.<br />
<br />
::If you are on Mac OS X and are using MacPorts, then these will not be included in the GHC in that distribution. Many of the dependancies are in MacPorts (for example: ghc, ghc-devel, alex, and gtk2hs). However, you may have some trouble building with Cabal-1.5.2, since it is a development version of Cabal. To work around these issues, you might have to add the line "Build-Type: Simple" to the .cabal files in the above required packages.<br />
<br />
=== Configuration ===<br />
<br />
==== How to Configure Yi ====<br />
<br />
You can find some example configs at https://github.com/yi-editor/yi/tree/master/example-configs<br />
<br />
A good way to start is to copy yi.hs in your $XDG_CONFIG_HOME/yi directory (create it if needed, usually ~/.config/yi), and hack as needed.<br />
<br />
=== Usage ===<br />
==== GError on startup ====<br />
I get the error message "yi.exe: <<System.Glib.GError.GError>>" when I try to run yi.<br />
<br />
Sometimes this is a result of yi not being able to find the contents of the art directory when trying to start in graphical mode (e.g. Gtk or Pango). Check that the install has be done correctly or use the VTY mode (<tt>$ yi -f vty</tt>).<br />
<br />
For more detail on the error, modify main in Yi/Main.hs to catch GError:<br />
<pre><br />
Right finalCfg -> do catchGError (do<br />
when (debugMode finalCfg) $ initDebug ".yi.dbg" <br />
startEditor finalCfg state) (\(GError dom code msg) -> fail msg)<br />
</pre><br />
<br />
Note that more recent versions of Yi (e.g. from the GitHub repo) no longer simply display the anonymous GError but instead provide a more detailed error message (making the above code snippet unnecessary).<br />
<br />
[[Category:FAQ]]</div>Fuuzetsuhttps://wiki.haskell.org/index.php?title=Haddock/Development_ideas&diff=57669Haddock/Development ideas2014-03-14T19:11:31Z<p>Fuuzetsu: doctest does the QC stuff</p>
<hr />
<div>Most of these ideas are '''very''' old, but some may still be relevant.<br />
<br />
* It would be good to have a recursive flag that would operate on all the .hs and .lhs files under a single directory.<br />
* There should be an annotation to include a function's entire definition in the documentation. This would be useful for functions like <hask>(.)</hask> and <hask>mapM</hask> where the definition is the clearest possible documentation.<br />
* There should be an option to include a simplified implementation of a function that is equivalent to the one in the code. For instance, instead of showing a complex implementation of List.length that makes use of stream fusion we could show a simple one based on foldl'.<br />
* Optionally [http://www.haskell.org/pipermail/haskell-cafe/2008-January/038211.html show qualifications of identifiers], that is print <hask>Sequence.map</hask> rather than <hask>map</hask>, <hask>Music.T</hask> rather than just <hask>T</hask>. The option for haddock could be <code>--qualification QUAL</code><br />
** <code>none</code> (default) strip off qualification (just <hask>map</hask>)<br />
** <code>orig</code> show the identifiers as they are written in the module (e.g. <hask>map</hask> or <hask>List.map</hask>)<br />
** <code>full</code> show all identifiers with full qualification (<hask>Data.List.map</hask>)</div>Fuuzetsuhttps://wiki.haskell.org/index.php?title=Haddock/Development_ideas&diff=57668Haddock/Development ideas2014-03-14T19:11:02Z<p>Fuuzetsu: Remove implemented idea</p>
<hr />
<div>Most of these ideas are '''very''' old, but some may still be relevant.<br />
<br />
* It would be good to have a recursive flag that would operate on all the .hs and .lhs files under a single directory.<br />
* There should be an annotation to include a function's entire definition in the documentation. This would be useful for functions like <hask>(.)</hask> and <hask>mapM</hask> where the definition is the clearest possible documentation, and for QuickCheck properties that specify the behavior of a library.<br />
* There should be an option to include a simplified implementation of a function that is equivalent to the one in the code. For instance, instead of showing a complex implementation of List.length that makes use of stream fusion we could show a simple one based on foldl'.<br />
* Optionally [http://www.haskell.org/pipermail/haskell-cafe/2008-January/038211.html show qualifications of identifiers], that is print <hask>Sequence.map</hask> rather than <hask>map</hask>, <hask>Music.T</hask> rather than just <hask>T</hask>. The option for haddock could be <code>--qualification QUAL</code><br />
** <code>none</code> (default) strip off qualification (just <hask>map</hask>)<br />
** <code>orig</code> show the identifiers as they are written in the module (e.g. <hask>map</hask> or <hask>List.map</hask>)<br />
** <code>full</code> show all identifiers with full qualification (<hask>Data.List.map</hask>)</div>Fuuzetsuhttps://wiki.haskell.org/index.php?title=Yi&diff=57498Yi2014-01-27T03:08:23Z<p>Fuuzetsu: /* Yi Ideas */ spelling</p>
<hr />
<div>[[Category:Applications]]<br />
<br />
[[Image:Yi-logo.png]]<br />
<br />
== About ==<br />
<br />
Yi is a text editor written in Haskell and extensible in Haskell. The goal of Yi is<br />
to provide a flexible, powerful and correct editor core<br />
scriptable in Haskell.<br />
<br />
Features:<br />
<br />
* A purely functional editor core;<br />
* Keybindings written as parsers of the input;<br />
* Emacs, Vim and Cua (subset) emulations provided by default;<br />
* Vty and GTK+ w/ Pango(via Gtk2Hs) frontends.<br />
<br />
The long term goal of the project is to make Yi the editor of choice for Haskell hackers.<br />
<br />
The main short term goal is to maximize Yi's Fun Factor. This includes:<br />
* Improve hackability (and therefore architecture)<br />
* Add cool features<br />
<br />
== Get Yi ==<br />
<br />
=== From Hackage ===<br />
<br />
Yi depends on the [http://haskell.org/platform Haskell Platform] which must be installed. Many Haskellers haven't installed this explicitly, as they have already installed most of the utilities it contains; to be sure you have everything that is needed, it is recommended that you explicitly install the Platform.<br />
<br />
Following that, simply:<br />
<br />
$ cabal update<br />
$ cabal install yi<br />
<br />
More information about the package is available at [http://hackage.haskell.org/package/yi Yi on Hackage].<br />
<br />
=== From GitHub ===<br />
<br />
See the GitHub [https://github.com/yi-editor/yi repository]. Or get it with git:<br />
<br />
$ git clone git://github.com/yi-editor/yi.git<br />
<br />
We try to keep the repository in a clean and buildable state, so it's "testable" for new users. Yi usually only works on the latest GHC release.<br />
<br />
''Note that the old yi-contrib repository is now just a subdirectory of the yi repo.''<br />
<br />
=== Platform Support ===<br />
<br />
==== GNU/Linux ====<br />
<br />
Some GNU/Linux distros have pre-built Yi packages. For Debian/Ubuntu packages, see [https://groups.google.com/forum/?fromgroups=#!topic/yi-devel/XSzWSv1HBmQ this post in the yi-devel mailing list].<br />
<br />
==== Mac OS X ====<br />
<br />
The easiest way to get Yi for Mac OS X is currently no different from the above. There is also a Yi release in MacPorts, but it might be very old, deprecated one. Please use the Hackage version instead.<br />
<br />
==== Windows ====<br />
<br />
The current version of Yi on Hackage (0.6.6.0) can be built on Windows.<br />
<br />
First, you should install the current version of [http://www.haskell.org/platform/windows.html Haskell Platform for Windows]. The version 2012.4.0.0 is known to work with Yi 0.6.6.0. Make sure that your Haskell compiler and tools are on your PATH.<br />
<br />
Next, you should install [http://www.gtk.org/download/win32.php GTK+ for Windows]. You have to use "All-in-one bundles", not individual packages. Download and unpack the archive, then again make sure that GTK+ utilities are on your PATH.<br />
<br />
Now, you can invoke cabal-Install from the command prompt.<br />
<br />
$ cabal update<br />
$ cabal install gtk2hs-buildtools<br />
$ cabal install gtk<br />
$ cabal install yi -f-vty -fpango<br />
<br />
Make sure that you do Configure with flag -f-vty -fpango to force enabling Pango and disabling Vty interface, since Vty is not supported in Windows.<br />
<br />
== Screenshots (0.3) ==<br />
<br />
[[Image:Yi-20070409.png|thumb|right|500px|The GTK frontend]]<br />
[[Image:Yi-20080114-vty.png|thumb|none|500px|The Vty frontend]]<br />
<br />
== News ==<br />
<br />
There is a Yi blog, that reports the important news about Yi, at [http://yi-editor.blogspot.com/ http://yi-editor.blogspot.com/]. It also delves into algorithms and the Yi internals.<br />
<br />
You can also check the [[/OldNews]].<br />
<br />
== Bugs ==<br />
<br />
Check/report bug reports here: [https://github.com/yi-editor/yi/issues GitHub issue tracker]<br />
<br />
== FAQs ==<br />
<br />
{{/FAQ}}<br />
<br />
== Contribute ==<br />
<br />
Fork the source on GitHub and send pull requests for merges. Or consult the yi-devel mailing list. Patches are always welcome. :)<br />
<br />
Otherwise, see [https://github.com/yi-editor/yi/issues the complete list of open issues] here.<br />
<br />
(Note you can start working on all issues in<br />
New/Accepted state, regardless of the owner of the issue.<br />
-- you can send an email to the list with your plan if unsure)<br />
<br />
Post your questions and follow up on [http://groups.google.com/group/yi-devel the yi-devel mailing list].<br />
Some other pending tasks are described below.<br />
<br />
=== Write access policy ===<br />
<br />
One does not need write access to the repository to contribute. Please fork the main repository and send pull requests.<br />
<br />
Write access can however be granted, with the following disclaimer:<br />
<br />
* All people with write access can apply patches without prior approval. If one thinks a patch would be controversial, it might be a good idea to discuss it on the list though.<br />
* Try to not break the build. (By Murphy's law, if you do so it will happen at the most annoying moment...) So, always try to build before pushing patches. Bypassing the test build to record a patch indicates you should further improve your patch.<br />
* [[JeanPhilippeBernardy | I]] can at any time rollback a patch for whatever reason. This however should not upset the author of the patch. Most contributions are welcome, so a patch revert normally would only mean that a detail or two need to be worked out. (e.g. it breaks an important feature in some configuration, etc.)<br />
<br />
== Yi Ideas ==<br />
<br />
This section is meant to gather ideas people have for Yi.<br />
<br />
*Evolution to an IDE:<br />
:Show exact location of compilation errors: 80% of a Haskell project<br />
:Support for the GHCi debugger & others: 10 % of a Haskell project (Added bonus: great for learning: through the debugger, people learn the real execution flow of a Haskell program. Better if this is done inside an editor)<br />
:Integration of refactoring tools : 5%<br />
:Edition: only 5%<br />
<br />
<br />
*An extension to GHCi to support documentation of symbols.<br />
:This seems to be (reasonably) straightforward, as GHCi already has :info. It would mean hacking the type environment (what about values?) to add documentation information. The main problem would seem to be populating this --- maybe hack haddock to produce something from the library docs? I assume that using package GHC uses the parent RTS (package GHC seems to be the way to go, but more investigation is required --- don?)<br />
<br />
*Views on data<br />
:Rather than just editing a file, you would open a view onto the file, i.e. there is no longer a 1-1 correspondence between buffers and files. Why? Well, for aggregate buffers (i.e., editing multiple files in the one view), or for multiple views of a file (e.g. AST and source-level). There would be some primitive ops for editing a buffer (insertChar, delete, etc.), which would then call update functions on anything observing that file.<br />
<br />
*Support for Perl style regular expressions<br />
:Emacs regexes don't support the same set of features; Perl regexes are more tersely powerful. This could be a good feature for luring users from vanilla Emacs.<br />
<br />
*Remote attach so I can work from home, but still use a remote machine<br />
:Like Emacs's server?<br />
<br />
*Haddock documentation<br />
:(no brainer), maybe associate with .hi files for binaries.<br />
<br />
*Maybe a class <code>YiShow</code>, which all config items must be a member of? This is to emulate describe-variable<br />
<br />
*Support for collaborative editing. This would be very good for #haskell work, and the text editor Gobby and its [http://gobby.0x539.de/trac/wiki/ObbyProtocol Obby protocol] seem to provide a candidate way of doing things.<br />
<br />
<br />
=== Borrowing from other editors ===<br />
Take some ideas from Emacs, some from vi, but don't stick them all together without a single core philosophy. Otherwise, you'll end up with an editor that looks like it was thrown together. Some people come from an Emacs background, some from vi, some from elsewhere, and ALL of them will want Yi to behave like their regular editor. The best way to do this is to have a single person make all the decisions on behavior.<br />
<br />
==== Emacs ====<br />
<br />
Coming from an Emacs background, I think a few things are essential,<br />
mainly the introspection capabilities of Emacs.<br />
<br />
===== Emacs goodness =====<br />
<br />
The following are things I like about Emacs, as an extensible<br />
environment, and miss in Yi:<br />
<br />
; Really good online documentation<br />
: Emacs can tell you a lot about a function or variable with a keypress--- the current value, where it is declared, and a hypertext formation string<br />
<br />
; Hooks-Extensibility<br />
: All (good) apps allow users to extend, through, e.g., hooks --- a list of functions that are run before/after some event (like saving a file)<br />
<br />
; List of must-have features<br />
: http://glyph.twistedmatrix.com/2008/12/emacs-test.html<br />
<br />
<br />
===== Emacs badness =====<br />
<br />
So, why replace it?:<br />
; ELisp<br />
: Dynamically scoped, Dynamically typed, ugly, old. 'Nuff said<br />
<br />
; What's a Parser?<br />
: A lot of apps in emacs do stuff with text, usually text that is in some language. There is no standard parser (like, e.g. parsec), so a lot of it is ugly handwritten spaghetti. This also means that adding analysis tools isn't really done (or done nicely).<br />
<br />
; ELisp again<br />
: Haskell is a lot cleaner to write, especially because of the large number of libraries.<br />
<br />
(See also [http://www.emacswiki.org/cgi-bin/wiki/WhyDoesElispSuck WhyDoesElispSuck] on the Emacs wiki.)<br />
<br />
===== Emacs maybeness (?) =====<br />
<br />
Some things that are sometimes bad, sometimes good:<br />
<br />
; Everything is a buffer<br />
: Makes some sense, but sometimes doesn't. It is nice to have uniform key bindings do the right thing (e.g., C-Space sets the mark, and the region can then be used, e.g. to delete a sequence of emails in Wl) Sometimes, however, you just want some sort of GUI widget.<br />
: OTOH, having the minibuffer be a special kind of buffer is a good idea.<br />
<br />
; Properties<br />
: It is possible to associate arbitrary properties with symbols. This means you can annotate a symbol and then use that information at a later date<br />
<br />
==== Vim? ====<br />
<br />
; good things<br />
: modal key editing -> configuration system is powerful enough!<br />
: light weight -> fast startup -> yi has this :)<br />
<br />
<br />
=== Ideas ===<br />
<br />
=== Implementation ===<br />
<br />
Considerations:<br />
<br />
; Interface to the runtime<br />
: The scheduler, docs, etc.<br />
<br />
; Introspection of e.g. what processes are running.<br />
: There are already libraries in Haskell for processes, but they don't give Yi any extra information --- we really want a layer on top.<br />
<br />
...<br />
<br />
== Trivia ==<br />
<br />
;Y I is the most recursive acronym. (Read it as combinators).<br />
;義, pronounced yi, means righteousness, one of the five virtues of confucianism.<br />
;Yi is the symbol for a yobi - the largest [http://en.wikipedia.org/wiki/Binary_prefix#Prefixes binary prefix], meaning 2^80<br />
<br />
== External links ==<br />
<br />
* Blog: http://yi-editor.blogspot.com/<br />
* Haddock: http://projects.haskell.org/yi/doc/<br />
* Repository: https://github.com/yi-editor/yi<br />
* Issues tracker: https://github.com/yi-editor/yi/issues<br />
* Hackage page: http://hackage.haskell.org/package/yi<br />
* IRC channel: #yi on Freenode</div>Fuuzetsuhttps://wiki.haskell.org/index.php?title=Yi&diff=57497Yi2014-01-27T02:40:59Z<p>Fuuzetsu: /* About */</p>
<hr />
<div>[[Category:Applications]]<br />
<br />
[[Image:Yi-logo.png]]<br />
<br />
== About ==<br />
<br />
Yi is a text editor written in Haskell and extensible in Haskell. The goal of Yi is<br />
to provide a flexible, powerful and correct editor core<br />
scriptable in Haskell.<br />
<br />
Features:<br />
<br />
* A purely functional editor core;<br />
* Keybindings written as parsers of the input;<br />
* Emacs, Vim and Cua (subset) emulations provided by default;<br />
* Vty and GTK+ w/ Pango(via Gtk2Hs) frontends.<br />
<br />
The long term goal of the project is to make Yi the editor of choice for Haskell hackers.<br />
<br />
The main short term goal is to maximize Yi's Fun Factor. This includes:<br />
* Improve hackability (and therefore architecture)<br />
* Add cool features<br />
<br />
== Get Yi ==<br />
<br />
=== From Hackage ===<br />
<br />
Yi depends on the [http://haskell.org/platform Haskell Platform] which must be installed. Many Haskellers haven't installed this explicitly, as they have already installed most of the utilities it contains; to be sure you have everything that is needed, it is recommended that you explicitly install the Platform.<br />
<br />
Following that, simply:<br />
<br />
$ cabal update<br />
$ cabal install yi<br />
<br />
More information about the package is available at [http://hackage.haskell.org/package/yi Yi on Hackage].<br />
<br />
=== From GitHub ===<br />
<br />
See the GitHub [https://github.com/yi-editor/yi repository]. Or get it with git:<br />
<br />
$ git clone git://github.com/yi-editor/yi.git<br />
<br />
We try to keep the repository in a clean and buildable state, so it's "testable" for new users. Yi usually only works on the latest GHC release.<br />
<br />
''Note that the old yi-contrib repository is now just a subdirectory of the yi repo.''<br />
<br />
=== Platform Support ===<br />
<br />
==== GNU/Linux ====<br />
<br />
Some GNU/Linux distros have pre-built Yi packages. For Debian/Ubuntu packages, see [https://groups.google.com/forum/?fromgroups=#!topic/yi-devel/XSzWSv1HBmQ this post in the yi-devel mailing list].<br />
<br />
==== Mac OS X ====<br />
<br />
The easiest way to get Yi for Mac OS X is currently no different from the above. There is also a Yi release in MacPorts, but it might be very old, deprecated one. Please use the Hackage version instead.<br />
<br />
==== Windows ====<br />
<br />
The current version of Yi on Hackage (0.6.6.0) can be built on Windows.<br />
<br />
First, you should install the current version of [http://www.haskell.org/platform/windows.html Haskell Platform for Windows]. The version 2012.4.0.0 is known to work with Yi 0.6.6.0. Make sure that your Haskell compiler and tools are on your PATH.<br />
<br />
Next, you should install [http://www.gtk.org/download/win32.php GTK+ for Windows]. You have to use "All-in-one bundles", not individual packages. Download and unpack the archive, then again make sure that GTK+ utilities are on your PATH.<br />
<br />
Now, you can invoke cabal-Install from the command prompt.<br />
<br />
$ cabal update<br />
$ cabal install gtk2hs-buildtools<br />
$ cabal install gtk<br />
$ cabal install yi -f-vty -fpango<br />
<br />
Make sure that you do Configure with flag -f-vty -fpango to force enabling Pango and disabling Vty interface, since Vty is not supported in Windows.<br />
<br />
== Screenshots (0.3) ==<br />
<br />
[[Image:Yi-20070409.png|thumb|right|500px|The GTK frontend]]<br />
[[Image:Yi-20080114-vty.png|thumb|none|500px|The Vty frontend]]<br />
<br />
== News ==<br />
<br />
There is a Yi blog, that reports the important news about Yi, at [http://yi-editor.blogspot.com/ http://yi-editor.blogspot.com/]. It also delves into algorithms and the Yi internals.<br />
<br />
You can also check the [[/OldNews]].<br />
<br />
== Bugs ==<br />
<br />
Check/report bug reports here: [https://github.com/yi-editor/yi/issues GitHub issue tracker]<br />
<br />
== FAQs ==<br />
<br />
{{/FAQ}}<br />
<br />
== Contribute ==<br />
<br />
Fork the source on GitHub and send pull requests for merges. Or consult the yi-devel mailing list. Patches are always welcome. :)<br />
<br />
Otherwise, see [https://github.com/yi-editor/yi/issues the complete list of open issues] here.<br />
<br />
(Note you can start working on all issues in<br />
New/Accepted state, regardless of the owner of the issue.<br />
-- you can send an email to the list with your plan if unsure)<br />
<br />
Post your questions and follow up on [http://groups.google.com/group/yi-devel the yi-devel mailing list].<br />
Some other pending tasks are described below.<br />
<br />
=== Write access policy ===<br />
<br />
One does not need write access to the repository to contribute. Please fork the main repository and send pull requests.<br />
<br />
Write access can however be granted, with the following disclaimer:<br />
<br />
* All people with write access can apply patches without prior approval. If one thinks a patch would be controversial, it might be a good idea to discuss it on the list though.<br />
* Try to not break the build. (By Murphy's law, if you do so it will happen at the most annoying moment...) So, always try to build before pushing patches. Bypassing the test build to record a patch indicates you should further improve your patch.<br />
* [[JeanPhilippeBernardy | I]] can at any time rollback a patch for whatever reason. This however should not upset the author of the patch. Most contributions are welcome, so a patch revert normally would only mean that a detail or two need to be worked out. (e.g. it breaks an important feature in some configuration, etc.)<br />
<br />
== Yi Ideas ==<br />
<br />
This section is meant to gather ideas people have for Yi.<br />
<br />
*Evolution to an IDE:<br />
:Show exact location of compilation errors: 80% of a Haskell project<br />
:Support for the GHCi debugger & others: 10 % of a Haskell project (Added bonus: greath for learning: trough the debugger, people learn the real execution flow of a Haskell program. Better if this is done inside an editor)<br />
:Integration of refactoring tools : 5 %<br />
:Edition: only 5%<br />
<br />
<br />
*An extension to GHCi to support documentation of symbols.<br />
:This seems to be (reasonably) straightforward, as GHCi already has :info. It would mean hacking the type environment (what about values?) to add documentation information. The main problem would seem to be populating this --- maybe hack haddock to produce something from the library docs? I assume that using package GHC uses the parent RTS (package GHC seems to be the way to go, but more investigation is required --- don?)<br />
<br />
*Views on data<br />
:Rather than just editing a file, you would open a view onto the file, i.e. there is no longer a 1-1 correspondence between buffers and files. Why? Well, for aggregate buffers (i.e., editing multiple files in the one view), or for multiple views of a file (e.g. AST and source-level). There would be some primitive ops for editing a buffer (insertChar, delete, etc.), which would then call update functions on anything observing that file.<br />
<br />
*Support for Perl style regular expressions<br />
:Emacs regexes don't support the same set of features; Perl regexes are more tersely powerful. This could be a good feature for luring users from vanilla Emacs.<br />
<br />
*Remote attach so I can work from home, but still use a remote machine<br />
:Like Emacs's server?<br />
<br />
*Haddock documentation<br />
:(no brainer), maybe associate with .hi files for binaries.<br />
<br />
*Maybe a class <code>YiShow</code>, which all config items must be a member of? This is to emulate describe-variable<br />
<br />
*Support for collaborative editing. This would be very good for #haskell work, and the text editor Gobby and its [http://gobby.0x539.de/trac/wiki/ObbyProtocol Obby protocol] seem to provide a candidate way of doing things.<br />
<br />
<br />
=== Borrowing from other editors ===<br />
Take some ideas from Emacs, some from vi, but don't stick them all together without a single core philosophy. Otherwise, you'll end up with an editor that looks like it was thrown together. Some people come from an Emacs background, some from vi, some from elsewhere, and ALL of them will want Yi to behave like their regular editor. The best way to do this is to have a single person make all the decisions on behavior.<br />
<br />
==== Emacs ====<br />
<br />
Coming from an Emacs background, I think a few things are essential,<br />
mainly the introspection capabilities of Emacs.<br />
<br />
===== Emacs goodness =====<br />
<br />
The following are things I like about Emacs, as an extensible<br />
environment, and miss in Yi:<br />
<br />
; Really good online documentation<br />
: Emacs can tell you a lot about a function or variable with a keypress--- the current value, where it is declared, and a hypertext formation string<br />
<br />
; Hooks-Extensibility<br />
: All (good) apps allow users to extend, through, e.g., hooks --- a list of functions that are run before/after some event (like saving a file)<br />
<br />
; List of must-have features<br />
: http://glyph.twistedmatrix.com/2008/12/emacs-test.html<br />
<br />
<br />
===== Emacs badness =====<br />
<br />
So, why replace it?:<br />
; ELisp<br />
: Dynamically scoped, Dynamically typed, ugly, old. 'Nuff said<br />
<br />
; What's a Parser?<br />
: A lot of apps in emacs do stuff with text, usually text that is in some language. There is no standard parser (like, e.g. parsec), so a lot of it is ugly handwritten spaghetti. This also means that adding analysis tools isn't really done (or done nicely).<br />
<br />
; ELisp again<br />
: Haskell is a lot cleaner to write, especially because of the large number of libraries.<br />
<br />
(See also [http://www.emacswiki.org/cgi-bin/wiki/WhyDoesElispSuck WhyDoesElispSuck] on the Emacs wiki.)<br />
<br />
===== Emacs maybeness (?) =====<br />
<br />
Some things that are sometimes bad, sometimes good:<br />
<br />
; Everything is a buffer<br />
: Makes some sense, but sometimes doesn't. It is nice to have uniform key bindings do the right thing (e.g., C-Space sets the mark, and the region can then be used, e.g. to delete a sequence of emails in Wl) Sometimes, however, you just want some sort of GUI widget.<br />
: OTOH, having the minibuffer be a special kind of buffer is a good idea.<br />
<br />
; Properties<br />
: It is possible to associate arbitrary properties with symbols. This means you can annotate a symbol and then use that information at a later date<br />
<br />
==== Vim? ====<br />
<br />
; good things<br />
: modal key editing -> configuration system is powerful enough!<br />
: light weight -> fast startup -> yi has this :)<br />
<br />
<br />
=== Ideas ===<br />
<br />
=== Implementation ===<br />
<br />
Considerations:<br />
<br />
; Interface to the runtime<br />
: The scheduler, docs, etc.<br />
<br />
; Introspection of e.g. what processes are running.<br />
: There are already libraries in Haskell for processes, but they don't give Yi any extra information --- we really want a layer on top.<br />
<br />
...<br />
<br />
== Trivia ==<br />
<br />
;Y I is the most recursive acronym. (Read it as combinators).<br />
;義, pronounced yi, means righteousness, one of the five virtues of confucianism.<br />
;Yi is the symbol for a yobi - the largest [http://en.wikipedia.org/wiki/Binary_prefix#Prefixes binary prefix], meaning 2^80<br />
<br />
== External links ==<br />
<br />
* Blog: http://yi-editor.blogspot.com/<br />
* Haddock: http://projects.haskell.org/yi/doc/<br />
* Repository: https://github.com/yi-editor/yi<br />
* Issues tracker: https://github.com/yi-editor/yi/issues<br />
* Hackage page: http://hackage.haskell.org/package/yi<br />
* IRC channel: #yi on Freenode</div>Fuuzetsuhttps://wiki.haskell.org/index.php?title=Yi&diff=57496Yi2014-01-26T23:40:38Z<p>Fuuzetsu: /* About */ Cocoa was removed from Yi</p>
<hr />
<div>[[Category:Applications]]<br />
<br />
[[Image:Yi-logo.png]]<br />
<br />
== About ==<br />
<br />
Yi is a text editor written in Haskell and extensible in Haskell. The goal of Yi is<br />
to provide a flexible, powerful and correct editor core<br />
scriptable in Haskell.<br />
<br />
Features:<br />
<br />
* A purely functional editor core;<br />
* Keybindings written as parsers of the input;<br />
* Emacs, Vim and Cua (subset) emulations provided by default;<br />
* Vty, GTK+ w/ Pango(via Gtk2Hs), and, in development, GTK+ w/ VTE frontends.<br />
<br />
The long term goal of the project is to make Yi the editor of choice for Haskell hackers.<br />
<br />
The main short term goal is to maximize Yi's Fun Factor. This includes:<br />
* Improve hackability (and therefore architecture)<br />
* Add cool features<br />
<br />
== Get Yi ==<br />
<br />
=== From Hackage ===<br />
<br />
Yi depends on the [http://haskell.org/platform Haskell Platform] which must be installed. Many Haskellers haven't installed this explicitly, as they have already installed most of the utilities it contains; to be sure you have everything that is needed, it is recommended that you explicitly install the Platform.<br />
<br />
Following that, simply:<br />
<br />
$ cabal update<br />
$ cabal install yi<br />
<br />
More information about the package is available at [http://hackage.haskell.org/package/yi Yi on Hackage].<br />
<br />
=== From GitHub ===<br />
<br />
See the GitHub [https://github.com/yi-editor/yi repository]. Or get it with git:<br />
<br />
$ git clone git://github.com/yi-editor/yi.git<br />
<br />
We try to keep the repository in a clean and buildable state, so it's "testable" for new users. Yi usually only works on the latest GHC release.<br />
<br />
''Note that the old yi-contrib repository is now just a subdirectory of the yi repo.''<br />
<br />
=== Platform Support ===<br />
<br />
==== GNU/Linux ====<br />
<br />
Some GNU/Linux distros have pre-built Yi packages. For Debian/Ubuntu packages, see [https://groups.google.com/forum/?fromgroups=#!topic/yi-devel/XSzWSv1HBmQ this post in the yi-devel mailing list].<br />
<br />
==== Mac OS X ====<br />
<br />
The easiest way to get Yi for Mac OS X is currently no different from the above. There is also a Yi release in MacPorts, but it might be very old, deprecated one. Please use the Hackage version instead.<br />
<br />
==== Windows ====<br />
<br />
The current version of Yi on Hackage (0.6.6.0) can be built on Windows.<br />
<br />
First, you should install the current version of [http://www.haskell.org/platform/windows.html Haskell Platform for Windows]. The version 2012.4.0.0 is known to work with Yi 0.6.6.0. Make sure that your Haskell compiler and tools are on your PATH.<br />
<br />
Next, you should install [http://www.gtk.org/download/win32.php GTK+ for Windows]. You have to use "All-in-one bundles", not individual packages. Download and unpack the archive, then again make sure that GTK+ utilities are on your PATH.<br />
<br />
Now, you can invoke cabal-Install from the command prompt.<br />
<br />
$ cabal update<br />
$ cabal install gtk2hs-buildtools<br />
$ cabal install gtk<br />
$ cabal install yi -f-vty -fpango<br />
<br />
Make sure that you do Configure with flag -f-vty -fpango to force enabling Pango and disabling Vty interface, since Vty is not supported in Windows.<br />
<br />
== Screenshots (0.3) ==<br />
<br />
[[Image:Yi-20070409.png|thumb|right|500px|The GTK frontend]]<br />
[[Image:Yi-20080114-vty.png|thumb|none|500px|The Vty frontend]]<br />
<br />
== News ==<br />
<br />
There is a Yi blog, that reports the important news about Yi, at [http://yi-editor.blogspot.com/ http://yi-editor.blogspot.com/]. It also delves into algorithms and the Yi internals.<br />
<br />
You can also check the [[/OldNews]].<br />
<br />
== Bugs ==<br />
<br />
Check/report bug reports here: [https://github.com/yi-editor/yi/issues GitHub issue tracker]<br />
<br />
== FAQs ==<br />
<br />
{{/FAQ}}<br />
<br />
== Contribute ==<br />
<br />
Fork the source on GitHub and send pull requests for merges. Or consult the yi-devel mailing list. Patches are always welcome. :)<br />
<br />
Otherwise, see [https://github.com/yi-editor/yi/issues the complete list of open issues] here.<br />
<br />
(Note you can start working on all issues in<br />
New/Accepted state, regardless of the owner of the issue.<br />
-- you can send an email to the list with your plan if unsure)<br />
<br />
Post your questions and follow up on [http://groups.google.com/group/yi-devel the yi-devel mailing list].<br />
Some other pending tasks are described below.<br />
<br />
=== Write access policy ===<br />
<br />
One does not need write access to the repository to contribute. Please fork the main repository and send pull requests.<br />
<br />
Write access can however be granted, with the following disclaimer:<br />
<br />
* All people with write access can apply patches without prior approval. If one thinks a patch would be controversial, it might be a good idea to discuss it on the list though.<br />
* Try to not break the build. (By Murphy's law, if you do so it will happen at the most annoying moment...) So, always try to build before pushing patches. Bypassing the test build to record a patch indicates you should further improve your patch.<br />
* [[JeanPhilippeBernardy | I]] can at any time rollback a patch for whatever reason. This however should not upset the author of the patch. Most contributions are welcome, so a patch revert normally would only mean that a detail or two need to be worked out. (e.g. it breaks an important feature in some configuration, etc.)<br />
<br />
== Yi Ideas ==<br />
<br />
This section is meant to gather ideas people have for Yi.<br />
<br />
*Evolution to an IDE:<br />
:Show exact location of compilation errors: 80% of a Haskell project<br />
:Support for the GHCi debugger & others: 10 % of a Haskell project (Added bonus: greath for learning: trough the debugger, people learn the real execution flow of a Haskell program. Better if this is done inside an editor)<br />
:Integration of refactoring tools : 5 %<br />
:Edition: only 5%<br />
<br />
<br />
*An extension to GHCi to support documentation of symbols.<br />
:This seems to be (reasonably) straightforward, as GHCi already has :info. It would mean hacking the type environment (what about values?) to add documentation information. The main problem would seem to be populating this --- maybe hack haddock to produce something from the library docs? I assume that using package GHC uses the parent RTS (package GHC seems to be the way to go, but more investigation is required --- don?)<br />
<br />
*Views on data<br />
:Rather than just editing a file, you would open a view onto the file, i.e. there is no longer a 1-1 correspondence between buffers and files. Why? Well, for aggregate buffers (i.e., editing multiple files in the one view), or for multiple views of a file (e.g. AST and source-level). There would be some primitive ops for editing a buffer (insertChar, delete, etc.), which would then call update functions on anything observing that file.<br />
<br />
*Support for Perl style regular expressions<br />
:Emacs regexes don't support the same set of features; Perl regexes are more tersely powerful. This could be a good feature for luring users from vanilla Emacs.<br />
<br />
*Remote attach so I can work from home, but still use a remote machine<br />
:Like Emacs's server?<br />
<br />
*Haddock documentation<br />
:(no brainer), maybe associate with .hi files for binaries.<br />
<br />
*Maybe a class <code>YiShow</code>, which all config items must be a member of? This is to emulate describe-variable<br />
<br />
*Support for collaborative editing. This would be very good for #haskell work, and the text editor Gobby and its [http://gobby.0x539.de/trac/wiki/ObbyProtocol Obby protocol] seem to provide a candidate way of doing things.<br />
<br />
<br />
=== Borrowing from other editors ===<br />
Take some ideas from Emacs, some from vi, but don't stick them all together without a single core philosophy. Otherwise, you'll end up with an editor that looks like it was thrown together. Some people come from an Emacs background, some from vi, some from elsewhere, and ALL of them will want Yi to behave like their regular editor. The best way to do this is to have a single person make all the decisions on behavior.<br />
<br />
==== Emacs ====<br />
<br />
Coming from an Emacs background, I think a few things are essential,<br />
mainly the introspection capabilities of Emacs.<br />
<br />
===== Emacs goodness =====<br />
<br />
The following are things I like about Emacs, as an extensible<br />
environment, and miss in Yi:<br />
<br />
; Really good online documentation<br />
: Emacs can tell you a lot about a function or variable with a keypress--- the current value, where it is declared, and a hypertext formation string<br />
<br />
; Hooks-Extensibility<br />
: All (good) apps allow users to extend, through, e.g., hooks --- a list of functions that are run before/after some event (like saving a file)<br />
<br />
; List of must-have features<br />
: http://glyph.twistedmatrix.com/2008/12/emacs-test.html<br />
<br />
<br />
===== Emacs badness =====<br />
<br />
So, why replace it?:<br />
; ELisp<br />
: Dynamically scoped, Dynamically typed, ugly, old. 'Nuff said<br />
<br />
; What's a Parser?<br />
: A lot of apps in emacs do stuff with text, usually text that is in some language. There is no standard parser (like, e.g. parsec), so a lot of it is ugly handwritten spaghetti. This also means that adding analysis tools isn't really done (or done nicely).<br />
<br />
; ELisp again<br />
: Haskell is a lot cleaner to write, especially because of the large number of libraries.<br />
<br />
(See also [http://www.emacswiki.org/cgi-bin/wiki/WhyDoesElispSuck WhyDoesElispSuck] on the Emacs wiki.)<br />
<br />
===== Emacs maybeness (?) =====<br />
<br />
Some things that are sometimes bad, sometimes good:<br />
<br />
; Everything is a buffer<br />
: Makes some sense, but sometimes doesn't. It is nice to have uniform key bindings do the right thing (e.g., C-Space sets the mark, and the region can then be used, e.g. to delete a sequence of emails in Wl) Sometimes, however, you just want some sort of GUI widget.<br />
: OTOH, having the minibuffer be a special kind of buffer is a good idea.<br />
<br />
; Properties<br />
: It is possible to associate arbitrary properties with symbols. This means you can annotate a symbol and then use that information at a later date<br />
<br />
==== Vim? ====<br />
<br />
; good things<br />
: modal key editing -> configuration system is powerful enough!<br />
: light weight -> fast startup -> yi has this :)<br />
<br />
<br />
=== Ideas ===<br />
<br />
=== Implementation ===<br />
<br />
Considerations:<br />
<br />
; Interface to the runtime<br />
: The scheduler, docs, etc.<br />
<br />
; Introspection of e.g. what processes are running.<br />
: There are already libraries in Haskell for processes, but they don't give Yi any extra information --- we really want a layer on top.<br />
<br />
...<br />
<br />
== Trivia ==<br />
<br />
;Y I is the most recursive acronym. (Read it as combinators).<br />
;義, pronounced yi, means righteousness, one of the five virtues of confucianism.<br />
;Yi is the symbol for a yobi - the largest [http://en.wikipedia.org/wiki/Binary_prefix#Prefixes binary prefix], meaning 2^80<br />
<br />
== External links ==<br />
<br />
* Blog: http://yi-editor.blogspot.com/<br />
* Haddock: http://projects.haskell.org/yi/doc/<br />
* Repository: https://github.com/yi-editor/yi<br />
* Issues tracker: https://github.com/yi-editor/yi/issues<br />
* Hackage page: http://hackage.haskell.org/package/yi<br />
* IRC channel: #yi on Freenode</div>Fuuzetsuhttps://wiki.haskell.org/index.php?title=Yi/FAQ&diff=57491Yi/FAQ2014-01-25T23:26:50Z<p>Fuuzetsu: /* GError on startup */ s/Darcs/GitHub</p>
<hr />
<div>=== Installation ===<br />
<br />
*How do I install Yi?<br />
:Get it from Hackage. Configure, compile and install Yi as you would do for any other Cabal package. See also above-mentioned (2.3 Platform Support).<br />
<br />
*Setup configure fails with<br />
Setup.hs: Package yi-0.4 can't be built on this system.<br />
:It means that you have no UI package available. You need VTY or GTK2hs installed. Get them from Hackage.<br />
<br />
*cabal install yi fails with dependency errors, e.g.:<br />
$ cabal install yi<br />
Resolving dependencies...<br />
cabal.exe: dependencies conflict: ghc-6.8.3 requires bytestring ==0.9.0.1.1<br />
however<br />
bytestring-0.9.0.1.1 was excluded because bytestring-0.9.0.1 was selected<br />
instead<br />
bytestring-0.9.0.1.1 was excluded because yi-0.3 requires bytestring =0.9.0.1<br />
:Try removing all your old yi packages, and do<br />
cabal update<br />
before attempting to install.<br />
<br />
*cabal install -fghcAPI fails<br />
:If you want GHC API special capabilities, you have to download, configure, build and copy separately:<br />
cd yi<br />
cabal configure -fghcAPI<br />
cabal build<br />
cabal copy<br />
<br />
* Compilation fails with a message about <tt>alex</tt> not being available?<br />
: Currently, Cabal doesn't track programs, just libraries, so it won't warn you if you are missing Alex (as many people are). The solution here is to just <tt>cabal install alex</tt> first. (Yi uses Alex to generate code for parsing stuff with syntax, like Haskell source.)<br />
<br />
* I can't install <tt>yi-gtk</tt> or <tt>yi-vty</tt>! It wants <tt>sourceview</tt> or something.<br />
: As the Hackage descriptions say, yi-gtk and yi-vty are ''only'' for versions of older than Yi 0.3. You really should be running the latest development (GitHub) or stable (Hackage) versions of Yi, so ''don't'' try to install these two packages. Yi supports VTY and Gtk2hs directly in the <tt>yi</tt> package now.<br />
*On Mac OS X if you get an error message similar to this:<br />
yi: can't load .so/.DLL for: gthread-2.0 (dlopen(libgthread-2.0.dylib, 10): image not found)<br />
<br />
:then your dynamic library search path variable is probably not set correctly. You can set it (in Bash) using:<br />
<br />
export DYLD_LIBRARY_PATH=/opt/local/lib<br />
<br />
:(Adjust the specific path to your system. You can find the right location using <tt>locate libgthread</tt>)<br />
<br />
*On Mac OS 10.6 (Snow Leopard) if you get the following error:<br />
Loading package cairo-0.11.1 ... <command line>: can't load .so/.DLL for: pixman-1 (dlopen(/opt/local/lib/libpixman-1.dylib, 9): no suitable image found. Did find:<br />
/opt/local/lib/libpixman-1.dylib: mach-o, but wrong architecture)<br />
cabal: Error: some packages failed to install:<br />
yi-0.6.2.4 failed during the building phase. The exception was:<br />
ExitFailure 1<br />
<br />
:then the problem is that GHC currently only supports linking against i386 libraries, and your ports are compiled for x86_64. To fix, recompile your ports with the +universal variant like so:<br />
<br />
port install installed +universal<br />
<br />
* Compilation fails with errors about template-haskell or data-accessor:<br />
Add constraints about which release of those libraries to use.<br />
$ cabal install yi --constraint="data-accessor < 0.2.1" --constraint="template-haskell < 2.4"<br />
<br />
=== Default key bindings ===<br />
<br />
==== CUA key bindings ====<br />
<br />
===== File operations =====<br />
{|<br />
| Ctrl-o<br />
| Open file.<br />
|-<br />
| Ctrl-s<br />
| Save the current file.<br />
|-<br />
| Ctrl-q<br />
| Quit the editor.<br />
|}<br />
<br />
===== Cursor/selection movement =====<br />
{|<br />
| &rarr;<br />
| Move cursor forward one character.<br />
|-<br />
| &larr;<br />
| Move cursor back one character.<br />
|-<br />
| &darr;<br />
| Move cursor down one line.<br />
|-<br />
| &uarr;<br />
| Move cursor down one line.<br />
|-<br />
| Shift+&rarr;<br />
| Extend selection forward one character.<br />
|-<br />
| Shift+&larr;<br />
| Extend selection back one character.<br />
|-<br />
| Shift+&darr;<br />
| Extend selection down one line.<br />
|-<br />
| Shift+&uarr;<br />
| Extend selection up one line.<br />
|-<br />
| Ctrl-&rarr;<br />
| Move cursor forward one word.<br />
|-<br />
| Ctrl-&larr;<br />
| Move cursor back one word.<br />
|-<br />
| Home<br />
| Move cursor to beginning of line.<br />
|-<br />
| End<br />
| Move cursor to end of line.<br />
|-<br />
| Ctrl-Home<br />
| Move cursor to beginning of document.<br />
|-<br />
| Ctrl-End<br />
| Move cursor to end of document.<br />
|}<br />
<br />
===== Miscellaneous operations =====<br />
<br />
{|<br />
| Ctrl-f<br />
| Incremental search.<br />
|-<br />
| Ctrl-x<br />
| Cut the selected area and save it to the clipboard<br />
|-<br />
| Ctrl-c<br />
| Copy the selected area to the clipboard<br />
|-<br />
| Ctrl-v<br />
| Paste contents of clipboard at cursor.<br />
|-<br />
| Ctrl-z<br />
| Undo last operation.<br />
|-<br />
| Ctrl-y<br />
| Redo last operation.<br />
|}<br />
<br />
==== Vim key bindings ====<br />
==== Emacs key bindings ====<br />
<br />
C = Control<br />
<br />
M = Meta = Alt|Esc<br />
<br />
===== Basics =====<br />
{|<br />
|C-x C-f<br />
|"Find" file i.e. open/create a file in buffer<br />
|-<br />
|C-x C-s<br />
|Save the file<br />
|-<br />
|C-x C-w<br />
|Write the text to an alternate name<br />
|-<br />
|C-x i<br />
|Insert file at cursor position<br />
|-<br />
|C-x b<br />
|Create/switch buffers<br />
|-<br />
|C-x C-b<br />
|Show buffer list<br />
|-<br />
|C-x k<br />
|Kill buffer<br />
|-<br />
|C-z<br />
|Suspend Yi<br />
|-<br />
|C-x C-c<br />
|Close down Yi<br />
|}<br />
<br />
===== Basic movement =====<br />
<br />
{|<br />
|C-f<br />
|Forward char<br />
|-<br />
|C-b<br />
|Backward char<br />
|-<br />
|C-p<br />
|Previous line<br />
|-<br />
|C-n<br />
|Next line<br />
|-<br />
|M-f<br />
|Forward one word<br />
|-<br />
|M-b<br />
|Backward one word<br />
|-<br />
|C-a<br />
|Beginning of line<br />
|-<br />
|C-e<br />
|End of line<br />
|-<br />
|C-v<br />
|One page up<br />
|-<br />
|M-v<br />
|Scroll down one page<br />
|-<br />
|M-<<br />
|Beginning of text<br />
|-<br />
|M-><br />
|End of text<br />
|}<br />
<br />
===== Editing =====<br />
<br />
{|<br />
|M-n<br />
|Repeat the following command n times<br />
|-<br />
|C-u<br />
|Repeat the following command 4 times<br />
|-<br />
|C-d<br />
|Delete a char<br />
|-<br />
|M-d<br />
|Delete word<br />
|-<br />
|M-Del<br />
|Delete word backwards<br />
|-<br />
|C-k<br />
|Kill line<br />
|-<br />
|C-Space<br />
|Set beginning mark (for region marking for example)<br />
|-<br />
|C-W<br />
|"Kill" (delete) the marked region region<br />
|-<br />
|M-W<br />
|Copy the marked region<br />
|-<br />
|C-y<br />
|"Yank" (paste) the copied/killed region/line<br />
|-<br />
|M-y<br />
|Yank earlier text (cycle through kill buffer)<br />
|-<br />
|C-x C-x<br />
|Exchange cursor and mark<br />
|-<br />
|C-t<br />
|Transpose two chars<br />
|-<br />
|M-t<br />
|Transpose two words<br />
|-<br />
|M-u<br />
|Make letters uppercase in word from cursor position to end<br />
|-<br />
|M-c<br />
|Simply make first letter in word uppercase<br />
|-<br />
|M-l<br />
|Opposite to M-u<br />
|}<br />
<br />
===== Important =====<br />
<br />
{|<br />
|C-g<br />
|Quit the running/entered command<br />
|-<br />
|C-x u<br />
|Undo previous action<br />
|-<br />
|M-/<br />
|Undo previous action<br />
|}<br />
<br />
===== Search/Replace =====<br />
<br />
{|<br />
|C-s<br />
|Search forward<br />
|-<br />
|C-r<br />
|Search backward<br />
|-<br />
|M-%<br />
|Query replace<br />
|-<br />
|Space or y<br />
|Replace this occurrence<br />
|-<br />
|Del or n<br />
|Don't replace<br />
|-<br />
|!<br />
|Replace all following occurrences<br />
|-<br />
|ENTER or q<br />
|Quit replace<br />
|}<br />
<br />
===== Window-Commands =====<br />
<br />
{|<br />
|C-x 2<br />
|Split window vertically<br />
|-<br />
|C-x o<br />
|Change to other window<br />
|-<br />
|C-x 0<br />
|Delete window<br />
|-<br />
|C-x 1<br />
|Close all windows except the one the cursors in<br />
|}<br />
<br />
===== DIRectory EDitor (dired) =====<br />
<br />
{|<br />
|C-x d<br />
|Start up dired<br />
|-<br />
|C (large C)<br />
|Copy<br />
|-<br />
|d<br />
|Mark for erase<br />
|-<br />
|D<br />
|Delete right away<br />
|-<br />
|e or f<br />
|Open file or directory<br />
|-<br />
|g<br />
|Re-read directory structure from file<br />
|-<br />
|m<br />
|Mark with *<br />
|-<br />
|n<br />
|Move to next line<br />
|-<br />
|q<br />
|Quit dired<br />
|-<br />
|R<br />
|Rename file<br />
|-<br />
|u<br />
|Remove mark<br />
|-<br />
|x<br />
|Delete files marked with D<br />
|-<br />
| +<br />
|Create directory<br />
|}<br />
<br />
===== Programming =====<br />
<br />
{|<br />
|M-m<br />
|Move to first (non-space) char in this line<br />
|-<br />
|M-^<br />
|Attach this line to previous<br />
|-<br />
|M-;<br />
|Formatize and indent comment<br />
|-<br />
<br />
===== C, C++ and Java Modes =====<br />
<br />
{|<br />
|M-a<br />
|Beginning of statement<br />
|-<br />
|M-e<br />
|End of statement<br />
|-<br />
|C-c C-c<br />
|Comment out marked area<br />
|}<br />
<br />
=== Development ===<br />
<br />
*How do I install Yi for development?<br />
:Fork the repository on GitHub, then clone your version to your machine. Push to your repo on GitHub, and then make merge requests.<br />
<br />
*What are some of the dependancies?<br />
:There is a rather long list of dependencies for Yi, check the yi.cabal file for a list.<br />
<br />
::If you are on Mac OS X and are using MacPorts, then these will not be included in the GHC in that distribution. Many of the dependancies are in MacPorts (for example: ghc, ghc-devel, alex, and gtk2hs). However, you may have some trouble building with Cabal-1.5.2, since it is a development version of Cabal. To work around these issues, you might have to add the line "Build-Type: Simple" to the .cabal files in the above required packages.<br />
<br />
=== Configuration ===<br />
<br />
==== How to Configure Yi ====<br />
<br />
You can find configuration file examples in the 'examples/' directory, or online at [http://code.haskell.org/yi/examples/ http://code.haskell.org/yi/examples/].<br />
<br />
You can find some user configs at [https://github.com/yi-editor/yi/tree/master/yi-contrib/src/Yi/Config/Users https://github.com/yi-editor/yi/tree/master/yi-contrib/src/Yi/Config/Users]<br />
<br />
A good way to start is to copy yi.hs in your $XDG_CONFIG_HOME/yi directory (create it if needed), and hack as needed.<br />
<br />
=== Usage ===<br />
==== GError on startup ====<br />
I get the error message "yi.exe: <<System.Glib.GError.GError>>" when I try to run yi.<br />
<br />
Sometimes this is a result of yi not being able to find the contents of the art directory when trying to start in graphical mode (e.g. Gtk or Pango). Check that the install has be done correctly or use the VTY mode (<tt>$ yi -f vty</tt>).<br />
<br />
For more detail on the error, modify main in Yi/Main.hs to catch GError:<br />
<pre><br />
Right finalCfg -> do catchGError (do<br />
when (debugMode finalCfg) $ initDebug ".yi.dbg" <br />
startEditor finalCfg state) (\(GError dom code msg) -> fail msg)<br />
</pre><br />
<br />
Note that more recent versions of Yi (e.g. from the GitHub repo) no longer simply display the anonymous GError but instead provide a more detailed error message (making the above code snippet unnecessary).<br />
<br />
[[Category:FAQ]]</div>Fuuzetsuhttps://wiki.haskell.org/index.php?title=Yi/FAQ&diff=57490Yi/FAQ2014-01-25T23:26:28Z<p>Fuuzetsu: /* Installation */ s/Darcs/GitHub/</p>
<hr />
<div>=== Installation ===<br />
<br />
*How do I install Yi?<br />
:Get it from Hackage. Configure, compile and install Yi as you would do for any other Cabal package. See also above-mentioned (2.3 Platform Support).<br />
<br />
*Setup configure fails with<br />
Setup.hs: Package yi-0.4 can't be built on this system.<br />
:It means that you have no UI package available. You need VTY or GTK2hs installed. Get them from Hackage.<br />
<br />
*cabal install yi fails with dependency errors, e.g.:<br />
$ cabal install yi<br />
Resolving dependencies...<br />
cabal.exe: dependencies conflict: ghc-6.8.3 requires bytestring ==0.9.0.1.1<br />
however<br />
bytestring-0.9.0.1.1 was excluded because bytestring-0.9.0.1 was selected<br />
instead<br />
bytestring-0.9.0.1.1 was excluded because yi-0.3 requires bytestring =0.9.0.1<br />
:Try removing all your old yi packages, and do<br />
cabal update<br />
before attempting to install.<br />
<br />
*cabal install -fghcAPI fails<br />
:If you want GHC API special capabilities, you have to download, configure, build and copy separately:<br />
cd yi<br />
cabal configure -fghcAPI<br />
cabal build<br />
cabal copy<br />
<br />
* Compilation fails with a message about <tt>alex</tt> not being available?<br />
: Currently, Cabal doesn't track programs, just libraries, so it won't warn you if you are missing Alex (as many people are). The solution here is to just <tt>cabal install alex</tt> first. (Yi uses Alex to generate code for parsing stuff with syntax, like Haskell source.)<br />
<br />
* I can't install <tt>yi-gtk</tt> or <tt>yi-vty</tt>! It wants <tt>sourceview</tt> or something.<br />
: As the Hackage descriptions say, yi-gtk and yi-vty are ''only'' for versions of older than Yi 0.3. You really should be running the latest development (GitHub) or stable (Hackage) versions of Yi, so ''don't'' try to install these two packages. Yi supports VTY and Gtk2hs directly in the <tt>yi</tt> package now.<br />
*On Mac OS X if you get an error message similar to this:<br />
yi: can't load .so/.DLL for: gthread-2.0 (dlopen(libgthread-2.0.dylib, 10): image not found)<br />
<br />
:then your dynamic library search path variable is probably not set correctly. You can set it (in Bash) using:<br />
<br />
export DYLD_LIBRARY_PATH=/opt/local/lib<br />
<br />
:(Adjust the specific path to your system. You can find the right location using <tt>locate libgthread</tt>)<br />
<br />
*On Mac OS 10.6 (Snow Leopard) if you get the following error:<br />
Loading package cairo-0.11.1 ... <command line>: can't load .so/.DLL for: pixman-1 (dlopen(/opt/local/lib/libpixman-1.dylib, 9): no suitable image found. Did find:<br />
/opt/local/lib/libpixman-1.dylib: mach-o, but wrong architecture)<br />
cabal: Error: some packages failed to install:<br />
yi-0.6.2.4 failed during the building phase. The exception was:<br />
ExitFailure 1<br />
<br />
:then the problem is that GHC currently only supports linking against i386 libraries, and your ports are compiled for x86_64. To fix, recompile your ports with the +universal variant like so:<br />
<br />
port install installed +universal<br />
<br />
* Compilation fails with errors about template-haskell or data-accessor:<br />
Add constraints about which release of those libraries to use.<br />
$ cabal install yi --constraint="data-accessor < 0.2.1" --constraint="template-haskell < 2.4"<br />
<br />
=== Default key bindings ===<br />
<br />
==== CUA key bindings ====<br />
<br />
===== File operations =====<br />
{|<br />
| Ctrl-o<br />
| Open file.<br />
|-<br />
| Ctrl-s<br />
| Save the current file.<br />
|-<br />
| Ctrl-q<br />
| Quit the editor.<br />
|}<br />
<br />
===== Cursor/selection movement =====<br />
{|<br />
| &rarr;<br />
| Move cursor forward one character.<br />
|-<br />
| &larr;<br />
| Move cursor back one character.<br />
|-<br />
| &darr;<br />
| Move cursor down one line.<br />
|-<br />
| &uarr;<br />
| Move cursor down one line.<br />
|-<br />
| Shift+&rarr;<br />
| Extend selection forward one character.<br />
|-<br />
| Shift+&larr;<br />
| Extend selection back one character.<br />
|-<br />
| Shift+&darr;<br />
| Extend selection down one line.<br />
|-<br />
| Shift+&uarr;<br />
| Extend selection up one line.<br />
|-<br />
| Ctrl-&rarr;<br />
| Move cursor forward one word.<br />
|-<br />
| Ctrl-&larr;<br />
| Move cursor back one word.<br />
|-<br />
| Home<br />
| Move cursor to beginning of line.<br />
|-<br />
| End<br />
| Move cursor to end of line.<br />
|-<br />
| Ctrl-Home<br />
| Move cursor to beginning of document.<br />
|-<br />
| Ctrl-End<br />
| Move cursor to end of document.<br />
|}<br />
<br />
===== Miscellaneous operations =====<br />
<br />
{|<br />
| Ctrl-f<br />
| Incremental search.<br />
|-<br />
| Ctrl-x<br />
| Cut the selected area and save it to the clipboard<br />
|-<br />
| Ctrl-c<br />
| Copy the selected area to the clipboard<br />
|-<br />
| Ctrl-v<br />
| Paste contents of clipboard at cursor.<br />
|-<br />
| Ctrl-z<br />
| Undo last operation.<br />
|-<br />
| Ctrl-y<br />
| Redo last operation.<br />
|}<br />
<br />
==== Vim key bindings ====<br />
==== Emacs key bindings ====<br />
<br />
C = Control<br />
<br />
M = Meta = Alt|Esc<br />
<br />
===== Basics =====<br />
{|<br />
|C-x C-f<br />
|"Find" file i.e. open/create a file in buffer<br />
|-<br />
|C-x C-s<br />
|Save the file<br />
|-<br />
|C-x C-w<br />
|Write the text to an alternate name<br />
|-<br />
|C-x i<br />
|Insert file at cursor position<br />
|-<br />
|C-x b<br />
|Create/switch buffers<br />
|-<br />
|C-x C-b<br />
|Show buffer list<br />
|-<br />
|C-x k<br />
|Kill buffer<br />
|-<br />
|C-z<br />
|Suspend Yi<br />
|-<br />
|C-x C-c<br />
|Close down Yi<br />
|}<br />
<br />
===== Basic movement =====<br />
<br />
{|<br />
|C-f<br />
|Forward char<br />
|-<br />
|C-b<br />
|Backward char<br />
|-<br />
|C-p<br />
|Previous line<br />
|-<br />
|C-n<br />
|Next line<br />
|-<br />
|M-f<br />
|Forward one word<br />
|-<br />
|M-b<br />
|Backward one word<br />
|-<br />
|C-a<br />
|Beginning of line<br />
|-<br />
|C-e<br />
|End of line<br />
|-<br />
|C-v<br />
|One page up<br />
|-<br />
|M-v<br />
|Scroll down one page<br />
|-<br />
|M-<<br />
|Beginning of text<br />
|-<br />
|M-><br />
|End of text<br />
|}<br />
<br />
===== Editing =====<br />
<br />
{|<br />
|M-n<br />
|Repeat the following command n times<br />
|-<br />
|C-u<br />
|Repeat the following command 4 times<br />
|-<br />
|C-d<br />
|Delete a char<br />
|-<br />
|M-d<br />
|Delete word<br />
|-<br />
|M-Del<br />
|Delete word backwards<br />
|-<br />
|C-k<br />
|Kill line<br />
|-<br />
|C-Space<br />
|Set beginning mark (for region marking for example)<br />
|-<br />
|C-W<br />
|"Kill" (delete) the marked region region<br />
|-<br />
|M-W<br />
|Copy the marked region<br />
|-<br />
|C-y<br />
|"Yank" (paste) the copied/killed region/line<br />
|-<br />
|M-y<br />
|Yank earlier text (cycle through kill buffer)<br />
|-<br />
|C-x C-x<br />
|Exchange cursor and mark<br />
|-<br />
|C-t<br />
|Transpose two chars<br />
|-<br />
|M-t<br />
|Transpose two words<br />
|-<br />
|M-u<br />
|Make letters uppercase in word from cursor position to end<br />
|-<br />
|M-c<br />
|Simply make first letter in word uppercase<br />
|-<br />
|M-l<br />
|Opposite to M-u<br />
|}<br />
<br />
===== Important =====<br />
<br />
{|<br />
|C-g<br />
|Quit the running/entered command<br />
|-<br />
|C-x u<br />
|Undo previous action<br />
|-<br />
|M-/<br />
|Undo previous action<br />
|}<br />
<br />
===== Search/Replace =====<br />
<br />
{|<br />
|C-s<br />
|Search forward<br />
|-<br />
|C-r<br />
|Search backward<br />
|-<br />
|M-%<br />
|Query replace<br />
|-<br />
|Space or y<br />
|Replace this occurrence<br />
|-<br />
|Del or n<br />
|Don't replace<br />
|-<br />
|!<br />
|Replace all following occurrences<br />
|-<br />
|ENTER or q<br />
|Quit replace<br />
|}<br />
<br />
===== Window-Commands =====<br />
<br />
{|<br />
|C-x 2<br />
|Split window vertically<br />
|-<br />
|C-x o<br />
|Change to other window<br />
|-<br />
|C-x 0<br />
|Delete window<br />
|-<br />
|C-x 1<br />
|Close all windows except the one the cursors in<br />
|}<br />
<br />
===== DIRectory EDitor (dired) =====<br />
<br />
{|<br />
|C-x d<br />
|Start up dired<br />
|-<br />
|C (large C)<br />
|Copy<br />
|-<br />
|d<br />
|Mark for erase<br />
|-<br />
|D<br />
|Delete right away<br />
|-<br />
|e or f<br />
|Open file or directory<br />
|-<br />
|g<br />
|Re-read directory structure from file<br />
|-<br />
|m<br />
|Mark with *<br />
|-<br />
|n<br />
|Move to next line<br />
|-<br />
|q<br />
|Quit dired<br />
|-<br />
|R<br />
|Rename file<br />
|-<br />
|u<br />
|Remove mark<br />
|-<br />
|x<br />
|Delete files marked with D<br />
|-<br />
| +<br />
|Create directory<br />
|}<br />
<br />
===== Programming =====<br />
<br />
{|<br />
|M-m<br />
|Move to first (non-space) char in this line<br />
|-<br />
|M-^<br />
|Attach this line to previous<br />
|-<br />
|M-;<br />
|Formatize and indent comment<br />
|-<br />
<br />
===== C, C++ and Java Modes =====<br />
<br />
{|<br />
|M-a<br />
|Beginning of statement<br />
|-<br />
|M-e<br />
|End of statement<br />
|-<br />
|C-c C-c<br />
|Comment out marked area<br />
|}<br />
<br />
=== Development ===<br />
<br />
*How do I install Yi for development?<br />
:Fork the repository on GitHub, then clone your version to your machine. Push to your repo on GitHub, and then make merge requests.<br />
<br />
*What are some of the dependancies?<br />
:There is a rather long list of dependencies for Yi, check the yi.cabal file for a list.<br />
<br />
::If you are on Mac OS X and are using MacPorts, then these will not be included in the GHC in that distribution. Many of the dependancies are in MacPorts (for example: ghc, ghc-devel, alex, and gtk2hs). However, you may have some trouble building with Cabal-1.5.2, since it is a development version of Cabal. To work around these issues, you might have to add the line "Build-Type: Simple" to the .cabal files in the above required packages.<br />
<br />
=== Configuration ===<br />
<br />
==== How to Configure Yi ====<br />
<br />
You can find configuration file examples in the 'examples/' directory, or online at [http://code.haskell.org/yi/examples/ http://code.haskell.org/yi/examples/].<br />
<br />
You can find some user configs at [https://github.com/yi-editor/yi/tree/master/yi-contrib/src/Yi/Config/Users https://github.com/yi-editor/yi/tree/master/yi-contrib/src/Yi/Config/Users]<br />
<br />
A good way to start is to copy yi.hs in your $XDG_CONFIG_HOME/yi directory (create it if needed), and hack as needed.<br />
<br />
=== Usage ===<br />
==== GError on startup ====<br />
I get the error message "yi.exe: <<System.Glib.GError.GError>>" when I try to run yi.<br />
<br />
Sometimes this is a result of yi not being able to find the contents of the art directory when trying to start in graphical mode (e.g. Gtk or Pango). Check that the install has be done correctly or use the VTY mode (<tt>$ yi -f vty</tt>).<br />
<br />
For more detail on the error, modify main in Yi/Main.hs to catch GError:<br />
<pre><br />
Right finalCfg -> do catchGError (do<br />
when (debugMode finalCfg) $ initDebug ".yi.dbg" <br />
startEditor finalCfg state) (\(GError dom code msg) -> fail msg)<br />
</pre><br />
<br />
Note that more recent versions of Yi (e.g. from the darcs repo) no longer simply display the anonymous GError but instead provide a more detailed error message (making the above code snippet unnecessary).<br />
<br />
[[Category:FAQ]]</div>Fuuzetsuhttps://wiki.haskell.org/index.php?title=Yi&diff=57489Yi2014-01-25T23:25:57Z<p>Fuuzetsu: Remove old darcs reference</p>
<hr />
<div>[[Category:Applications]]<br />
<br />
[[Image:Yi-logo.png]]<br />
<br />
== About ==<br />
<br />
Yi is a text editor written in Haskell and extensible in Haskell. The goal of Yi is<br />
to provide a flexible, powerful and correct editor core<br />
scriptable in Haskell.<br />
<br />
Features:<br />
<br />
* A purely functional editor core;<br />
* Keybindings written as parsers of the input;<br />
* Emacs, Vim and Cua (subset) emulations provided by default;<br />
* Vty, GTK+ w/ Pango(via Gtk2Hs), and, in development, Cocoa and GTK+ w/ VTE frontends.<br />
<br />
The long term goal of the project is to make Yi the editor of choice for Haskell hackers.<br />
<br />
The main short term goal is to maximize Yi's Fun Factor. This includes:<br />
* Improve hackability (and therefore architecture)<br />
* Add cool features<br />
<br />
== Get Yi ==<br />
<br />
=== From Hackage ===<br />
<br />
Yi depends on the [http://haskell.org/platform Haskell Platform] which must be installed. Many Haskellers haven't installed this explicitly, as they have already installed most of the utilities it contains; to be sure you have everything that is needed, it is recommended that you explicitly install the Platform.<br />
<br />
Following that, simply:<br />
<br />
$ cabal update<br />
$ cabal install yi<br />
<br />
More information about the package is available at [http://hackage.haskell.org/package/yi Yi on Hackage].<br />
<br />
=== From GitHub ===<br />
<br />
See the GitHub [https://github.com/yi-editor/yi repository]. Or get it with git:<br />
<br />
$ git clone git://github.com/yi-editor/yi.git<br />
<br />
We try to keep the repository in a clean and buildable state, so it's "testable" for new users. Yi usually only works on the latest GHC release.<br />
<br />
''Note that the old yi-contrib repository is now just a subdirectory of the yi repo.''<br />
<br />
=== Platform Support ===<br />
<br />
==== GNU/Linux ====<br />
<br />
Some GNU/Linux distros have pre-built Yi packages. For Debian/Ubuntu packages, see [https://groups.google.com/forum/?fromgroups=#!topic/yi-devel/XSzWSv1HBmQ this post in the yi-devel mailing list].<br />
<br />
==== Mac OS X ====<br />
<br />
The easiest way to get Yi for Mac OS X is currently no different from the above. There is also a Yi release in MacPorts, but it might be very old, deprecated one. Please use the Hackage version instead.<br />
<br />
==== Windows ====<br />
<br />
The current version of Yi on Hackage (0.6.6.0) can be built on Windows.<br />
<br />
First, you should install the current version of [http://www.haskell.org/platform/windows.html Haskell Platform for Windows]. The version 2012.4.0.0 is known to work with Yi 0.6.6.0. Make sure that your Haskell compiler and tools are on your PATH.<br />
<br />
Next, you should install [http://www.gtk.org/download/win32.php GTK+ for Windows]. You have to use "All-in-one bundles", not individual packages. Download and unpack the archive, then again make sure that GTK+ utilities are on your PATH.<br />
<br />
Now, you can invoke cabal-Install from the command prompt.<br />
<br />
$ cabal update<br />
$ cabal install gtk2hs-buildtools<br />
$ cabal install gtk<br />
$ cabal install yi -f-vty -fpango<br />
<br />
Make sure that you do Configure with flag -f-vty -fpango to force enabling Pango and disabling Vty interface, since Vty is not supported in Windows.<br />
<br />
== Screenshots (0.3) ==<br />
<br />
[[Image:Yi-20070409.png|thumb|right|500px|The GTK frontend]]<br />
[[Image:Yi-20080114-vty.png|thumb|none|500px|The Vty frontend]]<br />
<br />
== News ==<br />
<br />
There is a Yi blog, that reports the important news about Yi, at [http://yi-editor.blogspot.com/ http://yi-editor.blogspot.com/]. It also delves into algorithms and the Yi internals.<br />
<br />
You can also check the [[/OldNews]].<br />
<br />
== Bugs ==<br />
<br />
Check/report bug reports here: [https://github.com/yi-editor/yi/issues GitHub issue tracker]<br />
<br />
== FAQs ==<br />
<br />
{{/FAQ}}<br />
<br />
== Contribute ==<br />
<br />
Fork the source on GitHub and send pull requests for merges. Or consult the yi-devel mailing list. Patches are always welcome. :)<br />
<br />
Otherwise, see [https://github.com/yi-editor/yi/issues the complete list of open issues] here.<br />
<br />
(Note you can start working on all issues in<br />
New/Accepted state, regardless of the owner of the issue.<br />
-- you can send an email to the list with your plan if unsure)<br />
<br />
Post your questions and follow up on [http://groups.google.com/group/yi-devel the yi-devel mailing list].<br />
Some other pending tasks are described below.<br />
<br />
=== Write access policy ===<br />
<br />
One does not need write access to the repository to contribute. Please fork the main repository and send pull requests.<br />
<br />
Write access can however be granted, with the following disclaimer:<br />
<br />
* All people with write access can apply patches without prior approval. If one thinks a patch would be controversial, it might be a good idea to discuss it on the list though.<br />
* Try to not break the build. (By Murphy's law, if you do so it will happen at the most annoying moment...) So, always try to build before pushing patches. Bypassing the test build to record a patch indicates you should further improve your patch.<br />
* [[JeanPhilippeBernardy | I]] can at any time rollback a patch for whatever reason. This however should not upset the author of the patch. Most contributions are welcome, so a patch revert normally would only mean that a detail or two need to be worked out. (e.g. it breaks an important feature in some configuration, etc.)<br />
<br />
== Yi Ideas ==<br />
<br />
This section is meant to gather ideas people have for Yi.<br />
<br />
*Evolution to an IDE:<br />
:Show exact location of compilation errors: 80% of a Haskell project<br />
:Support for the GHCi debugger & others: 10 % of a Haskell project (Added bonus: greath for learning: trough the debugger, people learn the real execution flow of a Haskell program. Better if this is done inside an editor)<br />
:Integration of refactoring tools : 5 %<br />
:Edition: only 5%<br />
<br />
<br />
*An extension to GHCi to support documentation of symbols.<br />
:This seems to be (reasonably) straightforward, as GHCi already has :info. It would mean hacking the type environment (what about values?) to add documentation information. The main problem would seem to be populating this --- maybe hack haddock to produce something from the library docs? I assume that using package GHC uses the parent RTS (package GHC seems to be the way to go, but more investigation is required --- don?)<br />
<br />
*Views on data<br />
:Rather than just editing a file, you would open a view onto the file, i.e. there is no longer a 1-1 correspondence between buffers and files. Why? Well, for aggregate buffers (i.e., editing multiple files in the one view), or for multiple views of a file (e.g. AST and source-level). There would be some primitive ops for editing a buffer (insertChar, delete, etc.), which would then call update functions on anything observing that file.<br />
<br />
*Support for Perl style regular expressions<br />
:Emacs regexes don't support the same set of features; Perl regexes are more tersely powerful. This could be a good feature for luring users from vanilla Emacs.<br />
<br />
*Remote attach so I can work from home, but still use a remote machine<br />
:Like Emacs's server?<br />
<br />
*Haddock documentation<br />
:(no brainer), maybe associate with .hi files for binaries.<br />
<br />
*Maybe a class <code>YiShow</code>, which all config items must be a member of? This is to emulate describe-variable<br />
<br />
*Support for collaborative editing. This would be very good for #haskell work, and the text editor Gobby and its [http://gobby.0x539.de/trac/wiki/ObbyProtocol Obby protocol] seem to provide a candidate way of doing things.<br />
<br />
<br />
=== Borrowing from other editors ===<br />
Take some ideas from Emacs, some from vi, but don't stick them all together without a single core philosophy. Otherwise, you'll end up with an editor that looks like it was thrown together. Some people come from an Emacs background, some from vi, some from elsewhere, and ALL of them will want Yi to behave like their regular editor. The best way to do this is to have a single person make all the decisions on behavior.<br />
<br />
==== Emacs ====<br />
<br />
Coming from an Emacs background, I think a few things are essential,<br />
mainly the introspection capabilities of Emacs.<br />
<br />
===== Emacs goodness =====<br />
<br />
The following are things I like about Emacs, as an extensible<br />
environment, and miss in Yi:<br />
<br />
; Really good online documentation<br />
: Emacs can tell you a lot about a function or variable with a keypress--- the current value, where it is declared, and a hypertext formation string<br />
<br />
; Hooks-Extensibility<br />
: All (good) apps allow users to extend, through, e.g., hooks --- a list of functions that are run before/after some event (like saving a file)<br />
<br />
; List of must-have features<br />
: http://glyph.twistedmatrix.com/2008/12/emacs-test.html<br />
<br />
<br />
===== Emacs badness =====<br />
<br />
So, why replace it?:<br />
; ELisp<br />
: Dynamically scoped, Dynamically typed, ugly, old. 'Nuff said<br />
<br />
; What's a Parser?<br />
: A lot of apps in emacs do stuff with text, usually text that is in some language. There is no standard parser (like, e.g. parsec), so a lot of it is ugly handwritten spaghetti. This also means that adding analysis tools isn't really done (or done nicely).<br />
<br />
; ELisp again<br />
: Haskell is a lot cleaner to write, especially because of the large number of libraries.<br />
<br />
(See also [http://www.emacswiki.org/cgi-bin/wiki/WhyDoesElispSuck WhyDoesElispSuck] on the Emacs wiki.)<br />
<br />
===== Emacs maybeness (?) =====<br />
<br />
Some things that are sometimes bad, sometimes good:<br />
<br />
; Everything is a buffer<br />
: Makes some sense, but sometimes doesn't. It is nice to have uniform key bindings do the right thing (e.g., C-Space sets the mark, and the region can then be used, e.g. to delete a sequence of emails in Wl) Sometimes, however, you just want some sort of GUI widget.<br />
: OTOH, having the minibuffer be a special kind of buffer is a good idea.<br />
<br />
; Properties<br />
: It is possible to associate arbitrary properties with symbols. This means you can annotate a symbol and then use that information at a later date<br />
<br />
==== Vim? ====<br />
<br />
; good things<br />
: modal key editing -> configuration system is powerful enough!<br />
: light weight -> fast startup -> yi has this :)<br />
<br />
<br />
=== Ideas ===<br />
<br />
=== Implementation ===<br />
<br />
Considerations:<br />
<br />
; Interface to the runtime<br />
: The scheduler, docs, etc.<br />
<br />
; Introspection of e.g. what processes are running.<br />
: There are already libraries in Haskell for processes, but they don't give Yi any extra information --- we really want a layer on top.<br />
<br />
...<br />
<br />
== Trivia ==<br />
<br />
;Y I is the most recursive acronym. (Read it as combinators).<br />
;義, pronounced yi, means righteousness, one of the five virtues of confucianism.<br />
;Yi is the symbol for a yobi - the largest [http://en.wikipedia.org/wiki/Binary_prefix#Prefixes binary prefix], meaning 2^80<br />
<br />
== External links ==<br />
<br />
* Blog: http://yi-editor.blogspot.com/<br />
* Haddock: http://projects.haskell.org/yi/doc/<br />
* Repository: https://github.com/yi-editor/yi<br />
* Issues tracker: https://github.com/yi-editor/yi/issues<br />
* Hackage page: http://hackage.haskell.org/package/yi<br />
* IRC channel: #yi on Freenode</div>Fuuzetsuhttps://wiki.haskell.org/index.php?title=Template_haskell/Instance_deriving_example&diff=57358Template haskell/Instance deriving example2013-12-28T19:46:20Z<p>Fuuzetsu: Update old code</p>
<hr />
<div>In this example we use the following haskell code<br />
<haskell>$(gen_render ''Body)</haskell> <br />
<br />
to produce the following instance:<br />
<br />
<haskell> <br />
instance TH_Render Body where<br />
render (NormalB exp) = build 'normalB exp<br />
render (GuardedB guards) = build 'guardedB guards <br />
</haskell><br />
<br />
A function body is generated for each of the constructors of the type Body<br />
<br />
The function gen_render above is defined as follows.<br />
(Note that this code must be in separate module from the above usage).<br />
<br />
<haskell><br />
-- Generate an intance of the class TH_Render for the type typName<br />
gen_render :: Name -> Q [Dec]<br />
gen_render typName =<br />
do (TyConI d) <- reify typName -- Get all the information on the type<br />
(type_name,_,_,constructors) <- typeInfo (return d) -- extract name and constructors <br />
i_dec <- gen_instance (mkName "TH_Render") (conT type_name) constructors<br />
-- generation function for method "render"<br />
[(mkName "render", gen_render)]<br />
return [i_dec] -- return the instance declaration<br />
-- function to generation the function body for a particular function<br />
-- and constructor<br />
where gen_render (conName, components) vars <br />
-- function name is based on constructor name <br />
= let funcName = makeName $ unCapalize $ nameBase conName <br />
-- choose the correct builder function<br />
headFunc = case vars of<br />
[] -> "func_out"<br />
otherwise -> "build" <br />
-- build 'funcName parm1 parm2 parm3 ...<br />
in appsE $ (varE $ mkName headFunc):funcName:vars -- put it all together<br />
-- equivalent to 'funcStr where funcStr CONTAINS the name to be returned<br />
makeName funcStr = (appE (varE (mkName "mkName")) (litE $ StringL funcStr))<br />
</haskell><br />
<br />
Which uses the following functions and types<br />
<br />
First some type synonyms to make the code more readable<br />
<haskell><br />
type Constructor = (Name, [(Maybe Name, Type)]) -- the list of constructors<br />
type Cons_vars = [ExpQ] -- A list of variables that bind in the constructor<br />
type Function_body = ExpQ <br />
type Gen_func = Constructor -> Cons_vars -> Function_body<br />
type Func_name = Name -- The name of the instance function we will be creating<br />
-- For each function in the instance we provide a generator function<br />
-- to generate the function body (the body is generated for each constructor)<br />
type Funcs = [(Func_name, Gen_func)] <br />
</haskell><br />
<br />
The main reusable function. We pass it the list of functions to <br />
generate the functions of the instance<br />
<br />
<haskell><br />
-- construct an instance of class class_name for type for_type<br />
-- funcs is a list of instance method names with a corresponding<br />
-- function to build the method body<br />
gen_instance :: Name -> TypeQ -> [Constructor] -> Funcs -> DecQ<br />
gen_instance class_name for_type constructors funcs = <br />
instanceD (cxt [])<br />
(appT (conT class_name) for_type)<br />
(map func_def funcs) <br />
where func_def (func_name, gen_func) <br />
= funD func_name -- method name<br />
-- generate function body for each constructor<br />
(map (gen_clause gen_func) constructors)<br />
</haskell><br />
<br />
A helper function of the above.<br />
<br />
<haskell><br />
-- Generate the pattern match and function body for a given method and<br />
-- a given constructor. func_body is a function that generations the<br />
-- function body<br />
gen_clause :: (Constructor -> [ExpQ] -> ExpQ) -> Constructor -> ClauseQ<br />
gen_clause func_body data_con@(con_name, components) = <br />
-- create a parameter for each component of the constructor<br />
do vars <- mapM var components<br />
-- function (unnamed) that pattern matches the constructor <br />
-- mapping each component to a value.<br />
(clause [(conP con_name (map varP vars))]<br />
(normalB (func_body data_con (map varE vars))) [])<br />
-- create a unique name for each component. <br />
where var (_, typ) <br />
= newName <br />
$ case typ of <br />
(ConT name) -> toL $ nameBase name<br />
otherwise -> "parm"<br />
where toL (x:y) = (toLower x):y<br />
<br />
unCapalize :: [Char] -> [Char]<br />
unCapalize (x:y) = (toLower x):y<br />
</haskell><br />
<br />
<br />
And some borrowed helper code taken from Syb III / replib 0.2<br />
<br />
<haskell><br />
typeInfo :: DecQ -> Q (Name, [Name], [(Name, Int)], [(Name, [(Maybe Name, Type)])])<br />
typeInfo m =<br />
do d <- m<br />
case d of<br />
d@(DataD _ _ _ _ _) -><br />
return $ (simpleName $ name d, paramsA d, consA d, termsA d)<br />
d@(NewtypeD _ _ _ _ _) -><br />
return $ (simpleName $ name d, paramsA d, consA d, termsA d)<br />
_ -> error ("derive: not a data type declaration: " ++ show d)<br />
<br />
where<br />
consA (DataD _ _ _ cs _) = map conA cs<br />
consA (NewtypeD _ _ _ c _) = [ conA c ]<br />
<br />
{- This part no longer works on 7.6.3<br />
paramsA (DataD _ _ ps _ _) = ps<br />
paramsA (NewtypeD _ _ ps _ _) = ps<br />
-}<br />
<br />
-- Use this on more recent GHC rather than the above<br />
paramsA (DataD _ _ ps _ _) = map nameFromTyVar ps<br />
paramsA (NewtypeD _ _ ps _ _) = map nameFromTyVar ps<br />
<br />
nameFromTyVar (PlainTV a) = a<br />
nameFromTyVar (KindedTV a _) = a<br />
<br />
<br />
termsA (DataD _ _ _ cs _) = map termA cs<br />
termsA (NewtypeD _ _ _ c _) = [ termA c ]<br />
<br />
termA (NormalC c xs) = (c, map (\x -> (Nothing, snd x)) xs)<br />
termA (RecC c xs) = (c, map (\(n, _, t) -> (Just $ simpleName n, t)) xs)<br />
termA (InfixC t1 c t2) = (c, [(Nothing, snd t1), (Nothing, snd t2)])<br />
<br />
conA (NormalC c xs) = (simpleName c, length xs)<br />
conA (RecC c xs) = (simpleName c, length xs)<br />
conA (InfixC _ c _) = (simpleName c, 2)<br />
<br />
name (DataD _ n _ _ _) = n<br />
name (NewtypeD _ n _ _ _) = n<br />
name d = error $ show d<br />
<br />
simpleName :: Name -> Name<br />
simpleName nm =<br />
let s = nameBase nm<br />
in case dropWhile (/=':') s of<br />
[] -> mkName s<br />
_:[] -> mkName s<br />
_:t -> mkName t<br />
<br />
</haskell></div>Fuuzetsuhttps://wiki.haskell.org/index.php?title=Smart_constructors&diff=57350Smart constructors2013-12-26T04:35:18Z<p>Fuuzetsu: /* Examples */ grammar</p>
<hr />
<div>'''Smart constructors'''<br />
<br />
This is an introduction to a programming idiom for placing extra<br />
constraints on the construction of values by using ''smart<br />
constructors''.<br />
<br />
Sometimes you need guarantees about the values in your program beyond<br />
what can be accomplished with the usual [[Type|type system]] checks.<br />
Smart constructors can be used for this purpose.<br />
<br />
Consider the following problem: we want to be able to specify a data<br />
type for electronic resistors. The resistors come in two forms, metal<br />
and ceramic. Resistors are labelled with a number of bands, from 4 to 8.<br />
<br />
We'd like to be able to<br />
* ensure only resistors with the right number of bands are constructed.<br />
<br />
== Runtime checking : smart constructors ==<br />
<br />
=== A first attempt ===<br />
<br />
Code up a typical [[Type|data type]] describing a resistor value:<br />
<br />
<haskell><br />
data Resistor = Metal Bands<br />
| Ceramic Bands <br />
deriving Show<br />
<br />
type Bands = Int<br />
</haskell><br />
<br />
This has a problem however, that the [[constructor]]s of type ''Resistor'' are<br />
unable to check that only bands of size 4 to 8 are built. It is quite<br />
legal to say:<br />
<br />
*Main> :t Metal 23<br />
Metal 23 :: Resistor<br />
<br />
for example.<br />
<br />
=== Smart(er) constructors ===<br />
<br />
Smart constructors are just functions that build values of the required<br />
type, but perform some extra checks when the value is constructed, like<br />
so:<br />
<br />
<haskell><br />
metalResistor :: Bands -> Resistor<br />
metalResistor n | n < 4 || n > 8 = error "Invalid number of resistor bands" <br />
| otherwise = Metal n<br />
</haskell><br />
<br />
This function behaves like the constructor ''Metal'', but also performs<br />
a check. This check will be carried out at runtime, once, when the value<br />
is built.<br />
<br />
Running this code:<br />
> metalResistor 4<br />
Metal 4<br />
<br />
> metalResistor 7<br />
Metal 7<br />
<br />
> metalResistor 9<br />
*** Exception: Invalid number of resistor bands<br />
<br />
> metalResistor 0<br />
*** Exception: Invalid number of resistor bands<br />
<br />
One extra step has to be made though, to make the interface safe. When<br />
exporting the type ''Resistor'' we need to hide the (unsafe)<br />
constructors, and only export the smart constructors, otherwise a<br />
reckless user could bypass the smart constructor:<br />
<br />
<haskell><br />
module Resistor (<br />
Resistor, -- abstract, hiding constructors<br />
metalResistor, -- only way to build a metal resistor<br />
) where<br />
<br />
...<br />
</haskell><br />
<br />
=== Using assertions ===<br />
<br />
Hand-coding error messages can be tedious when used often. Instead we<br />
can use the ''assert'' function, provided (from Control.Exception). We<br />
rewrite the smart constructor as:<br />
<br />
<haskell><br />
metalResistor :: Bands -> Resistor<br />
metalResistor n = assert (n >= 4 && n <= 8) $ Metal n<br />
</haskell><br />
<br />
And now obtain more detailed error messages, automatically generated for us:<br />
<br />
> metalResistor 0<br />
*** Exception: A.hs:4:18-23: Assertion failed<br />
<br />
We at least now are given the line and column in which the error occured.<br />
<br />
== Compile-time checking : the type system ==<br />
<br />
=== Enforcing the constraint statically ===<br />
<br />
There are other ways to obtain numerical checks like this. The most<br />
interesting are probably the static checks that can be done with [[Type arithmetic]], <br />
that enforce the number of bands at compile time, rather than runtime,<br />
by lifting the band count into the type level.<br />
<br />
In the following example, instead of checking the band count at runtime,<br />
we instead lift the resistor band count into the type level, and have<br />
the typecheck perform the check statically, using [[Phantom type|phantom types]] <br />
and [[Peano numbers]].<br />
<br />
We thus remove the need for a runtime check, meaning faster code. A consequence<br />
of this decision is that since the band count is now represented in the type,<br />
it is no longer necessary to carry it around at runtime, meaning less data has<br />
to be allocated.<br />
<br />
Firstly, define some [[Peano numbers]] to represent the number of bands as types:<br />
<br />
<haskell> <br />
data Z = Z<br />
data S a = S a<br />
</haskell> <br />
<br />
Now specify a class for cardinal numbers.<br />
<br />
<haskell><br />
class Card c where<br />
<br />
instance Card Z where<br />
instance (Card c) => Card (S c) where<br />
</haskell> <br />
<br />
Ok, now we're set. So encode a type-level version of the bounds check.<br />
Only resistors with bands >= 4 and <= 8 are valid:<br />
<br />
<haskell><br />
class Card size => InBounds size where<br />
<br />
instance InBounds (S (S (S (S Z)))) where -- four<br />
instance InBounds (S (S (S (S (S Z))))) where -- five<br />
instance InBounds (S (S (S (S (S (S Z)))))) where -- six<br />
instance InBounds (S (S (S (S (S (S (S Z))))))) where -- seven<br />
instance InBounds (S (S (S (S (S (S (S (S Z)))))))) where -- eight<br />
</haskell> <br />
<br />
Now define a new resistor type. Note that since the bounds is represented in the<br />
type, ''we no longer need to store the bounds in the resistor value''.<br />
<br />
<haskell><br />
data Resistor size = Resistor deriving Show<br />
</haskell> <br />
<br />
And, finally, a convenience constructor for us to use, encoding the bounds<br />
check in the type:<br />
<br />
<haskell> <br />
resistor :: InBounds size => size -> Resistor size<br />
resistor _ = Resistor<br />
</haskell><br />
<br />
=== Examples ===<br />
<br />
First, define some convenience values:<br />
<br />
<haskell><br />
d0 = undefined :: Z<br />
d3 = undefined :: S (S (S Z))<br />
d4 = undefined :: S (S (S (S Z)))<br />
d6 = undefined :: S (S (S (S (S (S Z)))))<br />
d8 = undefined :: S (S (S (S (S (S (S (S Z)))))))<br />
d10 = undefined :: S (S (S (S (S (S (S (S (S (S Z)))))))))<br />
</haskell><br />
<br />
Now try to construct some resistors:<br />
<br />
> resistor d0<br />
No instance for (InBounds Z)<br />
<br />
So the value 0 isn't in bounds, as we want. And it is a ''compile-time error''<br />
to try to create such a resistor.<br />
<br />
> resistor d3<br />
No instance for (InBounds (S (S (S Z))))<br />
<br />
Ok, how about a valid resistor?<br />
<br />
> resistor d4<br />
Resistor<br />
<br />
Great!<br />
<br />
> :t resistor d4<br />
resistor d4 :: Resistor (S (S (S (S Z))))<br />
<br />
And its type encodes the number of bands.<br />
<br />
> resistor d6<br />
Resistor<br />
> resistor d8<br />
Resistor<br />
<br />
> :t resistor d8<br />
resistor d8 :: Resistor (S (S (S (S (S (S (S (S Z))))))))<br />
<br />
Similar result for other valid resistors.<br />
<br />
> resistor d10<br />
No instance for (InBounds (S (S (S (S (S (S (S (S (S (S Z)))))))))))<br />
<br />
And 10 is too big.<br />
<br />
=== Summary ===<br />
<br />
By using a standard encoding of numeric values on the type level we are able to<br />
encode a bounds check in the type of a value, thus removing a runtime check,<br />
and removing the need to store the numeric value at runtime. The code is safer,<br />
as it is impossible to compile the program unless all resistors have the<br />
correct number of bands.<br />
<br />
An extension would be to use a decimal encoding for the integers (at the<br />
expense of longer code).<br />
<br />
=== Extensions ===<br />
<br />
Further checks can be obtained by separating the metal and ceramic<br />
values on the type level, so no function that takes a metal resistor can<br />
be accidentally passed a ceramic one.<br />
<br />
A ''newtype'' is useful for this:<br />
<br />
<haskell><br />
newtype MetalResistor = Metal Bands<br />
newtype CeramicResistor = Ceramic Bands<br />
</haskell><br />
<br />
now, a function of resistors must have either a ''MetalResistor'' type, or a<br />
''CeramicResistor'' type:<br />
<br />
<haskell><br />
foo :: MetalResistor -> Int<br />
foo (MetalResistor n) = n<br />
</haskell><br />
<br />
You can't write a function over both resistor types (other than a purely<br />
polymorphic function).<br />
<br />
=== Related work ===<br />
<br />
These ideas are also discussed in [[Dimensionalized numbers]]<br />
and on the old wiki <br />
[http://web.archive.org/web/20050227183721/http://www.haskell.org/hawiki/NonTrivialTypeSynonyms here] (for<br />
compile-time unit analysis error catching at the type level).<br />
Recently migrated are the pages on [[worker wrapper]] and [[factory function]].<br />
In general, the more information you place on the type level, the more<br />
static checks you get -- and thus less chance for bugs.<br />
<br />
== Runtime Optimisation : smart constructors ==<br />
<br />
Another use for smart constructors is to perform basic optimisations, often to obtain a normal form for constructed data. For example, consider a data structure representing addition and multiplication of variables.<br />
<br />
<haskell><br />
data Expression = Variable String<br />
| Add [Expression]<br />
| Multiply [Expression]<br />
</haskell><br />
<br />
In this data structure, it is possible to represent a value such as <tt>Add [Variable "a", Add [Variable "b", Variable "c"]]</tt> more compactly as <tt>Add [Variable "a", Variable "b", Variable "c"]</tt>.<br />
<br />
This can be done automatically with smart constructors such as:<br />
<br />
<haskell><br />
add :: [Expression] -> Expression<br />
add xs = Add (concatMap fromAdd xs)<br />
multiply :: [Expression] -> Expression<br />
multiply xs = Multiply (concatMap fromMultiply xs)<br />
<br />
fromAdd (Add xs) = xs<br />
fromAdd x = [x]<br />
fromMultiply (Multiply xs) = xs<br />
fromMultiply x = [x]<br />
</haskell><br />
<br />
[[Category:Idioms]]<br />
[[Category:Glossary]]</div>Fuuzetsuhttps://wiki.haskell.org/index.php?title=Yi/FAQ&diff=57330Yi/FAQ2013-12-19T19:39:16Z<p>Fuuzetsu: /* How to Configure Yi */</p>
<hr />
<div>=== Installation ===<br />
<br />
*How do I install Yi?<br />
:Get it from Hackage. Configure, compile and install Yi as you would do for any other Cabal package. See also above-mentioned (2.3 Platform Support).<br />
<br />
*Setup configure fails with <br />
Setup.hs: Package yi-0.4 can't be built on this system.<br />
:It means that you have no UI package available. You need VTY or GTK2hs installed. Get them from Hackage.<br />
<br />
*cabal install yi fails with dependency errors, e.g.:<br />
$ cabal install yi<br />
Resolving dependencies...<br />
cabal.exe: dependencies conflict: ghc-6.8.3 requires bytestring ==0.9.0.1.1<br />
however<br />
bytestring-0.9.0.1.1 was excluded because bytestring-0.9.0.1 was selected<br />
instead<br />
bytestring-0.9.0.1.1 was excluded because yi-0.3 requires bytestring =0.9.0.1<br />
:Try removing all your old yi packages, and do<br />
cabal update<br />
before attempting to install.<br />
<br />
*cabal install -fghcAPI fails<br />
:If you want GHC API special capabilities, you have to download, configure, build and copy separately:<br />
cd yi<br />
cabal configure -fghcAPI<br />
cabal build<br />
cabal copy<br />
<br />
* Compilation fails with a message about <tt>alex</tt> not being available?<br />
: Currently, Cabal doesn't track programs, just libraries, so it won't warn you if you are missing Alex (as many people are). The solution here is to just <tt>cabal install alex</tt> first. (Yi uses Alex to generate code for parsing stuff with syntax, like Haskell source.)<br />
<br />
* I can't install <tt>yi-gtk</tt> or <tt>yi-vty</tt>! It wants <tt>sourceview</tt> or something.<br />
: As the Hackage descriptions say, yi-gtk and yi-vty are ''only'' for versions of older than Yi 0.3. You really should be running the latest development (Darcs) or stable (Hackage) versions of Yi, so ''don't'' try to install these two packages. Yi supports VTY and Gtk2hs directly in the <tt>yi</tt> package now.<br />
*On Mac OS X if you get an error message similar to this:<br />
yi: can't load .so/.DLL for: gthread-2.0 (dlopen(libgthread-2.0.dylib, 10): image not found)<br />
<br />
:then your dynamic library search path variable is probably not set correctly. You can set it (in Bash) using:<br />
<br />
export DYLD_LIBRARY_PATH=/opt/local/lib<br />
<br />
:(Adjust the specific path to your system. You can find the right location using <tt>locate libgthread</tt>)<br />
<br />
*On Mac OS 10.6 (Snow Leopard) if you get the following error:<br />
Loading package cairo-0.11.1 ... <command line>: can't load .so/.DLL for: pixman-1 (dlopen(/opt/local/lib/libpixman-1.dylib, 9): no suitable image found. Did find:<br />
/opt/local/lib/libpixman-1.dylib: mach-o, but wrong architecture)<br />
cabal: Error: some packages failed to install:<br />
yi-0.6.2.4 failed during the building phase. The exception was:<br />
ExitFailure 1<br />
<br />
:then the problem is that GHC currently only supports linking against i386 libraries, and your ports are compiled for x86_64. To fix, recompile your ports with the +universal variant like so:<br />
<br />
port install installed +universal<br />
<br />
* Compilation fails with errors about template-haskell or data-accessor:<br />
Add constraints about which release of those libraries to use.<br />
$ cabal install yi --constraint="data-accessor < 0.2.1" --constraint="template-haskell < 2.4"<br />
<br />
=== Default key bindings ===<br />
<br />
==== CUA key bindings ====<br />
<br />
===== File operations =====<br />
{|<br />
| Ctrl-o<br />
| Open file.<br />
|-<br />
| Ctrl-s<br />
| Save the current file.<br />
|-<br />
| Ctrl-q<br />
| Quit the editor.<br />
|}<br />
<br />
===== Cursor/selection movement =====<br />
{|<br />
| &rarr;<br />
| Move cursor forward one character.<br />
|-<br />
| &larr;<br />
| Move cursor back one character.<br />
|-<br />
| &darr;<br />
| Move cursor down one line.<br />
|-<br />
| &uarr;<br />
| Move cursor down one line.<br />
|-<br />
| Shift+&rarr;<br />
| Extend selection forward one character.<br />
|-<br />
| Shift+&larr;<br />
| Extend selection back one character.<br />
|-<br />
| Shift+&darr;<br />
| Extend selection down one line.<br />
|-<br />
| Shift+&uarr;<br />
| Extend selection up one line.<br />
|-<br />
| Ctrl-&rarr;<br />
| Move cursor forward one word.<br />
|-<br />
| Ctrl-&larr;<br />
| Move cursor back one word.<br />
|-<br />
| Home<br />
| Move cursor to beginning of line.<br />
|-<br />
| End<br />
| Move cursor to end of line.<br />
|-<br />
| Ctrl-Home<br />
| Move cursor to beginning of document.<br />
|-<br />
| Ctrl-End<br />
| Move cursor to end of document.<br />
|}<br />
<br />
===== Miscellaneous operations =====<br />
<br />
{|<br />
| Ctrl-f<br />
| Incremental search.<br />
|-<br />
| Ctrl-x<br />
| Cut the selected area and save it to the clipboard<br />
|-<br />
| Ctrl-c<br />
| Copy the selected area to the clipboard<br />
|-<br />
| Ctrl-v<br />
| Paste contents of clipboard at cursor.<br />
|-<br />
| Ctrl-z<br />
| Undo last operation.<br />
|-<br />
| Ctrl-y<br />
| Redo last operation.<br />
|}<br />
<br />
==== Vim key bindings ====<br />
==== Emacs key bindings ====<br />
<br />
C = Control<br />
<br />
M = Meta = Alt|Esc<br />
<br />
===== Basics =====<br />
{|<br />
|C-x C-f<br />
|"Find" file i.e. open/create a file in buffer<br />
|-<br />
|C-x C-s<br />
|Save the file<br />
|-<br />
|C-x C-w<br />
|Write the text to an alternate name<br />
|-<br />
|C-x i<br />
|Insert file at cursor position<br />
|-<br />
|C-x b<br />
|Create/switch buffers<br />
|-<br />
|C-x C-b<br />
|Show buffer list<br />
|-<br />
|C-x k<br />
|Kill buffer<br />
|-<br />
|C-z<br />
|Suspend Yi<br />
|-<br />
|C-x C-c<br />
|Close down Yi<br />
|}<br />
<br />
===== Basic movement =====<br />
<br />
{|<br />
|C-f<br />
|Forward char<br />
|-<br />
|C-b<br />
|Backward char<br />
|-<br />
|C-p<br />
|Previous line<br />
|-<br />
|C-n<br />
|Next line<br />
|-<br />
|M-f<br />
|Forward one word<br />
|-<br />
|M-b<br />
|Backward one word<br />
|-<br />
|C-a<br />
|Beginning of line<br />
|-<br />
|C-e<br />
|End of line<br />
|-<br />
|C-v<br />
|One page up<br />
|-<br />
|M-v<br />
|Scroll down one page<br />
|-<br />
|M-<<br />
|Beginning of text<br />
|-<br />
|M-><br />
|End of text<br />
|}<br />
<br />
===== Editing =====<br />
<br />
{|<br />
|M-n<br />
|Repeat the following command n times<br />
|-<br />
|C-u<br />
|Repeat the following command 4 times<br />
|-<br />
|C-d<br />
|Delete a char<br />
|-<br />
|M-d<br />
|Delete word<br />
|-<br />
|M-Del<br />
|Delete word backwards<br />
|-<br />
|C-k<br />
|Kill line<br />
|-<br />
|C-Space<br />
|Set beginning mark (for region marking for example)<br />
|-<br />
|C-W<br />
|"Kill" (delete) the marked region region<br />
|-<br />
|M-W<br />
|Copy the marked region<br />
|-<br />
|C-y<br />
|"Yank" (paste) the copied/killed region/line<br />
|-<br />
|M-y<br />
|Yank earlier text (cycle through kill buffer)<br />
|-<br />
|C-x C-x<br />
|Exchange cursor and mark<br />
|-<br />
|C-t<br />
|Transpose two chars<br />
|-<br />
|M-t<br />
|Transpose two words<br />
|-<br />
|M-u<br />
|Make letters uppercase in word from cursor position to end<br />
|-<br />
|M-c<br />
|Simply make first letter in word uppercase<br />
|-<br />
|M-l<br />
|Opposite to M-u<br />
|}<br />
<br />
===== Important =====<br />
<br />
{|<br />
|C-g<br />
|Quit the running/entered command<br />
|-<br />
|C-x u<br />
|Undo previous action<br />
|-<br />
|M-/<br />
|Undo previous action<br />
|}<br />
<br />
===== Search/Replace =====<br />
<br />
{|<br />
|C-s<br />
|Search forward<br />
|-<br />
|C-r<br />
|Search backward<br />
|-<br />
|M-%<br />
|Query replace<br />
|-<br />
|Space or y<br />
|Replace this occurrence<br />
|-<br />
|Del or n<br />
|Don't replace<br />
|-<br />
|!<br />
|Replace all following occurrences<br />
|-<br />
|ENTER or q<br />
|Quit replace<br />
|}<br />
<br />
===== Window-Commands =====<br />
<br />
{|<br />
|C-x 2<br />
|Split window vertically<br />
|-<br />
|C-x o<br />
|Change to other window<br />
|-<br />
|C-x 0<br />
|Delete window<br />
|-<br />
|C-x 1<br />
|Close all windows except the one the cursors in<br />
|}<br />
<br />
===== DIRectory EDitor (dired) =====<br />
<br />
{|<br />
|C-x d<br />
|Start up dired<br />
|-<br />
|C (large C)<br />
|Copy<br />
|-<br />
|d<br />
|Mark for erase<br />
|-<br />
|D<br />
|Delete right away<br />
|-<br />
|e or f<br />
|Open file or directory<br />
|-<br />
|g<br />
|Re-read directory structure from file<br />
|-<br />
|m<br />
|Mark with *<br />
|-<br />
|n<br />
|Move to next line<br />
|-<br />
|q<br />
|Quit dired<br />
|-<br />
|R<br />
|Rename file<br />
|-<br />
|u<br />
|Remove mark<br />
|-<br />
|x<br />
|Delete files marked with D<br />
|-<br />
| +<br />
|Create directory<br />
|}<br />
<br />
===== Programming =====<br />
<br />
{|<br />
|M-m<br />
|Move to first (non-space) char in this line<br />
|-<br />
|M-^<br />
|Attach this line to previous<br />
|-<br />
|M-;<br />
|Formatize and indent comment<br />
|-<br />
<br />
===== C, C++ and Java Modes =====<br />
<br />
{|<br />
|M-a<br />
|Beginning of statement<br />
|-<br />
|M-e<br />
|End of statement<br />
|-<br />
|C-c C-c<br />
|Comment out marked area<br />
|}<br />
<br />
=== Development ===<br />
<br />
*How do I install Yi for development?<br />
:Fork the repository on GitHub, then clone your version to your machine. Push to your repo on GitHub, and then make merge requests.<br />
<br />
*What are some of the dependancies?<br />
:There is a rather long list of dependencies for Yi, check the yi.cabal file for a list.<br />
<br />
::If you are on Mac OS X and are using MacPorts, then these will not be included in the GHC in that distribution. Many of the dependancies are in MacPorts (for example: ghc, ghc-devel, alex, and gtk2hs). However, you may have some trouble building with Cabal-1.5.2, since it is a development version of Cabal. To work around these issues, you might have to add the line "Build-Type: Simple" to the .cabal files in the above required packages.<br />
<br />
=== Configuration ===<br />
<br />
==== How to Configure Yi ====<br />
<br />
You can find configuration file examples in the 'examples/' directory, or online at [http://code.haskell.org/yi/examples/ http://code.haskell.org/yi/examples/].<br />
<br />
You can find some user configs at [https://github.com/yi-editor/yi/tree/master/yi-contrib/src/Yi/Config/Users https://github.com/yi-editor/yi/tree/master/yi-contrib/src/Yi/Config/Users]<br />
<br />
A good way to start is to copy yi.hs in your $XDG_CONFIG_HOME/yi directory (create it if needed), and hack as needed.<br />
<br />
=== Usage ===<br />
==== GError on startup ====<br />
I get the error message "yi.exe: <<System.Glib.GError.GError>>" when I try to run yi.<br />
<br />
Sometimes this is a result of yi not being able to find the contents of the art directory when trying to start in graphical mode (e.g. Gtk or Pango). Check that the install has be done correctly or use the VTY mode (<tt>$ yi -f vty</tt>).<br />
<br />
For more detail on the error, modify main in Yi/Main.hs to catch GError:<br />
<pre><br />
Right finalCfg -> do catchGError (do<br />
when (debugMode finalCfg) $ initDebug ".yi.dbg" <br />
startEditor finalCfg state) (\(GError dom code msg) -> fail msg)<br />
</pre><br />
<br />
Note that more recent versions of Yi (e.g. from the darcs repo) no longer simply display the anonymous GError but instead provide a more detailed error message (making the above code snippet unnecessary).<br />
<br />
[[Category:FAQ]]</div>Fuuzetsuhttps://wiki.haskell.org/index.php?title=Hoogle&diff=57319Hoogle2013-12-18T14:18:29Z<p>Fuuzetsu: /* Database Creation */ typo</p>
<hr />
<div>Hoogle is a Haskell API search engine, which allows you to search many standard Haskell libraries by either function name, or by approximate [[type signature]].<br />
<br />
* '''Online version:''' http://haskell.org/hoogle<br />
* '''Hackage page:''' http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hoogle<br />
* '''GitHub repository:''' https://github.com/ndmitchell/hoogle<br />
* '''Darcs repository:''' http://code.haskell.org/hoogle<br />
* '''Bug tracker:''' http://code.google.com/p/ndmitchell/issues/list<br />
* '''Manual:''' https://github.com/ndmitchell/hoogle/blob/master/README.md<br />
<br />
Below is the old manual, which is gradually being phased out.<br />
<br />
<br />
== Hoogle Use ==<br />
<br />
Hoogle can be used in several ways:<br />
<br />
* Online, with the web interface: http://haskell.org/hoogle<br />
* In the [[IRC channel|Haskell IRC channel]], using the [[Lambdabot]] plugin, <tt>@hoogle</tt> and <tt>@hoogle+</tt><br />
* With the command line version [http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hoogle available on Hackage].<br />
<br />
This section describes Hoogle searches, and the flags available from the Hoogle command line tool. The information applies only to Hoogle 4, the next version of Hoogle, and is still being fleshed out.<br />
<br />
=== Searches ===<br />
<br />
Before explaining the syntax of searches, we first give a list of example searches with their meaning:<br />
<br />
* "map" Search for the text "map"<br />
* "con map" Search for the text "map" and the text "con"<br />
* "a -> a" Search for the type "a -> a"<br />
* ":: a -> a" Search for the type "a -> a"<br />
* "a" Search for the text "a"<br />
* ":: a" Search for the type "a"<br />
* "id :: a -> a" Search for the text "id" and the type "a -> a"<br />
<br />
Searches can be either textual (a list of words), or by type (a type signature) or both. A type search may optionally start with a "::" symbol. A search is considered a text search unless it contains a combination of text and symbols, or if it starts with (::). To search for both a type and a name, place a :: between them, for example "undefined :: a"<br />
<br />
Searches can be restricted to a particular module with +Module.Name, or to avoid a module with -Module.Name. The command Module.Name.Foo is treated as +Module.Name Foo.<br />
<br />
Searches can be restricted to a particular package with +packagename, or to avoid a package with -package. By default Hoogle will search a standard set of packages.<br />
<br />
==== Command Line Search Flags ====<br />
<br />
Flags can be specified as <tt>--flag</tt> or <tt>/flag</tt>. Flags requiring arguments are specified as <tt>--flag=arg</tt> or <tt>/flag=arg</tt>. Anything which is not a flag is counted as a search query. Because a console will treat <tt>-></tt> as a redirection, you can do <tt>-#</tt> to get the right character.<br />
<br />
* <tt>-V, --version</tt> Print out version information<br />
* <tt>-?, --help</tt> Show help on the command line flags<br />
* <tt>-v --verbose</tt> Verbose mode<br />
* <tt>--color</tt> Show color output, requires an ANSI compliant terminal, defaults to false<br />
* <tt>--count=int</tt> Maximum number of results to print, defaults to showing all results<br />
* <tt>--start=int</tt> 1-based index of first result to print, defaults to 1<br />
* <tt>--info</tt> Show extended information for the first results<br />
<br />
=== Database Creation ===<br />
<br />
Hoogle has both binary databases (extension .hoo) and textual databases (extension .txt). Textual database files are a list of functions and their types, along with information about type synonyms, instances etc. The textual database files can be generated by [http://haskell.org/haddock/ Haddock] with the <tt>--hoogle</tt> flag. Support for this is now in [http://haskell.org/cabal/ Cabal] with <tt>runhaskell Setup haddock --hoogle</tt>.<br />
<br />
A more detailed tutorial style style post on database creation is available [http://neilmitchell.blogspot.com/2008/08/hoogle-database-generation.html on the author's blog].<br />
<br />
You can create some default databases with (Windows users, please read [http://stackoverflow.com/questions/7523151/hoogle-data-on-windows Hoogle data on Windows] first):<br />
<br />
$ hoogle data<br />
<br />
or you can create an extended database with<br />
<br />
$ hoogle data all<br />
<br />
==== Converting text databases to binary databases ====<br />
<br />
A text database can be converted to a binary database with the command <tt>hoogle convert file.txt</tt>. Any package dependencies should be specified with <tt>+package</tt> or <tt>--data=package.hoo</tt>, and will require the binary databases for those packages. The output file can be controlled with <tt>--output=file.hoo</tt>.<br />
<br />
==== Merging binary databases ====<br />
<br />
Multiple binary databases can be merged with <tt>hoogle combine file1.hoo file2.hoo</tt>. The result would be written as <tt>default.hoo</tt>. As before, <tt>--output=out.hoo</tt> can be specified.<br />
<br />
The following script (from Matt Brown) may be helpful:<br />
<br />
$cat hoogleCombiner.sh <br />
#!/bin/bash<br />
<br />
function combines {<br />
for f in ~/.hoogle/*.hoo<br />
do<br />
echo -n " $(readlink -f $f)"<br />
done<br />
}<br />
<br />
hoogle --output=$(readlink -f ~/.hoogle.hoo) combine $(combines)<br />
<br />
Simon Michaels suggests: <br />
<br />
#!/bin/bash<br />
#<br />
# Search for hoogle databases in or under the directories/files specified<br />
# as arguments or hard-coded below (see allHoogleDbs), and combine them as<br />
# ~/.hoogle/default.hoo. Lets you search all your code (and installed<br />
# haskell libs) at once.<br />
#<br />
# Usage:<br />
# $ hoogle-update-db<br />
# $ alias hoogle="hoogle --i=$HOME/.hoogle"<br />
# $ hoogle something<br />
<br />
# nb current hoogle cli quirks: path options should have two hyphens, one<br />
# equals, and no tildes, eg: --d=NOTILDEFILEPATH<br />
<br />
#set -x<br />
<br />
ARGS=$*<br />
<br />
function allHoogleDbs {<br />
for p in $ARGS ~/src/ ~/.cabal/share/ # add paths here<br />
do<br />
echo -n " $(findHoogleDbs $p)"<br />
done<br />
}<br />
<br />
function findHoogleDbs {<br />
find $1 -name '*.hoo'<br />
}<br />
<br />
function combineOpts {<br />
for f in $*<br />
do<br />
echo -n " $(readlink -f $f)"<br />
done<br />
}<br />
<br />
dbs=$(allHoogleDbs)<br />
echo Found $dbs<br />
mkdir -p ~/.hoogle<br />
hoogle --output=$(readlink -f ~/.hoogle/default.hoo) combine $(combineOpts $dbs)<br />
echo Created ~/.hoogle/default.hoo<br />
<br />
==== Installing databases from Hackage ====<br />
<br />
Packages on Hackage usually have .txt databases generated for you, so you can download those. You can find them in the <tt>html</tt> directories under the name <tt>[package-name].txt</tt>. So, for example, for <tt>diagrams-core</tt> the database can be found here: http://hackage.haskell.org/packages/archive/diagrams-core/0.6.0.2/doc/html/diagrams-core.txt<br />
<br />
==== Scope of Web Searches ====<br />
<br />
Using the standard web interface, Hoogle searches: array, arrows, base, bytestring, Cabal, cgi, containers, directory, filepath, haskell-src, HUnit, mtl, old-locale, old-time, packedstring, parallel, parsec, pretty, process, QuickCheck, random, stm, template-haskell, time, xhtml.<br />
<br />
Using the [http://haskell.org/hoogle/?hoogle=gtk+%2bpackage Gtk2hs Hoogle], Hoogle searches only in the Gtk2hs package.<br />
<br />
=== Developer Flags ===<br />
<br />
,f (ArgNone Web) ["w","web"] [PCmdLine] "Run as though it was a CGI script"<br />
,f (ArgNone Test) ["test"] [PCmdLine] "Run the regression tests"<br />
,f (ArgStr Dump) ["dump"] [PCmdLine] "Dump a database for debugging"<br />
,f (ArgFileIn DataFile ["hoo"]) ["d","data"] [PCmdLine,PMultiple] "Database file"<br />
,f (ArgNone Verbose) ["v","verbose"] [PCmdLine] "Display verbose information"<br />
,f (ArgNone Debug) ["debug"] [PCmdLine] "Debugging only"<br />
,f (ArgFileIn TestFile ["txt"]) ["testfile"] [PCmdLine,PMultiple] "Run tests from a file"<br />
,f (ArgFileIn Rank ["txt"]) ["rank"] [PCmdLine,PMultiple] "Generate ranking scores"<br />
<br />
== Hoogle Integration Modes ==<br />
<br />
Hoogle can be integrated with various programs, listed below. Most of these integration modes were contributed by users, and users are encouraged to add more programs to this list.<br />
<br />
=== Firefox Integration ===<br />
<br />
'''From the search bar:''' Go to the [http://haskell.org/hoogle/ Hoogle website] in Firefox and click on "Search plugin", top right hand corner (some versions of firefox instead will have an "add Hoogle" option in the list of search engines when you are viewing the Hoogle page). This will add a Hoogle entry to the search box in Firefox.<br />
<br />
'''As a keyword search:''' You can set up Hoogle as a keyword search in Firefox. This means that you can type <tt>h map</tt> directly into the location bar and you'll jump directly to the Hoogle search results page.<br />
<br />
# Visit Hoogle's web interface: http://haskell.org/hoogle<br />
# Right-click on the text input box and click "Add a Keyword for this Search..."<br />
# Give it a nice short keyword like "h".<br />
<br />
If you want to also search for special symbols in Firefox keyword search, modify the keyword search URL to be: <tt>javascript:window.location.href="http://haskell.org/hoogle?q=" + encodeURIComponent("%s")</tt><br />
<br />
=== Chrome Integration ===<br />
<br />
'''Add to list of available search engines:''' Exactly as for the search bar in Firefox above.<br />
<br />
'''As a keyword search:''' Under Chrome Preferences (Basic),<br />
select Manage Search Engines. You can then edit the keyword box appropriately.<br />
<br />
To get the new Hoogle engine into the "default" section from the "other" section, make it default, and then re-select what was the original default.<br />
<br />
(Works with Chrome on Mac OS X, at least).<br />
<br />
=== GHCi Integration ===<br />
<br />
Ever feel like having access to hoogle whilst messing around in GHCi? It's relatively easy to integrate the two. <br />
<br />
The following will install hoogle as a shell command, and configure GHCi to have commands ":hoogle" showing all matches, and ":doc" showing haddock documentation for the first match:<br />
<br />
# <tt>cabal install hoogle</tt><br />
# <tt>echo >> ~/.ghci ':def hoogle \x -> return $ ":!hoogle \"" ++ x ++ "\""'</tt><br />
# <tt>echo >> ~/.ghci ':def doc \x -> return $ ":!hoogle --info \"" ++ x ++ "\""'</tt><br />
<br />
NB. the above wraps the argument in quotes before passing to the shell command, so there is no need to supply quotes; eg.<br />
<br />
:hoogle map<br />
:hoogle (a -> b) -> [a] -> [b]<br />
<br />
Done!<br />
<br />
On Windows you should add the same lines<br />
:def hoogle \x -> return $ ":!hoogle \"" ++ x ++ "\""<br />
:def doc \x -> return $ ":!hoogle --info \"" ++ x ++ "\""<br />
to file (XP/2003):<br />
C:\Documents and Settings\[your windows account]\Application Data\ghc\ghci.conf <br />
or(Windows Vista/7):<br />
C:\users\[your windows account]\Application Data\ghc\ghci.conf <br />
<br />
<br />
==== Installation from source (without cabal) ====<br />
<br />
First, you need to download and compile Hoogle. Then, we want to move hoogle to somewhere in your system's <code>$PATH</code> (open a terminal and type <code>echo $PATH</code> to see where this is). I suggest ~/bin, although you might want to go for /usr/bin or /usr/local/bin, etc.<br />
<br />
Copy the Hoogle binary and hoogle.txt to the directory you chose. If you're using a version of hoogle pulled straight from darcs, you can ignore everything up until the 'Next, we need to integrate it into GHCi' bit. Otherwise:<br />
<br />
There's a problem in that hoogle doesn't look for hoogle.txt in the system <code>$PATH</code>, it only looks in the current directory. This is a slight pain but is easily worked around: rename the hoogle binary to hoogle-bin, then create a new text file called 'hoogle' with the following contents:<br />
<br />
#! /bin/bash<br />
hoogle-bin -l /path/to/your/chosen/directory/hoogle.txt "$@"<br />
<br />
chmod hoogle to make it executable (try <code>chmod +x hoogle</code>). Now you should be able to run hoogle requests from the shell. Try a few of the examples above.<br />
<br />
==== How it works ====<br />
<br />
Next, we need to integrate it into GHCi. We can execute shell commands with GHCi via <code>:def</code>. Load up GHCi, and type the following:<br />
<br />
:def hoogle \x -> return $ ":!hoogle " ++ x<br />
<br />
If this executes cleanly, you should be able to run hoogle commands from GHCi via <code>:hoogle</code>, i.e. <code>:hoogle map</code> or <code>:hoogle "(a -> b) -> [a] -> [b]"</code>. Be careful: you need the extra quotes when hoogling types, at least on my system. <code>:ho</code> works as an abbreviation of <code>:hoogle</code> (just <code>:h</code> clashes with <code>:help</code>).<br />
<br />
Finally, we want to make this persist across GHCi sessions. GHCi loads a file called ~/.ghci before running, so simply stick the above <code>:def</code> in that file and all should work.<br />
<br />
Contributed by [[User:DavidHouse|DavidHouse]]<br />
<br />
=== Emacs Integration ===<br />
[[Haskell_mode_for_Emacs|haskell-mode]] from versions 2.4 onwards have the function haskell-hoogle, which will hoogle the identifier at point. Setup:<br />
<br />
(require 'haskell-mode)<br />
(define-key haskell-mode-map "\C-ch" 'haskell-hoogle)<br />
;(setq haskell-hoogle-command "hoogle")<br />
<br />
You will need a web browser configured for best results. Here's an example setup for Safari:<br />
<br />
(setq browse-url-browser-function 'browse-url-safari)<br />
(defun browse-url-safari (url &optional new-window)<br />
"Open URL in a new Safari window."<br />
(interactive (browse-url-interactive-arg "URL: "))<br />
(unless<br />
(string= ""<br />
(shell-command-to-string<br />
(concat "open -a Safari " url)))<br />
(message "Starting Safari...")<br />
(start-process (concat "open -a Safari " url) nil "open -a Safari " url)<br />
(message "Starting Safari... done")))<br />
<br />
Alternately, you can build the command-line hoogle (darcs repo below) and uncomment the third line above, then results will appear in a buffer.<br />
<br />
=== Firefox Ubiquity Integration ===<br />
<br />
[https://wiki.mozilla.org/Labs/Ubiquity Ubiquity] provides a graphical command-line for Firefox. To install Ubiquity, see the [https://wiki.mozilla.org/Labs/Ubiquity/Ubiquity_0.1_User_Tutorial tutorial].<br />
<br />
To install the Ubiquity Hoogle command, visit the [http://www.randomhacks.net/git/ubiquity/hoogle/ command's home page] and click <b>Subscribe...</b> when asked whether you want to install it. You may also want to look at the [http://www.randomhacks.net/articles/2008/09/01/ubiquitous-hoogle introductory article].<br />
<br />
== Developers ==<br />
<br />
This work is licensed under the [http://www.gnu.org/copyleft/gpl.html GPL version 2.0]. By submitting any patches to Hoogle you agree to license them under the BSD license, or to assign copyright to Neil Mitchell who will include them under the GPL (either one, your choice). This is so I can relicense Hoogle under the BSD at a later date if that proves beneficial to the Haskell community.<br />
<br />
The work is intended to be helpful, open and free. If the license doesn't meet your needs then talk to me.<br />
<br />
=== The Source Code ===<br />
<br />
<tt>$ darcs get http://code.haskell.org/hoogle/</tt><br />
<br />
Contributions are most welcome. Hoogle is written in Haskell 98 + Heirarchical Modules, I do not wish to change this. Other than that, I'm pretty flexible about most aspects of Hoogle. The [http://code.google.com/p/ndmitchell/issues/list bug tracker] has many outstanding tasks, but please contact me if you have thoughts on doing something major to Hoogle, so I can give some advice.<br />
<br />
== Theoretical Foundations ==<br />
<br />
A lot of related work was done by Rittri [1] and Runciman [2] in the late 80's. Since then Di Cosmo [3] has produced a book on type isomorphisms, which is also related. Unfortunately the implementations that accompanied the earlier works were for functional languages that have since become less popular, and to my knowledge no existing functional programming language has a tool such as Hoogle.<br />
<br />
# Mikael Rittri, Using Types as Search Keys in Function Libraries. Proceedings of the fourth international conference on Functional programming languages and computer architecture: 174-183, June 1989. (http://portal.acm.org/citation.cfm?id=99384)<br />
# Colin Runciman and Ian Toyn, Retrieving reusable software components by polymorphic type. Journal of Functional Programming 1 (2): 191-211, April 1991. (http://portal.acm.org/citation.cfm?id=99383)<br />
# Roberto Di Cosmo. Isomorphisms of types: from lambda-calculus to information retrieval and language design. Birkhauser, 1995. ISBN-0-8176-3763-X (http://www.pps.jussieu.fr/~dicosmo/Publications/ISObook.html)<br />
<br />
I have given two presentations on type searching in Hoogle:<br />
<br />
* [http://www-users.cs.york.ac.uk/~ndm/downloads/slides-hoogle-08_dec_2005.pdf December 2005, York University] - information on Hoogle type searching in versions 1 to 3.<br />
* [http://www.wellquite.org/anglohaskell2008/ August 2008, AngloHaskell] - information on type searching in versions 1 to 4. Audio is also available from that link.<br />
<br />
=== Similar Tools ===<br />
<br />
I didn't know of any similar tools before starting development, and no other tool has really influenced this tool (except the first on this list). The follow are provided for comparison.<br />
<br />
* [http://www.google.com/ Google] - Google rock!<br />
* [http://holumbus.fh-wedel.de/hayoo/hayoo.html Hayoo] - Similar to Hoogle, but with less focus on type search<br />
* [http://www.krugle.com/ Krugle] - Search code, no Haskell :(<br />
<br />
== Acknowledgements ==<br />
<br />
The code is all &copy; [http://community.haskell.org/~ndm/ Neil Mitchell] 2004-2010. The initial version was done in my own time, and further refinement and reimplementation was done as part of my PhD. During Summer 2008 I was funded to full-time on Hoogle by [http://code.google.com/soc/ Google Summer of Code] with the [http://haskell.org/ haskell.org] mentoring organisation. Since then I have been working on Hoogle in my spare time. Various people have given lots of useful ideas, including my supervisor [http://www.cs.york.ac.uk/~colin/ Colin Runciman], and various members of the [http://www.cs.york.ac.uk/plasma/ Plasma group]. In addition the following people have also contributed some code or significant debugging work:<br />
<br />
* [http://www.cs.kent.ac.uk/people/rpg/tatd2/ Thomas "Bob" Davie]<br />
* [http://www.cse.unsw.edu.au/~dons/ Don Stewart]<br />
* Thomas Jäger<br />
* [http://gaal.livejournal.com/ Gaal Yahas]<br />
* [http://www-users.cs.york.ac.uk/~miked/ Mike Dodds]<br />
* [http://www.cs.chalmers.se/~d00nibro/ Niklas Broberg]<br />
* Esa Ilari Vuokko<br />
* Udo Stenzel<br />
* [http://members.chello.nl/hjgtuyl/ Henk-Jan van Tuyl]<br />
* Gwern Branwen<br />
* Tillmann Rendel<br />
* David Waern<br />
* Ganesh Sittampalam<br />
* Duncan Coutts<br />
* Peter Collingbourne<br />
* Andrea Vezzosi<br />
* Ian Lynagh<br />
<br />
In previous versions, all the data was taken from [http://www.zvon.org/other/haskell/Outputglobal/ Zvon's Haskell Guide]. Thanks to their open and friendly policy of allowing the data to be reused, this project became possible. More recent versions use the Hierarchical Libraries as distributed with GHC, and databases generated by Haddock.<br />
<br />
[[Category:Tools]]</div>Fuuzetsu