/vendor/haskell-mode/haskell-doc.el
Emacs Lisp | 1972 lines | 1185 code | 174 blank | 613 comment | 23 complexity | 5660d9174cec87faa101fe3d02e8eca0 MD5 | raw file
Possible License(s): GPL-2.0
Large files files are truncated, but you can click here to view the full file
1;;; haskell-doc.el --- show function types in echo area -*- coding: iso-8859-1 -*- 2 3;; Copyright (C) 2004, 2005, 2006, 2007, 2009 Free Software Foundation, Inc. 4;; Copyright (C) 1997 Hans-Wolfgang Loidl 5 6;; Author: Hans-Wolfgang Loidl <hwloidl@dcs.glasgow.ac.uk> 7;; Temporary Maintainer and Hacker: Graeme E Moss <gem@cs.york.ac.uk> 8;; Keywords: extensions, minor mode, language mode, Haskell 9;; Created: 1997-06-17 10;; URL: http://cvs.haskell.org/cgi-bin/cvsweb.cgi/fptools/CONTRIB/haskell-modes/emacs/haskell-doc.el?rev=HEAD 11 12;;; Copyright: 13;; ========== 14 15;; This program is free software; you can redistribute it and/or modify 16;; it under the terms of the GNU General Public License as published by 17;; the Free Software Foundation; either version 3, or (at your option) 18;; any later version. 19;; 20;; This program is distributed in the hope that it will be useful, 21;; but WITHOUT ANY WARRANTY; without even the implied warranty of 22;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23;; GNU General Public License for more details. 24;; 25;; You should have received a copy of the GNU General Public License 26;; along with this program; if not, you can either send email to this 27;; program's maintainer or write to: The Free Software Foundation, 28;; Inc.; 59 Temple Place, Suite 330; Boston, MA 02111-1307, USA. 29 30;;; Commentary: 31;; =========== 32 33;; This program shows the type of the Haskell function under the cursor in the 34;; minibuffer. It acts as a kind of "Emacs background process", by regularly 35;; checking the word under the cursor and matching it against a list of 36;; prelude, library, local and global functions. 37 38;; To show types of global functions, i.e. functions defined in a module 39;; imported by the current module, call the function 40;; `turn-on-haskell-doc-global-types'. This automatically loads all modules 41;; and builds `imenu' tables to get the types of all functions. 42;; Note: The modules are loaded recursively, so you might pull in 43;; many modules by just turning on global function support. 44;; This features is currently not very well supported. 45 46;; This program was inspired by the `eldoc.el' package by Noah Friedman. 47 48;;; Installation: 49;; ============= 50 51;; One useful way to enable this minor mode is to put the following in your 52;; .emacs: 53;; 54;; (autoload 'turn-on-haskell-doc-mode "haskell-doc" nil t) 55 56;; and depending on the major mode you use for your Haskell programs: 57;; (add-hook 'hugs-mode-hook 'turn-on-haskell-doc-mode) ; hugs-mode 58;; or 59;; (add-hook 'haskell-mode-hook 'turn-on-haskell-doc-mode) ; haskell-mode 60 61;;; Customisation: 62;; ============== 63 64;; You can control what exactly is shown by setting the following variables to 65;; either t or nil: 66;; `haskell-doc-show-global-types' (default: nil) 67;; `haskell-doc-show-reserved' (default: t) 68;; `haskell-doc-show-prelude' (default: t) 69;; `haskell-doc-show-strategy' (default: t) 70;; `haskell-doc-show-user-defined' (default: t) 71 72;; If you want to define your own strings for some identifiers define an 73;; alist of (ID . STRING) and set `haskell-doc-show-user-defined' to t. 74;; E.g: 75;; 76;; (setq haskell-doc-show-user-defined t) 77;; (setq haskell-doc-user-defined-ids 78;; (list 79;; '("main" . "just another pathetic main function") 80;; '("foo" . "a very dummy name") 81;; '("bar" . "another dummy name"))) 82 83;; The following two variables are useful to make the type fit on one line: 84;; If `haskell-doc-chop-off-context' is non-nil the context part of the type 85;; of a local fct will be eliminated (default: t). 86;; If `haskell-doc-chop-off-fctname' is non-nil the function name is not 87;; shown together with the type (default: nil). 88 89;;; Internals: 90;; ========== 91 92;; `haskell-doc-mode' is implemented as a minor-mode. So, you can combine it 93;; with any other mode. To enable it just type 94;; M-x turn-on-haskell-doc-mode 95 96;; These are the names of the functions that can be called directly by the 97;; user (with keybindings in `haskell-hugs-mode' and `haskell-mode'): 98;; `haskell-doc-mode' ... toggle haskell-doc-mode; with prefix turn it on 99;; unconditionally if the prefix is greater 0 otherwise 100;; turn it off 101;; Key: CTRL-c CTRL-o (CTRL-u CTRL-c CTRL-o) 102;; `haskell-doc-ask-mouse-for-type' ... show the type of the id under the mouse 103;; Key: C-S-M-mouse-3 104;; `haskell-doc-show-reserved' ... toggle echoing of reserved id's types 105;; `haskell-doc-show-prelude' ... toggle echoing of prelude id's types 106;; `haskell-doc-show-strategy' ... toggle echoing of strategy id's types 107;; `haskell-doc-show-user-defined' ... toggle echoing of user def id's types 108;; `haskell-doc-check-active' ... check whether haskell-doc is active; 109;; Key: CTRL-c ESC-/ 110 111;;; ToDo: 112;; ===== 113 114;; - Fix byte-compile problems in `haskell-doc-prelude-types' for getArgs etc 115;; - Write a parser for .hi files and make haskell-doc independent from 116;; hugs-mode. Read library interfaces via this parser. 117;; - Indicate kind of object with colours 118;; - Handle multi-line types 119;; - Encode i-am-fct info in the alist of ids and types. 120 121;;; Bugs: 122;; ===== 123 124;; - Some prelude fcts aren't displayed properly. This might be due to a 125;; name clash of Haskell and Elisp functions (e.g. length) which 126;; confuses Emacs when reading `haskell-doc-prelude-types' 127 128;;; Changelog: 129;; ========== 130;; $Log: haskell-doc.el,v $ 131;; Revision 1.30 2009/02/02 21:00:33 monnier 132;; (haskell-doc-imported-list): Don't add current buffer 133;; to the imported file list if it is not (yet?) visiting a file. 134;; 135;; Revision 1.29 2007-12-12 04:04:19 monnier 136;; (haskell-doc-in-code-p): New function. 137;; (haskell-doc-show-type): Use it. 138;; 139;; Revision 1.28 2007/08/30 03:10:08 monnier 140;; Comment/docs fixes. 141;; 142;; Revision 1.27 2007/07/30 17:36:50 monnier 143;; (displayed-month): Remove declaration since it's not used here. 144;; 145;; Revision 1.26 2007/02/10 06:28:55 monnier 146;; (haskell-doc-get-current-word): Remove. 147;; Change all refs to it, to use haskell-ident-at-point instead. 148;; 149;; Revision 1.25 2007/02/09 21:53:42 monnier 150;; (haskell-doc-get-current-word): Correctly distinguish 151;; variable identifiers and infix identifiers. 152;; (haskell-doc-rescan-files): Avoid switch-to-buffer. 153;; (haskell-doc-imported-list): Operate on current buffer. 154;; (haskell-doc-make-global-fct-index): Adjust call. 155;; 156;; Revision 1.24 2006/11/20 20:18:24 monnier 157;; (haskell-doc-mode-print-current-symbol-info): Fix thinko. 158;; 159;; Revision 1.23 2006/10/20 03:12:31 monnier 160;; Drop post-command-idle-hook in favor of run-with-idle-timer. 161;; (haskell-doc-timer, haskell-doc-buffers): New vars. 162;; (haskell-doc-mode): Use them. 163;; (haskell-doc-check-active): Update the check. 164;; (haskell-doc-mode-print-current-symbol-info): Remove the interactive spec. 165;; Don't sit-for unless it's really needed. 166;; 167;; Revision 1.22 2006/09/20 18:42:35 monnier 168;; Doc fix. 169;; 170;; Revision 1.21 2005/11/21 21:48:52 monnier 171;; * haskell-doc.el (haskell-doc-extract-types): Get labelled data working. 172;; (haskell-doc-prelude-types): Update via auto-generation. 173;; 174;; * haskell-doc.el (haskell-doc-extract-types): Get it partly working. 175;; (haskell-doc-fetch-lib-urls): Don't use a literal if we apply 176;; `nreverse' on it later on. 177;; (haskell-doc-prelude-types): Update some parts by auto-generation. 178;; (haskell-doc-grab, haskell-doc-string-nub-ws): Simplify. 179;; 180;; * haskell-doc.el (haskell-doc-maintainer, haskell-doc-varlist) 181;; (haskell-doc-submit-bug-report, haskell-doc-ftp-site) 182;; (haskell-doc-visit-home): Remove. 183;; (haskell-doc-reserved-ids, haskell-doc-fetch-lib-urls) 184;; (haskell-doc-extract-and-insert-types): New funs. 185;; (haskell-doc-reserved-ids): Fix type of `map'. 186;; 187;; Revision 1.20 2005/11/21 21:27:57 monnier 188;; (haskell-doc-extract-types): Get labelled data working. 189;; (haskell-doc-prelude-types): Update via auto-generation. 190;; 191;; Revision 1.19 2005/11/21 20:44:13 monnier 192;; (haskell-doc-extract-types): Get it partly working. 193;; (haskell-doc-fetch-lib-urls): Don't use a literal if we apply 194;; `nreverse' on it later on. 195;; (haskell-doc-prelude-types): Update some parts by auto-generation. 196;; (haskell-doc-grab, haskell-doc-string-nub-ws): Simplify. 197;; 198;; Revision 1.18 2005/11/21 18:02:15 monnier 199;; (haskell-doc-maintainer, haskell-doc-varlist) 200;; (haskell-doc-submit-bug-report, haskell-doc-ftp-site) 201;; (haskell-doc-visit-home): Remove. 202;; (haskell-doc-reserved-ids, haskell-doc-fetch-lib-urls) 203;; (haskell-doc-extract-and-insert-types): New funs. 204;; (haskell-doc-reserved-ids): Fix type of `map'. 205;; 206;; Revision 1.17 2005/11/20 23:55:09 monnier 207;; Add coding cookie. 208;; 209;; Revision 1.16 2005/11/07 01:28:16 monnier 210;; (haskell-doc-xemacs-p, haskell-doc-emacs-p) 211;; (haskell-doc-message): Remove. 212;; (haskell-doc-is-id-char-at): Remove. 213;; (haskell-doc-get-current-word): Rewrite. 214;; 215;; Revision 1.15 2005/11/04 17:11:12 monnier 216;; Add arch-tag. 217;; 218;; Revision 1.14 2005/08/24 11:36:32 monnier 219;; (haskell-doc-message): Paren typo. 220;; 221;; Revision 1.13 2005/08/23 19:23:27 monnier 222;; (haskell-doc-show-type): Assume that the availability 223;; of display-message won't change at runtime. 224;; 225;; Revision 1.12 2005/07/18 21:04:14 monnier 226;; (haskell-doc-message): Remove. 227;; (haskell-doc-show-type): inline it. Do nothing for if there's no doc to show. 228;; 229;; Revision 1.11 2004/12/10 17:33:18 monnier 230;; (haskell-doc-minor-mode-string): Make it dynamic. 231;; (haskell-doc-install-keymap): Remove conflicting C-c C-o binding. 232;; (haskell-doc-mode): Make a nil arg turn the mode ON. 233;; (turn-on-haskell-doc-mode): Make it an alias for haskell-doc-mode. 234;; (haskell-doc-mode): Don't touch haskell-doc-minor-mode-string. 235;; (haskell-doc-show-global-types): Don't touch 236;; haskell-doc-minor-mode-string. Call haskell-doc-make-global-fct-index. 237;; (haskell-doc-check-active): Fix message. 238;; (define-key-after): Don't define. 239;; (haskell-doc-install-keymap): Check existence of define-key-after. 240;; 241;; Revision 1.10 2004/11/25 23:03:23 monnier 242;; (haskell-doc-sym-doc): Make even the last char bold. 243;; 244;; Revision 1.9 2004/11/24 22:14:36 monnier 245;; (haskell-doc-install-keymap): Don't blindly assume there's a Hugs menu. 246;; 247;; Revision 1.8 2004/11/22 10:45:35 simonmar 248;; Fix type of getLine 249;; 250;; Revision 1.7 2004/10/14 22:27:47 monnier 251;; (turn-off-haskell-doc-mode, haskell-doc-current-info): Don't autoload. 252;; 253;; Revision 1.6 2004/10/13 22:45:22 monnier 254;; (haskell-doc): New group. 255;; (haskell-doc-show-reserved, haskell-doc-show-prelude) 256;; (haskell-doc-show-strategy, haskell-doc-show-user-defined) 257;; (haskell-doc-chop-off-context, haskell-doc-chop-off-fctname): 258;; Make them custom vars. 259;; (haskell-doc-keymap): Declare and fill it right there. 260;; (haskell-doc-mode): Simplify. 261;; (haskell-doc-toggle-var): Make it into what it was supposed to be. 262;; (haskell-doc-mode-print-current-symbol-info): Simplify. 263;; (haskell-doc-current-info): New autoloaded function. 264;; (haskell-doc-sym-doc): New fun extracted from haskell-doc-show-type. 265;; (haskell-doc-show-type): Use it. 266;; (haskell-doc-wrapped-type-p): Remove unused var `lim'. 267;; (haskell-doc-forward-sexp-safe, haskell-doc-current-symbol): Remove. Unused. 268;; (haskell-doc-visit-home): Don't require ange-ftp, it's autoloaded. 269;; (haskell-doc-install-keymap): Simplify. 270;; 271;; Revision 1.5 2003/01/09 11:56:26 simonmar 272;; Patches from Ville Skyttä <scop@xemacs.org>, the XEmacs maintainer of 273;; the haskell-mode: 274;; 275;; - Make the auto-mode-alist modifications autoload-only. 276;; 277;; Revision 1.4 2002/10/14 09:55:03 simonmar 278;; Patch to update the Prelude/libraries function names and to remove 279;; support for older versions of Haskell. 280;; 281;; Submitted by: Anders Lau Olsen <alauo@mip.sdu.dk> 282;; 283;; Revision 1.3 2002/04/30 09:34:37 rrt 284;; Remove supporting Haskell 1.4 and 1.2 from the ToDo list. It's Far Too Late. 285;; 286;; Add (require 'imenu). Thanks to N. Y. Kwok. 287;; 288;; Revision 1.2 2002/04/23 14:45:10 simonmar 289;; Tweaks to the doc strings and support for customization, from 290;; Ville Skyttä <scop@xemacs.org>. 291;; 292;; Revision 1.1 2001/07/19 16:17:36 rrt 293;; Add the current version of the Moss/Thorn/Marlow Emacs mode, along with its 294;; web pages and sample files. This is now the preferred mode, and the 295;; haskell.org pages are being changed to reflect that. Also includes the new 296;; GHCi mode from Chris Webb. 297;; 298;; Revision 1.6 1998/12/10 16:27:25 hwloidl 299;; Minor changes ("Doc" as modeline string, mouse-3 moved to C-S-M-mouse-3) 300;; 301;; Revision 1.5 1998/09/24 14:25:46 gem 302;; Fixed minor compatibility bugs with Haskell mode of Moss&Thorn. 303;; Disabled M-/ binding. 304;; 305;; Revision 1.4 1997/11/12 23:51:19 hwloidl 306;; Fixed start-up problem under emacs-19.34. 307;; Added support for wrapped (multi-line) types and 2 vars to control the 308;; behaviour with long fct types 309;; 310;; Revision 1.3 1997/11/03 00:48:03 hwloidl 311;; Major revision for first release. 312;; Added alists for showing prelude fcts, haskell syntax, and strategies 313;; Added mouse interface to show type under mouse 314;; Fixed bug which causes demon to fall over 315;; Works now with hugs-mode and haskell-mode under emacs 19.34,20 and xemacs 19.15 316;; 317 318;;; Code: 319;; ===== 320 321;;@menu 322;;* Constants and Variables:: 323;;* Install as minor mode:: 324;;* Menubar Support:: 325;;* Haskell Doc Mode:: 326;;* Switch it on or off:: 327;;* Check:: 328;;* Top level function:: 329;;* Mouse interface:: 330;;* Print fctsym:: 331;;* Movement:: 332;;* Bug Reports:: 333;;* Visit home site:: 334;;* Index:: 335;;* Token:: 336;;@end menu 337 338;;@node top, Constants and Variables, (dir), (dir) 339;;@top 340 341;;@node Constants and Variables, Install as minor mode, top, top 342;;@section Constants and Variables 343 344;;@menu 345;;* Emacs portability:: 346;;* Maintenance stuff:: 347;;* Mode Variable:: 348;;* Variables:: 349;;* Prelude types:: 350;;* Test membership:: 351;;@end menu 352 353;;@node Emacs portability, Maintenance stuff, Constants and Variables, Constants and Variables 354;;@subsection Emacs portability 355 356(require 'haskell-mode) 357(eval-when-compile (require 'cl)) 358 359(defgroup haskell-doc nil 360 "Show Haskell function types in echo area." 361 :group 'haskell 362 :prefix "haskell-doc-") 363 364;;@node Mode Variable, Variables, Maintenance stuff, Constants and Variables 365;;@subsection Mode Variable 366 367(defvar haskell-doc-mode nil 368 "*If non-nil, show the type of the function near point or a related comment. 369 370If the identifier near point is a Haskell keyword and the variable 371`haskell-doc-show-reserved' is non-nil show a one line summary 372of the syntax. 373 374If the identifier near point is a Prelude or one of the standard library 375functions and `haskell-doc-show-prelude' is non-nil show its type. 376 377If the identifier near point is local \(i.e. defined in this module\) check 378the `imenu' list of functions for the type. This obviously requires that 379your language mode uses `imenu'. 380 381If the identifier near point is global \(i.e. defined in an imported module\) 382and the variable `haskell-doc-show-global-types' is non-nil show the type of its 383function. 384 385If the identifier near point is a standard strategy or a function, type related 386related to strategies and `haskell-doc-show-strategy' is non-nil show the type 387of the function. Strategies are special to the parallel execution of Haskell. 388If you're not interested in that just turn it off. 389 390If the identifier near point is a user defined function that occurs as key 391in the alist `haskell-doc-user-defined-ids' and the variable 392`haskell-doc-show-user-defined' is non-nil show the type of the function. 393 394This variable is buffer-local.") 395(make-variable-buffer-local 'haskell-doc-mode) 396 397(defvar haskell-doc-mode-hook nil 398 "Hook invoked when entering `haskell-doc-mode'.") 399 400(defvar haskell-doc-index nil 401 "Variable holding an alist matching file names to fct-type alists. 402The function `haskell-doc-make-global-fct-index' rebuilds this variables 403\(similar to an `imenu' rescan\). 404This variable is buffer-local.") 405(make-variable-buffer-local 'haskell-doc-index) 406 407(defcustom haskell-doc-show-global-types nil 408 "If non-nil, search for the types of global functions by loading the files. 409This variable is buffer-local." 410 :group 'haskell-doc 411 :type 'boolean) 412(make-variable-buffer-local 'haskell-doc-show-global-types) 413 414(defcustom haskell-doc-show-reserved t 415 "If non-nil, show a documentation string for reserved ids. 416This variable is buffer-local." 417 :group 'haskell-doc 418 :type 'boolean) 419(make-variable-buffer-local 'haskell-doc-show-reserved) 420 421(defcustom haskell-doc-show-prelude t 422 "If non-nil, show a documentation string for prelude functions. 423This variable is buffer-local." 424 :group 'haskell-doc 425 :type 'boolean) 426(make-variable-buffer-local 'haskell-doc-show-prelude) 427 428(defcustom haskell-doc-show-strategy t 429 "If non-nil, show a documentation string for strategies. 430This variable is buffer-local." 431 :group 'haskell-doc 432 :type 'boolean) 433(make-variable-buffer-local 'haskell-doc-show-strategy) 434 435(defcustom haskell-doc-show-user-defined t 436 "If non-nil, show a documentation string for user defined ids. 437This variable is buffer-local." 438 :group 'haskell-doc 439 :type 'boolean) 440(make-variable-buffer-local 'haskell-doc-show-user-defined) 441 442(defcustom haskell-doc-chop-off-context t 443 "If non-nil eliminate the context part in a Haskell type." 444 :group 'haskell-doc 445 :type 'boolean) 446 447(defcustom haskell-doc-chop-off-fctname nil 448 "If non-nil omit the function name and show only the type." 449 :group 'haskell-doc 450 :type 'boolean) 451 452(defvar haskell-doc-search-distance 40 ; distance in characters 453 "*How far to search when looking for the type declaration of fct under cursor.") 454 455;;@node Variables, Prelude types, Mode Variable, Constants and Variables 456;;@subsection Variables 457 458(defvar haskell-doc-idle-delay 0.50 459 "*Number of seconds of idle time to wait before printing. 460If user input arrives before this interval of time has elapsed after the 461last input, no documentation will be printed. 462 463If this variable is set to 0, no idle time is required.") 464 465(defvar haskell-doc-argument-case 'identity ; 'upcase 466 "Case to display argument names of functions, as a symbol. 467This has two preferred values: `upcase' or `downcase'. 468Actually, any name of a function which takes a string as an argument and 469returns another string is acceptable.") 470 471(defvar haskell-doc-mode-message-commands nil 472 "*Obarray of command names where it is appropriate to print in the echo area. 473 474This is not done for all commands since some print their own 475messages in the echo area, and these functions would instantly overwrite 476them. But `self-insert-command' as well as most motion commands are good 477candidates. 478 479It is probably best to manipulate this data structure with the commands 480`haskell-doc-add-command' and `haskell-doc-remove-command'.") 481 482;;(cond ((null haskell-doc-mode-message-commands) 483;; ;; If you increase the number of buckets, keep it a prime number. 484;; (setq haskell-doc-mode-message-commands (make-vector 31 0)) 485;; (let ((list '("self-insert-command" 486;; "next-" "previous-" 487;; "forward-" "backward-" 488;; "beginning-of-" "end-of-" 489;; "goto-" 490;; "recenter" 491;; "scroll-")) 492;; (syms nil)) 493;; (while list 494;; (setq syms (all-completions (car list) obarray 'fboundp)) 495;; (setq list (cdr list)) 496;; (while syms 497;; (set (intern (car syms) haskell-doc-mode-message-commands) t) 498;; (setq syms (cdr syms))))))) 499 500;; Bookkeeping; the car contains the last symbol read from the buffer. 501;; The cdr contains the string last displayed in the echo area, so it can 502;; be printed again if necessary without reconsing. 503(defvar haskell-doc-last-data '(nil . nil)) 504 505(defvar haskell-doc-minor-mode-string 506 '(haskell-doc-show-global-types " DOC" " Doc") 507 "*String to display in mode line when Haskell-Doc Mode is enabled.") 508 509 510;;@node Prelude types, Test membership, Variables, Constants and Variables 511;;@subsection Prelude types 512 513;;@cindex haskell-doc-reserved-ids 514 515(defvar haskell-doc-reserved-ids 516 '(("case" . "case exp of { alts [;] }") 517 ("class" . "class [context =>] simpleclass [where { cbody [;] }]") 518 ("data" . "data [context =>] simpletype = constrs [deriving]") 519 ("default" . "default (type1 , ... , typen)") 520 ("deriving" . "deriving (dclass | (dclass1, ... , dclassn))") ; used with data or newtype 521 ("do" . "do { stmts [;] } stmts -> exp [; stmts] | pat <- exp ; stmts | let decllist ; stmts") 522 ("else" . "if exp then exp else exp") 523 ("if" . "if exp then exp else exp") 524 ("import" . "import [qualified] modid [as modid] [impspec]") 525 ("in" . "let decllist in exp") 526 ("infix" . "infix [digit] ops") 527 ("infixl" . "infixl [digit] ops") 528 ("infixr" . "infixr [digit] ops") 529 ("instance" . "instance [context =>] qtycls inst [where { valdefs [;] }]") 530 ("let" . "let { decl; ...; decl [;] } in exp") 531 ("module" . "module modid [exports] where body") 532 ("newtype" . "newtype [context =>] simpletype = con atype [deriving]") 533 ("of" . "case exp of { alts [;] }") 534 ("then" . "if exp then exp else exp") 535 ("type" . "type simpletype = type") 536 ("where" . "exp where { decl; ...; decl [;] }") ; check that ; see also class, instance, module 537 ("as" . "import [qualified] modid [as modid] [impspec]") 538 ("qualified" . "import [qualified] modid [as modid] [impspec]") 539 ("hiding" . "hiding ( import1 , ... , importn [ , ] )")) 540 "An alist of reserved identifiers. 541Each element is of the form (ID . DOC) where both ID and DOC are strings. 542DOC should be a concise single-line string describing the construct in which 543the keyword is used.") 544 545(eval-and-compile 546(defalias 'haskell-doc-split-string 547 (if (condition-case () 548 (split-string "" nil t) 549 (wrong-number-of-arguments nil)) 550 'split-string 551 ;; copied from Emacs 22 552 (lambda (string &optional separators omit-nulls) 553 (let ((keep-nulls (not (if separators omit-nulls t))) 554 (rexp (or separators "[ \f\t\n\r\v]+")) 555 (start 0) 556 notfirst 557 (list nil)) 558 (while (and (string-match rexp string 559 (if (and notfirst 560 (= start (match-beginning 0)) 561 (< start (length string))) 562 (1+ start) start)) 563 (< start (length string))) 564 (setq notfirst t) 565 (if (or keep-nulls (< start (match-beginning 0))) 566 (setq list 567 (cons (substring string start (match-beginning 0)) 568 list))) 569 (setq start (match-end 0))) 570 (if (or keep-nulls (< start (length string))) 571 (setq list 572 (cons (substring string start) 573 list))) 574 (nreverse list)))))) 575 576;;@cindex haskell-doc-prelude-types 577 578(defun haskell-doc-extract-types (url) 579 (with-temp-buffer 580 (insert-file-contents url) 581 (goto-char (point-min)) 582 (while (search-forward " " nil t) (replace-match " " t t)) 583 584 ;; First, focus on the actual code, removing the surrounding HTML text. 585 (goto-char (point-min)) 586 (let ((last (point-min)) 587 (modules nil)) 588 (while (re-search-forward "^module +\\([[:alnum:]]+\\)" nil t) 589 (let ((module (match-string 1))) 590 (if (member module modules) 591 ;; The library nodes of the HTML doc contain modules twice: 592 ;; once at the top, with only type declarations, and once at 593 ;; the bottom with an actual sample implementation which may 594 ;; include declaration of non-exported values. 595 ;; We're now at this second occurrence is the implementation 596 ;; which should thus be ignored. 597 nil 598 (push module modules) 599 (delete-region last (point)) 600 (search-forward "</tt>") 601 ;; Some of the blocks of code are split. 602 (while (looking-at "\\(<[^<>]+>[ \t\n]*\\)*<tt>") 603 (goto-char (match-end 0)) 604 (search-forward "</tt>")) 605 (setq last (point))))) 606 (delete-region last (point-max)) 607 608 ;; Then process the HTML encoding to get back to pure ASCII. 609 (goto-char (point-min)) 610 (while (search-forward "<br>" nil t) (replace-match "\n" t t)) 611 ;; (goto-char (point-min)) 612 ;; (while (re-search-forward "<[^<>]+>" nil t) (replace-match "" t t)) 613 (goto-char (point-min)) 614 (while (search-forward ">" nil t) (replace-match ">" t t)) 615 (goto-char (point-min)) 616 (while (search-forward "<" nil t) (replace-match "<" t t)) 617 (goto-char (point-min)) 618 (while (search-forward "&" nil t) (replace-match "&" t t)) 619 (goto-char (point-min)) 620 (if (re-search-forward "&[a-z]+;" nil t) 621 (error "Unexpected charref %s" (match-string 0))) 622 ;; Remove TABS. 623 (goto-char (point-min)) 624 (while (search-forward "\t" nil t) (replace-match " " t t)) 625 626 ;; Finally, extract the actual data. 627 (goto-char (point-min)) 628 (let* ((elems nil) 629 (space-re "[ \t\n]*\\(?:--.*\n[ \t\n]*\\)*") 630 (comma-re (concat " *," space-re)) 631 ;; A list of identifiers. We have to be careful to weed out 632 ;; entries like "ratPrec = 7 :: Int". Also ignore entries 633 ;; which start with a < since they're actually in the HTML text 634 ;; part. And the list may be spread over several lines, cut 635 ;; after a comma. 636 (idlist-re 637 (concat "\\([^< \t\n][^ \t\n]*" 638 "\\(?:" comma-re "[^ \t\n]+\\)*\\)")) 639 ;; A type. A few types are spread over 2 lines, 640 ;; cut after the "=>", so we have to handle these as well. 641 (type-re "\\(.*[^\n>]\\(?:>[ \t\n]+.*[^\n>]\\)*\\) *$") 642 ;; A decl of a list of values, possibly indented. 643 (val-decl-re 644 (concat "^\\( +\\)?" idlist-re "[ \t\n]*::[ \t\n]*" type-re)) 645 (re (concat 646 ;; 3 possibilities: a class decl, a data decl, or val decl. 647 ;; First, let's match a class decl. 648 "^class \\(?:.*=>\\)? *\\(.*[^ \t\n]\\)[ \t\n]*where" 649 650 ;; Or a value decl: 651 "\\|" val-decl-re 652 653 "\\|" ;; Or a data decl. We only handle single-arm 654 ;; datatypes with labels. 655 "^data +\\([[:alnum:]][[:alnum:] ]*[[:alnum:]]\\)" 656 " *=.*{\\([^}]+\\)}" 657 )) 658 (re-class (concat "^[^ \t\n]\\|" re)) 659 curclass) 660 (while (re-search-forward (if curclass re-class re) nil t) 661 (cond 662 ;; A class decl. 663 ((match-end 1) (setq curclass (match-string 1))) 664 ;; A value decl. 665 ((match-end 4) 666 (let ((type (match-string 4)) 667 (vars (match-string 3)) 668 (indented (match-end 2))) 669 (if (string-match "[ \t\n][ \t\n]+" type) 670 (setq type (replace-match " " t t type))) 671 (if (string-match " *\\(--.*\\)?\\'" type) 672 (setq type (substring type 0 (match-beginning 0)))) 673 (if indented 674 (if curclass 675 (if (string-match "\\`\\(.*[^ \t\n]\\) *=> *" type) 676 (let ((classes (match-string 1 type))) 677 (setq type (substring type (match-end 0))) 678 (if (string-match "\\`(.*)\\'" classes) 679 (setq classes (substring classes 1 -1))) 680 (setq type (concat "(" curclass ", " classes 681 ") => " type))) 682 (setq type (concat curclass " => " type))) 683 ;; It's actually not an error: just a type annotation on 684 ;; some local variable. 685 ;; (error "Indentation outside a class in %s: %s" 686 ;; module vars) 687 nil) 688 (setq curclass nil)) 689 (dolist (var (haskell-doc-split-string vars comma-re t)) 690 (if (string-match "(.*)" var) (setq var (substring var 1 -1))) 691 (push (cons var type) elems)))) 692 ;; A datatype decl. 693 ((match-end 5) 694 (setq curclass nil) 695 (let ((name (match-string 5))) 696 (save-excursion 697 (save-restriction 698 (narrow-to-region (match-beginning 6) (match-end 6)) 699 (goto-char (point-min)) 700 (while (re-search-forward val-decl-re nil t) 701 (let ((vars (match-string 2)) 702 (type (match-string 3))) 703 (if (string-match "[ \t\n][ \t\n]+" type) 704 (setq type (replace-match " " t t type))) 705 (if (string-match " *\\(--.*\\)?\\'" type) 706 (setq type (substring type 0 (match-beginning 0)))) 707 (if (string-match ",\\'" type) 708 (setq type (substring type 0 -1))) 709 (setq type (concat name " -> " type)) 710 (dolist (var (haskell-doc-split-string vars comma-re t)) 711 (if (string-match "(.*)" var) 712 (setq var (substring var 1 -1))) 713 (push (cons var type) elems)))))))) 714 715 ;; The end of a class declaration. 716 (t (setq curclass nil) (beginning-of-line)))) 717 (cons (car (last modules)) elems))))) 718 719(defun haskell-doc-fetch-lib-urls (base-url) 720 (with-temp-buffer 721 (insert-file-contents base-url) 722 (goto-char (point-min)) 723 (search-forward "Part II: Libraries") 724 (delete-region (point-min) (point)) 725 (search-forward "</table>") 726 (delete-region (point) (point-max)) 727 (goto-char (point-min)) 728 (let ((libs (list "standard-prelude.html"))) 729 (while (re-search-forward "<a href=\"\\([^\"]+\\)\">" nil t) 730 (push (match-string 1) libs)) 731 (mapcar (lambda (s) (expand-file-name s (file-name-directory base-url))) 732 (nreverse libs))))) 733 734(defun haskell-doc-extract-and-insert-types (url) 735 "Fetch the types from the online doc and insert them at point. 736URL is the URL of the online doc." 737 (interactive (if current-prefix-arg 738 (read-file-name "URL: ") 739 (list "http://www.haskell.org/onlinereport/"))) 740 (let ((urls (haskell-doc-fetch-lib-urls url))) 741 (dolist (url urls) 742 (let ((data (haskell-doc-extract-types url))) 743 (insert ";; " (pop data)) (indent-according-to-mode) (newline) 744 (dolist (elem (sort data (lambda (x y) (string-lessp (car x) (car y))))) 745 (prin1 elem (current-buffer)) 746 (indent-according-to-mode) (newline)))))) 747 748(defvar haskell-doc-prelude-types 749 ;; This list was auto generated by `haskell-doc-extract-and-insert-types'. 750 '( 751 ;; Prelude 752 ("!!" . "[a] -> Int -> a") 753 ("$" . "(a -> b) -> a -> b") 754 ("$!" . "(a -> b) -> a -> b") 755 ("&&" . "Bool -> Bool -> Bool") 756 ("*" . "Num a => a -> a -> a") 757 ("**" . "Floating a => a -> a -> a") 758 ("+" . "Num a => a -> a -> a") 759 ("++" . "[a] -> [a] -> [a]") 760 ("-" . "Num a => a -> a -> a") 761 ("." . "(b -> c) -> (a -> b) -> a -> c") 762 ("/" . "Fractional a => a -> a -> a") 763 ("/=" . "Eq a => a -> a -> Bool") 764 ("<" . "Ord a => a -> a -> Bool") 765 ("<=" . "Ord a => a -> a -> Bool") 766 ("=<<" . "Monad m => (a -> m b) -> m a -> m b") 767 ("==" . "Eq a => a -> a -> Bool") 768 (">" . "Ord a => a -> a -> Bool") 769 (">=" . "Ord a => a -> a -> Bool") 770 (">>" . "Monad m => m a -> m b -> m b") 771 (">>=" . "Monad m => m a -> (a -> m b) -> m b") 772 ("^" . "(Num a, Integral b) => a -> b -> a") 773 ("^^" . "(Fractional a, Integral b) => a -> b -> a") 774 ("abs" . "Num a => a -> a") 775 ("acos" . "Floating a => a -> a") 776 ("acosh" . "Floating a => a -> a") 777 ("all" . "(a -> Bool) -> [a] -> Bool") 778 ("and" . "[Bool] -> Bool") 779 ("any" . "(a -> Bool) -> [a] -> Bool") 780 ("appendFile" . "FilePath -> String -> IO ()") 781 ("asTypeOf" . "a -> a -> a") 782 ("asin" . "Floating a => a -> a") 783 ("asinh" . "Floating a => a -> a") 784 ("atan" . "Floating a => a -> a") 785 ("atan2" . "RealFloat a => a -> a -> a") 786 ("atanh" . "Floating a => a -> a") 787 ("break" . "(a -> Bool) -> [a] -> ([a],[a])") 788 ("catch" . "IO a -> (IOError -> IO a) -> IO a") 789 ("ceiling" . "(RealFrac a, Integral b) => a -> b") 790 ("compare" . "Ord a => a -> a -> Ordering") 791 ("concat" . "[[a]] -> [a]") 792 ("concatMap" . "(a -> [b]) -> [a] -> [b]") 793 ("const" . "a -> b -> a") 794 ("cos" . "Floating a => a -> a") 795 ("cosh" . "Floating a => a -> a") 796 ("curry" . "((a, b) -> c) -> a -> b -> c") 797 ("cycle" . "[a] -> [a]") 798 ("decodeFloat" . "RealFloat a => a -> (Integer,Int)") 799 ("div" . "Integral a => a -> a -> a") 800 ("divMod" . "Integral a => a -> a -> (a,a)") 801 ("drop" . "Int -> [a] -> [a]") 802 ("dropWhile" . "(a -> Bool) -> [a] -> [a]") 803 ("either" . "(a -> c) -> (b -> c) -> Either a b -> c") 804 ("elem" . "(Eq a) => a -> [a] -> Bool") 805 ("encodeFloat" . "RealFloat a => Integer -> Int -> a") 806 ("enumFrom" . "Enum a => a -> [a]") 807 ("enumFromThen" . "Enum a => a -> a -> [a]") 808 ("enumFromThenTo" . "Enum a => a -> a -> a -> [a]") 809 ("enumFromTo" . "Enum a => a -> a -> [a]") 810 ("error" . "String -> a") 811 ("even" . "(Integral a) => a -> Bool") 812 ("exp" . "Floating a => a -> a") 813 ("exponent" . "RealFloat a => a -> Int") 814 ("fail" . "Monad m => String -> m a") 815 ("filter" . "(a -> Bool) -> [a] -> [a]") 816 ("flip" . "(a -> b -> c) -> b -> a -> c") 817 ("floatDigits" . "RealFloat a => a -> Int") 818 ("floatRadix" . "RealFloat a => a -> Integer") 819 ("floatRange" . "RealFloat a => a -> (Int,Int)") 820 ("floor" . "(RealFrac a, Integral b) => a -> b") 821 ("fmap" . "Functor f => (a -> b) -> f a -> f b") 822 ("foldl" . "(a -> b -> a) -> a -> [b] -> a") 823 ("foldl1" . "(a -> a -> a) -> [a] -> a") 824 ("foldr" . "(a -> b -> b) -> b -> [a] -> b") 825 ("foldr1" . "(a -> a -> a) -> [a] -> a") 826 ("fromEnum" . "Enum a => a -> Int") 827 ("fromInteger" . "Num a => Integer -> a") 828 ("fromIntegral" . "(Integral a, Num b) => a -> b") 829 ("fromRational" . "Fractional a => Rational -> a") 830 ("fst" . "(a,b) -> a") 831 ("gcd" . "(Integral a) => a -> a -> a") 832 ("getChar" . "IO Char") 833 ("getContents" . "IO String") 834 ("getLine" . "IO String") 835 ("head" . "[a] -> a") 836 ("id" . "a -> a") 837 ("init" . "[a] -> [a]") 838 ("interact" . "(String -> String) -> IO ()") 839 ("ioError" . "IOError -> IO a") 840 ("isDenormalized" . "RealFloat a => a -> Bool") 841 ("isIEEE" . "RealFloat a => a -> Bool") 842 ("isInfinite" . "RealFloat a => a -> Bool") 843 ("isNaN" . "RealFloat a => a -> Bool") 844 ("isNegativeZero" . "RealFloat a => a -> Bool") 845 ("iterate" . "(a -> a) -> a -> [a]") 846 ("last" . "[a] -> a") 847 ("lcm" . "(Integral a) => a -> a -> a") 848 ("length" . "[a] -> Int") 849 ("lex" . "ReadS String") 850 ("lines" . "String -> [String]") 851 ("log" . "Floating a => a -> a") 852 ("logBase" . "Floating a => a -> a -> a") 853 ("lookup" . "(Eq a) => a -> [(a,b)] -> Maybe b") 854 ("map" . "(a -> b) -> [a] -> [b]") 855 ("mapM" . "Monad m => (a -> m b) -> [a] -> m [b]") 856 ("mapM_" . "Monad m => (a -> m b) -> [a] -> m ()") 857 ("max" . "Ord a => a -> a -> a") 858 ("maxBound" . "Bounded a => a") 859 ("maximum" . "(Ord a) => [a] -> a") 860 ("maybe" . "b -> (a -> b) -> Maybe a -> b") 861 ("min" . "Ord a => a -> a -> a") 862 ("minBound" . "Bounded a => a") 863 ("minimum" . "(Ord a) => [a] -> a") 864 ("mod" . "Integral a => a -> a -> a") 865 ("negate" . "Num a => a -> a") 866 ("not" . "Bool -> Bool") 867 ("notElem" . "(Eq a) => a -> [a] -> Bool") 868 ("null" . "[a] -> Bool") 869 ("numericEnumFrom" . "(Fractional a) => a -> [a]") 870 ("numericEnumFromThen" . "(Fractional a) => a -> a -> [a]") 871 ("numericEnumFromThenTo" . "(Fractional a, Ord a) => a -> a -> a -> [a]") 872 ("numericEnumFromTo" . "(Fractional a, Ord a) => a -> a -> [a]") 873 ("odd" . "(Integral a) => a -> Bool") 874 ("or" . "[Bool] -> Bool") 875 ("otherwise" . "Bool") 876 ("pi" . "Floating a => a") 877 ("pred" . "Enum a => a -> a") 878 ("print" . "Show a => a -> IO ()") 879 ("product" . "(Num a) => [a] -> a") 880 ("properFraction" . "(RealFrac a, Integral b) => a -> (b,a)") 881 ("putChar" . "Char -> IO ()") 882 ("putStr" . "String -> IO ()") 883 ("putStrLn" . "String -> IO ()") 884 ("quot" . "Integral a => a -> a -> a") 885 ("quotRem" . "Integral a => a -> a -> (a,a)") 886 ("read" . "(Read a) => String -> a") 887 ("readFile" . "FilePath -> IO String") 888 ("readIO" . "Read a => String -> IO a") 889 ("readList" . "Read a => ReadS [a]") 890 ("readLn" . "Read a => IO a") 891 ("readParen" . "Bool -> ReadS a -> ReadS a") 892 ("reads" . "(Read a) => ReadS a") 893 ("readsPrec" . "Read a => Int -> ReadS a") 894 ("realToFrac" . "(Real a, Fractional b) => a -> b") 895 ("recip" . "Fractional a => a -> a") 896 ("rem" . "Integral a => a -> a -> a") 897 ("repeat" . "a -> [a]") 898 ("replicate" . "Int -> a -> [a]") 899 ("return" . "Monad m => a -> m a") 900 ("reverse" . "[a] -> [a]") 901 ("round" . "(RealFrac a, Integral b) => a -> b") 902 ("scaleFloat" . "RealFloat a => Int -> a -> a") 903 ("scanl" . "(a -> b -> a) -> a -> [b] -> [a]") 904 ("scanl1" . "(a -> a -> a) -> [a] -> [a]") 905 ("scanr" . "(a -> b -> b) -> b -> [a] -> [b]") 906 ("scanr1" . "(a -> a -> a) -> [a] -> [a]") 907 ("seq" . "a -> b -> b") 908 ("sequence" . "Monad m => [m a] -> m [a]") 909 ("sequence_" . "Monad m => [m a] -> m ()") 910 ("show" . "Show a => a -> String") 911 ("showChar" . "Char -> ShowS") 912 ("showList" . "Show a => [a] -> ShowS") 913 ("showParen" . "Bool -> ShowS -> ShowS") 914 ("showString" . "String -> ShowS") 915 ("shows" . "(Show a) => a -> ShowS") 916 ("showsPrec" . "Show a => Int -> a -> ShowS") 917 ("significand" . "RealFloat a => a -> a") 918 ("signum" . "Num a => a -> a") 919 ("sin" . "Floating a => a -> a") 920 ("sinh" . "Floating a => a -> a") 921 ("snd" . "(a,b) -> b") 922 ("span" . "(a -> Bool) -> [a] -> ([a],[a])") 923 ("splitAt" . "Int -> [a] -> ([a],[a])") 924 ("sqrt" . "Floating a => a -> a") 925 ("subtract" . "(Num a) => a -> a -> a") 926 ("succ" . "Enum a => a -> a") 927 ("sum" . "(Num a) => [a] -> a") 928 ("tail" . "[a] -> [a]") 929 ("take" . "Int -> [a] -> [a]") 930 ("takeWhile" . "(a -> Bool) -> [a] -> [a]") 931 ("tan" . "Floating a => a -> a") 932 ("tanh" . "Floating a => a -> a") 933 ("toEnum" . "Enum a => Int -> a") 934 ("toInteger" . "Integral a => a -> Integer") 935 ("toRational" . "Real a => a -> Rational") 936 ("truncate" . "(RealFrac a, Integral b) => a -> b") 937 ("uncurry" . "(a -> b -> c) -> ((a, b) -> c)") 938 ("undefined" . "a") 939 ("unlines" . "[String] -> String") 940 ("until" . "(a -> Bool) -> (a -> a) -> a -> a") 941 ("unwords" . "[String] -> String") 942 ("unzip" . "[(a,b)] -> ([a],[b])") 943 ("unzip3" . "[(a,b,c)] -> ([a],[b],[c])") 944 ("userError" . "String -> IOError") 945 ("words" . "String -> [String]") 946 ("writeFile" . "FilePath -> String -> IO ()") 947 ("zip" . "[a] -> [b] -> [(a,b)]") 948 ("zip3" . "[a] -> [b] -> [c] -> [(a,b,c)]") 949 ("zipWith" . "(a->b->c) -> [a]->[b]->[c]") 950 ("zipWith3" . "(a->b->c->d) -> [a]->[b]->[c]->[d]") 951 ("||" . "Bool -> Bool -> Bool") 952 ;; Ratio 953 ("%" . "(Integral a) => a -> a -> Ratio a") 954 ("approxRational" . "(RealFrac a) => a -> a -> Rational") 955 ("denominator" . "(Integral a) => Ratio a -> a") 956 ("numerator" . "(Integral a) => Ratio a -> a") 957 ;; Complex 958 ("cis" . "(RealFloat a) => a -> Complex a") 959 ("conjugate" . "(RealFloat a) => Complex a -> Complex a") 960 ("imagPart" . "(RealFloat a) => Complex a -> a") 961 ("magnitude" . "(RealFloat a) => Complex a -> a") 962 ("mkPolar" . "(RealFloat a) => a -> a -> Complex a") 963 ("phase" . "(RealFloat a) => Complex a -> a") 964 ("polar" . "(RealFloat a) => Complex a -> (a,a)") 965 ("realPart" . "(RealFloat a) => Complex a -> a") 966 ;; Numeric 967 ("floatToDigits" . "(RealFloat a) => Integer -> a -> ([Int], Int)") 968 ("fromRat" . "(RealFloat a) => Rational -> a") 969 ("lexDigits" . "ReadS String") 970 ("readDec" . "(Integral a) => ReadS a") 971 ("readFloat" . "(RealFrac a) => ReadS a") 972 ("readHex" . "(Integral a) => ReadS a") 973 ("readInt" . "(Integral a) => a -> (Char -> Bool) -> (Char -> Int) -> ReadS a") 974 ("readOct" . "(Integral a) => ReadS a") 975 ("readSigned" . "(Real a) => ReadS a -> ReadS a") 976 ("showEFloat" . "(RealFloat a) => Maybe Int -> a -> ShowS") 977 ("showFFloat" . "(RealFloat a) => Maybe Int -> a -> ShowS") 978 ("showFloat" . "(RealFloat a) => a -> ShowS") 979 ("showGFloat" . "(RealFloat a) => Maybe Int -> a -> ShowS") 980 ("showHex" . "Integral a => a -> ShowS") 981 ("showInt" . "Integral a => a -> ShowS") 982 ("showIntAtBase" . "Integral a => a -> (Int -> Char) -> a -> ShowS") 983 ("showOct" . "Integral a => a -> ShowS") 984 ("showSigned" . "(Real a) => (a -> ShowS) -> Int -> a -> ShowS") 985 ;; Ix 986 ("inRange" . "Ix a => (a,a) -> a -> Bool") 987 ("index" . "Ix a => (a,a) -> a -> Int") 988 ("range" . "Ix a => (a,a) -> [a]") 989 ("rangeSize" . "Ix a => (a,a) -> Int") 990 ;; Array 991 ("!" . "(Ix a) => Array a b -> a -> b") 992 ("//" . "(Ix a) => Array a b -> [(a,b)] -> Array a b") 993 ("accum" . "(Ix a) => (b -> c -> b) -> Array a b -> [(a,c)]") 994 ("accumArray" . "(Ix a) => (b -> c -> b) -> b -> (a,a) -> [(a,c)]") 995 ("array" . "(Ix a) => (a,a) -> [(a,b)] -> Array a b") 996 ("assocs" . "(Ix a) => Array a b -> [(a,b)]") 997 ("bounds" . "(Ix a) => Array a b -> (a,a)") 998 ("elems" . "(Ix a) => Array a b -> [b]") 999 ("indices" . "(Ix a) => Array a b -> [a]") 1000 ("ixmap" . "(Ix a, Ix b) => (a,a) -> (a -> b) -> Array b c") 1001 ("listArray" . "(Ix a) => (a,a) -> [b] -> Array a b") 1002 ;; List 1003 ("\\\\" . "Eq a => [a] -> [a] -> [a]") 1004 ("delete" . "Eq a => a -> [a] -> [a]") 1005 ("deleteBy" . "(a -> a -> Bool) -> a -> [a] -> [a]") 1006 ("deleteFirstsBy" . "(a -> a -> Bool) -> [a] -> [a] -> [a]") 1007 ("elemIndex" . "Eq a => a -> [a] -> Maybe Int") 1008 ("elemIndices" . "Eq a => a -> [a] -> [Int]") 1009 ("find" . "(a -> Bool) -> [a] -> Maybe a") 1010 ("findIndex" . "(a -> Bool) -> [a] -> Maybe Int") 1011 ("findIndices" . "(a -> Bool) -> [a] -> [Int]") 1012 ("genericDrop" . "Integral a => a -> [b] -> [b]") 1013 ("genericIndex" . "Integral a => [b] -> a -> b") 1014 ("genericLength" . "Integral a => [b] -> a") 1015 ("genericReplicate" . "Integral a => a -> b -> [b]") 1016 ("genericSplitAt" . "Integral a => a -> [b] -> ([b],[b])") 1017 ("genericTake" . "Integral a => a -> [b] -> [b]") 1018 ("group" . "Eq a => [a] -> [[a]]") 1019 ("groupBy" . "(a -> a -> Bool) -> [a] -> [[a]]") 1020 ("inits" . "[a] -> [[a]]") 1021 ("insert" . "Ord a => a -> [a] -> [a]") 1022 ("insertBy" . "(a -> a -> Ordering) -> a -> [a] -> [a]") 1023 ("intersect" . "Eq a => [a] -> [a] -> [a]") 1024 ("intersectBy" . "(a -> a -> Bool) -> [a] -> [a] -> [a]") 1025 ("intersperse" . "a -> [a] -> [a]") 1026 ("isPrefixOf" . "Eq a => [a] -> [a] -> Bool") 1027 ("isSuffixOf" . "Eq a => [a] -> [a] -> Bool") 1028 ("mapAccumL" . "(a -> b -> (a, c)) -> a -> [b] -> (a, [c])") 1029 ("mapAccumR" . "(a -> b -> (a, c)) -> a -> [b] -> (a, [c])") 1030 ("maximumBy" . "(a -> a -> Ordering) -> [a] -> a") 1031 ("minimumBy" . "(a -> a -> Ordering) -> [a] -> a") 1032 ("nub" . "Eq a => [a] -> [a]") 1033 ("nubBy" . "(a -> a -> Bool) -> [a] -> [a]") 1034 ("partition" . "(a -> Bool) -> [a] -> ([a],[a])") 1035 ("sort" . "Ord a => [a] -> [a]") 1036 ("sortBy" . "(a -> a -> Ordering) -> [a] -> [a]") 1037 ("tails" . "[a] -> [[a]]") 1038 ("transpose" . "[[a]] -> [[a]]") 1039 ("unfoldr" . "(b -> Maybe (a,b)) -> b -> [a]") 1040 ("union" . "Eq a => [a] -> [a] -> [a]") 1041 ("unionBy" . "(a -> a -> Bool) -> [a] -> [a] -> [a]") 1042 ("unzip4" . "[(a,b,c,d)] -> ([a],[b],[c],[d])") 1043 ("unzip5" . "[(a,b,c,d,e)] -> ([a],[b],[c],[d],[e])") 1044 ("unzip6" . "[(a,b,c,d,e,f)] -> ([a],[b],[c],[d],[e],[f])") 1045 ("unzip7" . "[(a,b,c,d,e,f,g)] -> ([a],[b],[c],[d],[e],[f],[g])") 1046 ("zip4" . "[a] -> [b] -> [c] -> [d] -> [(a,b,c,d)]") 1047 ("zip5" . "[a] -> [b] -> [c] -> [d] -> [e] -> [(a,b,c,d,e)]") 1048 ("zip6" . "[a] -> [b] -> [c] -> [d] -> [e] -> [f]") 1049 ("zip7" . "[a] -> [b] -> [c] -> [d] -> [e] -> [f] -> [g]") 1050 ("zipWith4" . "(a->b->c->d->e) -> [a]->[b]->[c]->[d]->[e]") 1051 ("zipWith5" . "(a->b->c->d->e->f) ->") 1052 ("zipWith6" . "(a->b->c->d->e->f->g) -> [a]->[b]->[c]->[d]->[e]->[f]->[g]") 1053 ("zipWith7" . "(a->b->c->d->e->f->g->h) -> [a]->[b]->[c]->[d]->[e]->[f]->[g]->[h]") 1054 ;; Maybe 1055 ("catMaybes" . "[Maybe a] -> [a]") 1056 ("fromJust" . "Maybe a -> a") 1057 ("fromMaybe" . "a -> Maybe a -> a") 1058 ("isJust" . "Maybe a -> Bool") 1059 ("isNothing" . "Maybe a -> Bool") 1060 ("listToMaybe" . "[a] -> Maybe a") 1061 ("mapMaybe" . "(a -> Maybe b) -> [a] -> [b]") 1062 ("maybeToList" . "Maybe a -> [a]") 1063 ;; Char 1064 ("chr" . "Int -> Char") 1065 ("digitToInt" . "Char -> Int") 1066 ("intToDigit" . "Int -> Char") 1067 ("isAlpha" . "Char -> Bool") 1068 ("isAlphaNum" . "Char -> Bool") 1069 ("isAscii" . "Char -> Bool") 1070 ("isControl" . "Char -> Bool") 1071 ("isDigit" . "Char -> Bool") 1072 ("isHexDigit" . "Char -> Bool") 1073 ("isLatin1" . "Char -> Bool") 1074 ("isLower" . "Char -> Bool") 1075 ("isOctDigit" . "Char -> Bool") 1076 ("isPrint" . "Char -> Bool") 1077 ("isSpace" . "Char -> Bool") 1078 ("isUpper" . "Char -> Bool") 1079 ("lexLitChar" . "ReadS String") 1080 ("ord" . "Char -> Int") 1081 ("readLitChar" . "ReadS Char") 1082 ("showLitChar" . "Char -> ShowS") 1083 ("toLower" . "Char -> Char") 1084 ("toUpper" . "Char -> Char") 1085 ;; Monad 1086 ("ap" . "Monad m => m (a -> b) -> m a -> m b") 1087 ("filterM" . "Monad m => (a -> m Bool) -> [a] -> m [a]") 1088 ("foldM" . "Monad m => (a -> b -> m a) -> a -> [b] -> m a") 1089 ("guard" . "MonadPlus m => Bool -> m ()") 1090 ("join" . "Monad m => m (m a) -> m a") 1091 ("liftM" . "Monad m => (a -> b) -> (m a -> m b)") 1092 ("liftM2" . "Monad m => (a -> b -> c) -> (m a -> m b -> m c)") 1093 ("liftM3" . "Monad m => (a -> b -> c -> d) -> (m a -> m b -> m c -> m d)") 1094 ("liftM4" . "Monad m => (a -> b -> c -> d -> e) -> (m a -> m b -> m c -> m d -> m e)") 1095 ("liftM5" . "Monad m => (a -> b -> c -> d -> e -> f) -> (m a -> m b -> m c -> m d -> m e -> m f)") 1096 ("mapAndUnzipM" . "Monad m => (a -> m (b,c)) -> [a] -> m ([b], [c])") 1097 ("mplus" . "MonadPlus m => m a -> m a -> m a") 1098 ("msum" . "MonadPlus m => [m a] -> m a") 1099 ("mzero" . "MonadPlus m => m a") 1100 ("unless" . "Monad m => Bool -> m () -> m ()") 1101 ("when" . "Monad m => Bool -> m () -> m ()") 1102 ("zipWithM" . "Monad m => (a -> b -> m c) -> [a] -> [b] -> m [c]") 1103 ("zipWithM_" . "Monad m => (a -> b -> m c) -> [a] -> [b] -> m ()") 1104 ;; IO 1105 ("bracket" . "IO a -> (a -> IO b) -> (a -> IO c) -> IO c") 1106 ("bracket_" . "IO a -> (a -> IO b) -> IO c -> IO c") 1107 ("hClose" . "Handle -> IO ()") 1108 ("hFileSize" . "Handle -> IO Integer") 1109 ("hFlush" . "Handle -> IO ()") 1110 ("hGetBuffering" . "Handle -> IO BufferMode") 1111 ("hGetChar" . "Handle -> IO Char") 1112 ("hGetContents" . "Handle -> IO String") 1113 ("hGetLine" . "Handle -> IO String") 1114 ("hGetPosn" . "Handle -> IO HandlePosn") 1115 ("hIsClosed" . "Handle -> IO Bool") 1116 ("hIsEOF" . "Handle -> IO Bool") 1117 ("hIsOpen" . "Handle -> IO Bool") 1118 ("hIsReadable" . "Handle -> IO Bool") 1119 ("hIsSeekable" . "Handle -> IO Bool") 1120 ("hIsWritable" . "Handle -> IO Bool") 1121 ("hLookAhead" . "Handle -> IO Char") 1122 ("hPrint" . "Show a => Handle -> a -> IO ()") 1123 ("hPutChar" . "Handle -> Char -> IO ()") 1124 ("hPutStr" . "Handle -> String -> IO ()") 1125 ("hPutStrLn" . "Handle -> String -> IO ()") 1126 ("hReady" . "Handle -> IO Bool") 1127 ("hSeek" . "Handle -> SeekMode -> Integer -> IO ()") 1128 ("hSetBuffering" . "Handle -> BufferMode -> IO ()") 1129 ("hSetPosn" . "HandlePosn -> IO ()") 1130 ("hWaitForInput" . "Handle -> Int -> IO Bool") 1131 ("ioeGetErrorString" . "IOError -> String") 1132 ("ioeGetFileName" . "IOError -> Maybe FilePath") 1133 ("ioeGetHandle" . "IOError -> Maybe Handle") 1134 ("isAlreadyExistsError" . "IOError -> Bool") 1135 ("isAlreadyInUseError" . "IOError -> Bool") 1136 ("isDoesNotExistError" . "IOError -> Bool") 1137 ("isEOF" . "IO Bool") 1138 ("isEOFError" . "IOError -> Bool") 1139 ("isFullError" . "IOError -> Bool") 1140 ("isIllegalOperation" . "IOError -> Bool") 1141 ("isPermissionError" . "IOError -> Bool") 1142 ("isUserError" . "IOError -> Bool") 1143 ("openFile" . "FilePath -> IOMode -> IO Handle") 1144 ("stderr" . "Handle") 1145 ("stdin" . "Handle") 1146 ("stdout" . "Handle") 1147 ("try" . "IO a -> IO (Either IOError a)") 1148 ;; Directory 1149 ("createDirectory" . "FilePath -> IO ()") 1150 ("doesDirectoryExist" . "FilePath -> IO Bool") 1151 ("doesFileExist" . "FilePath -> IO Bool") 1152 ("executable" . "Permissions -> Bool") 1153 ("getCurrentDirectory" . "IO FilePath") 1154 ("getDirectoryContents" . "FilePath -> IO [FilePath]") 1155 ("getModificationTime" . "FilePath -> IO ClockTime") 1156 ("getPermissions" . "FilePath -> IO Permissions") 1157 ("readable" . "Permissions -> Bool") 1158 ("removeDirectory" . "FilePath -> IO ()") 1159 ("removeFile" . "FilePath -> IO ()") 1160 ("renameDirectory" . "FilePath -> FilePath -> IO ()") 1161 ("renameFile" . "FilePath -> FilePath -> IO ()") 1162 ("searchable" . "Permissions -> Bool") 1163 ("setCurrentDirectory" . "FilePath -> IO ()") 1164 ("setPermissions" . "FilePath -> Permissions -> IO ()") 1165 ("writable" . "Permissions -> Bool") 1166 ;; System 1167 ("exitFailure" . "IO a") 1168 ("exitWith" . "ExitCode -> IO a") 1169 ("getArgs" . "IO [String]") 1170 ("getEnv" . "String -> IO String") 1171 ("getProgName" . "IO String") 1172 ("system" . "String -> IO ExitCode") 1173 ;; Time 1174 ("addToClockTime" . "TimeDiff -> ClockTime -> ClockTime") 1175 ("calendarTimeToString" . "CalendarTime -> String") 1176 ("ctDay" . "Cal…
Large files files are truncated, but you can click here to view the full file