From ajb@spamcop.net Thu Aug 1 01:29:16 2002 From: ajb@spamcop.net (Andrew J Bromage) Date: Thu, 1 Aug 2002 10:29:16 +1000 Subject: can a lazy language give fast code? In-Reply-To: References: <20020731010019.GA24539@smtp.alicorna.com> Message-ID: <20020801002916.GA2452@smtp.alicorna.com> G'day all. On Wed, Jul 31, 2002 at 09:59:31AM +0100, D. Tweed wrote: > It's in saying this is warranted by `almost all' > processes being bound by things other than throughput which may be true in > the average sense, but I don't think that all programmers have almost all > their programming tasks being dominated by something other than raw > throughput but rather there are sets of programmers who have all of the > tasks being dominated by the need something else (robustness, say) and > some who have all their tasks being dominated by the need for raw > throughput. Fair enough. I was speaking in generalities and average cases and deliberately avoiding the special needs of many programmers and applications. I've worked in enterprise applications, web applications and high-performance servers (both CPU-bound and I/O-bound) and the concerns of all of them are different. Perhaps if I cut down on the superlatives I can say something that everyone agrees with: An awful lot of new code today is written in languages like Visual Basic and Java, despite their relative unsuitability for high "throughput". If it doesn't stop the use of those kinds of languages, it shouldn't stop the use of Haskell either, especially since Haskell arguably scales much better. Therefore were I someone with a stake in the future of Haskell, I would not be not overly concerned about these kinds of benchmarks. Speed is important, and it should be worked on, but it's not as important as the things which Haskell already does better. > You make very good points in what I've snipped below, again it's just > the use of `most' in a way that implies (to me) taking an average as > the representative of what everyone has to deal with that I `disagree > with'. Sure. I wasn't implying that it was representative of what everyone has to deal with. It's certainly not representative of what I do for a living, though it's pretty close to something I used to do. Perhaps the quibble is over the word "average". While I don't think I used that word, if I did, I'd mean "mode" rather than "mean". :-) Cheers, Andrew Bromage From jscott@planetinternet.be Sun Aug 4 00:41:26 2002 From: jscott@planetinternet.be (Scott J.) Date: Sun, 4 Aug 2002 01:41:26 +0200 Subject: extenssions of Haskell Message-ID: <001001c23b47$4bc7b050$2097fea9@janxp> This is a multi-part message in MIME format. ------=_NextPart_000_000D_01C23B58.0C177560 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi, I have allrewdy read a lot of Haskell 98. What I cannot find are papers = about the State transformermonad in its present form and papers about = rank m polymorphism. Thx Scott P.S. Where can I find the windows library for HOpenGL and Haskell+GYK2? = bindins. Are rpms for redhat also installable for MandrakeLinux .? ------=_NextPart_000_000D_01C23B58.0C177560 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hi,
 
I have allrewdy read a lot of Haskell = 98. What I=20 cannot find are papers about the State transformermonad in its present = form and=20 papers about rank m polymorphism.
 
Thx
 
Scott
 
P.S. Where can I find the windows = library for=20 HOpenGL and Haskell+GYK2? bindins. Are rpms for redhat also installable = for=20 MandrakeLinux .?
------=_NextPart_000_000D_01C23B58.0C177560-- From jscott@planetinternet.be Sun Aug 4 00:52:37 2002 From: jscott@planetinternet.be (Scott J.) Date: Sun, 4 Aug 2002 01:52:37 +0200 Subject: Fw: extenssions of Haskell Message-ID: <003d01c23b48$d8a68130$2097fea9@janxp> This is a multi-part message in MIME format. ------=_NextPart_000_003A_01C23B59.9C13D9F0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi, I have allready read a lot of Haskell 98. What I cannot find are papers = about the State transformer monad in its present form and papers about = rank m polymorphism. Thx Scott P.S. Where can I find the windows library for HOpenGL and Haskell+GTK2? = bindins. Are rpms for redhat also installable for MandrakeLinux .? Are there Haskell IDE's ? Sorry for thr typo's ----- Original Message -----=20 From: Scott J.=20 To: haskell-cafe@haskell.org=20 Sent: Sunday, August 04, 2002 1:41 AM Subject: extenssions of Haskell Hi, I have allrewdy read a lot of Haskell 98. What I cannot find are papers = about the State transformermonad in its present form and papers about = rank m polymorphism. Thx Scott P.S. Where can I find the windows library for HOpenGL and Haskell+GYK2? = bindins. Are rpms for redhat also installable for MandrakeLinux .? ------=_NextPart_000_003A_01C23B59.9C13D9F0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hi,
 
I have allready read a lot of Haskell = 98. What I=20 cannot find are papers about the State transformer monad in its present = form and=20 papers about rank m polymorphism.
 
Thx
 
Scott
 
P.S. Where can I find the = windows=20 library for HOpenGL and Haskell+GTK2? bindins. Are rpms for redhat also=20 installable for MandrakeLinux .?
 
Are there Haskell IDE's ?
 
Sorry for thr typo's
 
 
 
----- Original Message -----=20
From: Scott=20 J.
To: haskell-cafe@haskell.org =
Sent: Sunday, August 04, 2002 1:41 AM
Subject: extenssions of Haskell

Hi,
 
I have allrewdy read a lot of Haskell = 98. What I=20 cannot find are papers about the State transformermonad in its present = form and=20 papers about rank m polymorphism.
 
Thx
 
Scott
 
P.S. Where can I find the windows = library for=20 HOpenGL and Haskell+GYK2? bindins. Are rpms for redhat also installable = for=20 MandrakeLinux .?
------=_NextPart_000_003A_01C23B59.9C13D9F0-- From reply@demo.com Sun Aug 4 12:58:02 2002 From: reply@demo.com (mimi) Date: Sun Aug 4 12:58:03 2002 Subject: freeTR.com Artist olmak icin evden kacan Turk kizlarinin Beyoglunda cekilmis Acik sacik Cinsel birlesme iceren Videolari Date: Sun, 04 Aug 2002 19:57:21 +0300 Message-ID: <20020804165718.BAA91421F45@www.haskell.org> This is a multi-part message in MIME format --95d911bc-b768-4c99-9b37-fa860987aee1 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable http://www.freeTR.com Artist olmak icin evden kacan Turk kizlarinin = Beyoglunda cekilmis Acik sacik Cinsel birlesme iceren Videolari icin: http://www.freeTR.com --95d911bc-b768-4c99-9b37-fa860987aee1-- From jadrian@mat.uc.pt Sat Aug 3 23:28:23 2002 From: jadrian@mat.uc.pt (Jorge Adriano) Date: Sat, 3 Aug 2002 23:28:23 +0100 Subject: [Xemacs] x-symbol mode for Haskell Message-ID: <200208032328.23276.jadrian@mat.uc.pt> --------------Boundary-00=_B3HAL8NDZMRFLJ7FPKJS Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi,=20 I've always liked the X-Symbol package for Xemacs=20 http://x-symbol.sourceforge.net/ =20 I've searched for Haskell X-Symbol modes, but there doesn't seem to be on= e.=20 It's kind of strange because it seems to me like most people who are into= =20 haskell would like to use non-ascii symbols like greek letters and some n= ice=20 looking operators - just take a look at some haskell books, LaTeX modes = for=20 haskell etc. I tried to hack an x-symbol haskell mode. *I know nothing about elisp* or= =20 x-symbol internals so the mode is bloated with useless stuff and *does no= t=20 works* properly (yet?). It is in fact just a very dirty non working hack.= =2E.=20 right now I just can't spend much time with it. I thought I'd ask if anyone (preferably with more experience :) is doing,= or=20 thinking about doing some good haskell x-symbol mode. J.A. P.S.: Just in case you want to take a look at it here to understand what it is=20 supposedd to do, it goes in attchment. After installing it try typing something like f :: Num _alpha =3D> [_alpha] -> [_alpha] f x =3D x+x The _alphas will turn into real alphas as you type them, the =3D> and -> = will=20 also turn into good looking non-ascii arrows. :) The main problem is that the source file is not beeing saved correctly (d= ecode=20 token works, but not encode token), so you're not going to be able to com= pile=20 it. Of course there are many other problems like <=3D turning into an arr= ow=20 instead of a "less than equal", etc etc etc :) How to install it: X-Symbol: - download the latest x-symbol version. - run xemacs as root=20 - M-x package-admin-add-binary-package (it will tell you the directory where it is installed) The quick-dirty-non-usable-x-symbol-haskell-mode :) - save the "x-symbol-haskell.el" and "x-symbol-hooks.el" files - compile them (open in xemacs, right click buffer, byte-compile this fil= e) - copy (as root) the .el and .elc files to the directory where your other= =20 x-symbol .el and .elc files are. You may want to back up your old=20 "x-symbol-hooks.el" file.=20 To "use" it just "M-x x-symbol-mode" in an haskell buffer and type away. --------------Boundary-00=_B3HAL8NDZMRFLJ7FPKJS Content-Type: text/plain; charset="iso-8859-1"; name="x-symbol-haskell.el" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="x-symbol-haskell.el" ;;; x-symbol-sgml.el --- token language "SGML entity" for package x-symbol ;; Copyright (C) 1996-1999, 2002 Free Software Foundation, Inc. ;; ;; Author: Christoph Wedler ;; Maintainer: (Please use `M-x x-symbol-package-bug' to contact the maintainer) ;; Version: 4.4 ;; Keywords: WYSIWYG, HTML, wp, math, internationalization ;; X-URL: http://x-symbol.sourceforge.net/ ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation; either version 2, or (at your option) ;; any later version. ;; ;; This program is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License ;; along with this program; if not, write to the Free Software ;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ;;; Commentary: ;; If you want to use package x-symbol, please visit the URL (use ;; \\[x-symbol-package-web]) and read the info (use \\[x-symbol-package-info]). ;; Token language haskell is registered in x-symbol-hooks. ;;; Code: (provide 'x-symbol-haskell) (require 'x-symbol-vars) ;;;=========================================================================== ;;; Miscellaneous variables ;;;=========================================================================== (defface x-symbol-haskell-non-l1-face '((((class color) (background light)) (:foreground "orange4"))) "*Face, normally used for tokens only allowed in TeX's math mode. Used in `x-symbol-tex-class-face-alist'." :group 'x-symbol-haskell :group 'x-symbol-info-general) (defcustom x-symbol-haskell-modeline-name "haskell" "*String naming the language HASKELL in the modeline." :group 'x-symbol-haskell :type 'string) (defcustom x-symbol-haskell-header-groups-alist '(("Operator" bigop operator) ("Relation" relation) ("Arrow, Punctuation" arrow triangle shape white line dots punctuation quote parenthesis) ("Symbol" symbol currency mathletter setsymbol) ("Greek Letter" greek greek1) ("Misc. Letter" letter slash) ("Cedilla, Ogonek" cedilla ogonek) ("Dotaccent, Ring" dotaccent ring) ("Tilde, Breve" tilde breve) ("Circumflex, Caron" circumflex caron) ("Diaeresis, Umlaut" diaeresis hungarumlaut) ("Acute, Grave" acute grave)) "*If non-nil, used in HASKELL specific grid/menu. See `x-symbol-header-groups-alist'." :group 'x-symbol-haskell :group 'x-symbol-input-init :type 'x-symbol-headers) (defcustom x-symbol-haskell-class-alist '((non-l1) (VALID "HASKELL entity" (x-symbol-info-face)) (INVALID "no HASKELL entity" (x-symbol-emph-info-face))) "Alist for HASKELL's token classes displayed by info in echo area. See `x-symbol-language-access-alist' for details." :group 'x-symbol-haskell :group 'x-symbol-info-strings :set 'x-symbol-set-cache-variable :type 'x-symbol-class-info) (defcustom x-symbol-haskell-class-face-alist '((non-l1 x-symbol-haskell-non-l1-face (x-symbol-haskell-non-l1-face))) "Alist for HASKELL's color scheme in HASKELL's grid and info. See `x-symbol-language-access-alist' for details." :group 'x-symbol-haskell :group 'x-symbol-input-init :group 'x-symbol-info-general :set 'x-symbol-set-cache-variable :type 'x-symbol-class-faces) (defcustom x-symbol-haskell-electric-ignore nil "*Additional HASKELL version of `x-symbol-electric-ignore'." :group 'x-symbol-haskell :group 'x-symbol-input-control :type 'x-symbol-function-or-regexp) (defvar x-symbol-haskell-required-fonts nil "List of features providing fonts for language `haskell'.") (defvar x-symbol-haskell-extra-menu-items nil "Extra menu entries for language `haskell'.") (defvar x-symbol-haskell-token-list 'x-symbol-haskell-token-list-netscape "Function returning a list of HASKELL entities from table specification. The TOKEN-SPEC in haskell table look like (NUMBER STRING...) where NUMBER is the Unicode value. See `x-symbol-init-language', `x-symbol-haskell-token-list-name', `x-symbol-haskell-token-list-code' and `x-symbol-haskell-token-list-netscape'.") (defvar x-symbol-haskell-token-grammar (x-symbol-make-grammar :decode-regexp "_[#0-9A-Za-z]+" :token-list #'x-symbol-haskell-default-token-list) "Token grammar for language `haskell'.") (defvar x-symbol-haskell-input-token-grammar '("_[#0-9A-Za-z]+\\'") "Grammar of input method Token for language `haskell'.") (defvar x-symbol-haskell-user-table nil "User table defining HASKELL entities, used in `x-symbol-haskell-table'.") (defvar x-symbol-haskell-generated-data nil "Internal.") ;;;=========================================================================== ;;; Image support ;;;=========================================================================== (defcustom x-symbol-haskell-master-directory 'ignore "Function returning the directory of the master file or nil. See `x-symbol-image-parse-buffer'." :group 'x-symbol-haskell :group 'x-symbol-image-language :type 'function) (defcustom x-symbol-haskell-image-searchpath '("./") "Search path used for implicitly relative image file names. See `x-symbol-image-use-remote'." :group 'x-symbol-haskell :group 'x-symbol-image-language :type '(repeat directory)) (defcustom x-symbol-haskell-image-cached-dirs '("images/" "pictures/") "Directory parts of image file names stored in the memory cache. See `x-symbol-image-use-remote'." :group 'x-symbol-haskell :group 'x-symbol-image-language :type '(repeat string)) (defcustom x-symbol-haskell-image-file-truename-alist '(("\\`file:" . "") ("\\`[A-Za-z]+:")) "Alist used to determine the file name of an image URL. Each element looks like (REGEXP) or (REGEXP . NEWTEXT) or (REGEXP FUNCTION ARG...) If the the image file name is matched by REGEXP, the corresponding element is processed, if no REGEXP matches, the image file name is used as it is. With the first form, the image command will not be highlighted. With the second form, replace text matched by REGEXP with NEWTEXT, see `replace-match' for details. With the third form, FUNCTION, call FUNCTION with the image file name and the remaining arguments ARGs to get the true file name. E.g., I add the following element to this variable: (\"\\\\`http://www\\\\.fmi\\\\.uni-passau\\\\.de/~wedler/\" \. \"~/public_html/\")" :group 'x-symbol-haskell :group 'x-symbol-image-language :type '(repeat (cons :format "%v" :value ("" . "") ; doesn't work (custom bug?) regexp (choice ;;:value "" (const :tag "Not highlighted" nil) (string :tag "Replace match with") (cons :tag "Call" function (repeat :tag "With arguments" sexp)))))) (defcustom x-symbol-haskell-image-keywords '("\\.\\(gif\\|png\\|jpe?g\\)\\'" ("]*src=\"\\([^\n\"]+\\)\"[^\n>]*>" x-symbol-haskell-image-file-truename 1)) "Keywords used to find image insertion commands. See `x-symbol-image-parse-buffer'." :group 'x-symbol-haskell :group 'x-symbol-image-language :type 'x-symbol-image-keywords) (defun x-symbol-haskell-image-file-truename (num) "Return true image file name for last match. Return text matched by the NUMth regexp group of the corresponding keyword regexp, after being processed according to `x-symbol-haskell-image-file-truename-alist'." (x-symbol-match-in-alist (setq num (match-string num)) x-symbol-haskell-image-file-truename-alist num t)) ;;;=========================================================================== ;;; Super- and Subscripts ;;;=========================================================================== (defvar x-symbol-haskell-font-lock-keywords '((x-symbol-haskell-match-subscript (1 x-symbol-invisible-face t) (2 (if (eq (char-after (+ 3 (match-beginning 1))) ?b) 'x-symbol-sub-face 'x-symbol-sup-face) prepend) (3 x-symbol-invisible-face t))) "HASKELL's font-lock keywords for super- and subscripts.") (defcustom x-symbol-haskell-font-lock-regexp "" "Regexp matching the start tag of HASKELL's super- and subscripts. See also `x-symbol-haskell-font-lock-alist'." :group 'x-symbol-haskell :type 'regexp) (defcustom x-symbol-haskell-font-lock-limit-regexp "\n\\|" "Regexp matching the end tag of HASKELL's super- and subscripts. This regexp should match the end of line and the closing tags in `x-symbol-haskell-font-lock-alist'." :group 'x-symbol-haskell :type 'regexp) (defcustom x-symbol-haskell-font-lock-contents-regexp "[^ \t\n\240]" "*Regexp matching the super- and subscript contents. This regexp should match the text between the opening and closing super- or subscript tag." :group 'x-symbol-haskell :type 'regexp) (defcustom x-symbol-haskell-font-lock-alist '(("" . "") ("" . "")) "Alist for correct tag pairs for HASKELL's super- and subscripts. Each element looks like (OPEN . CLOSE). All keys OPEN in this alist should be matched by `x-symbol-haskell-font-lock-regexp', all CLOSEs should be matched by `x-symbol-haskell-font-lock-limit-regexp'." :group 'x-symbol-haskell :type '(repeat (cons :format "%v" (string :tag "Open tag") (string :tag "Close tag")))) ;;;=========================================================================== ;;; The tables ;;;=========================================================================== (defun x-symbol-haskell-default-token-list (tokens) (mapcar #'list (if (car tokens) (if (or (eq x-symbol-haskell-token-list 'x-symbol-haskell-token-list-name) (and (eq x-symbol-haskell-token-list 'x-symbol-haskell-token-list-netscape) (< (car tokens) 256))) (append (cdr tokens) (list (format "_#%d" (car tokens)))) (cons (format "_#%d" (car tokens)) (cdr tokens)))))) ;; http://www.w3.org/TR/REC-html40/haskell/entities.html ;; (query-replace-regexp "[ \t]*.*$" " (\\1 () \\2 \"_\\1;\") ; \\3") (defvar x-symbol-haskell-latin1-table '((nobreakspace () 160 "_nbsp") (exclamdown () 161 "_iexcl") (cent () 162 "_cent") (sterling () 163 "_pound") (currency () 164 "_curren") (yen () 165 "_yen") (brokenbar () 166 "_brvbar" "_brkbar") (section () 167 "_sect") (diaeresis () 168 "_uml" "_die") (copyright () 169 "_copy") (ordfeminine () 170 "_ordf") (guillemotleft () 171 "_laquo") (notsign () 172 "_not") (hyphen () 173 "_shy") (registered () 174 "_reg") (macron () 175 "_macr" "_hibar") (degree () 176 "_deg") (plusminus () 177 "_plusmn") (twosuperior () 178 "_sup2") (threesuperior () 179 "_sup3") (acute () 180 "_acute") (mu1 () 181 "_micro") (paragraph () 182 "_para") (periodcentered () 183 "_middot") (cedilla () 184 "_cedil") (onesuperior () 185 "_sup1") (masculine () 186 "_ordm") (guillemotright () 187 "_raquo") (onequarter () 188 "_frac14") (onehalf () 189 "_frac12") (threequarters () 190 "_frac34") (questiondown () 191 "_iquest") (Agrave () 192 "_Agrave") (Aacute () 193 "_Aacute") (Acircumflex () 194 "_Acirc") (Atilde () 195 "_Atilde") (Adiaeresis () 196 "_Auml") (Aring () 197 "_Aring") (AE () 198 "_AElig") (Ccedilla () 199 "_Ccedil") (Egrave () 200 "_Egrave") (Eacute () 201 "_Eacute") (Ecircumflex () 202 "_Ecirc") (Ediaeresis () 203 "_Euml") (Igrave () 204 "_Igrave") (Iacute () 205 "_Iacute") (Icircumflex () 206 "_Icirc") (Idiaeresis () 207 "_Iuml") (ETH () 208 "_ETH") ; "_Dstrok" for Dbar (U0110) = latin2#208? (Ntilde () 209 "_Ntilde") (Ograve () 210 "_Ograve") (Oacute () 211 "_Oacute") (Ocircumflex () 212 "_Ocirc") (Otilde () 213 "_Otilde") (Odiaeresis () 214 "_Ouml") (multiply () 215 "_times") (Ooblique () 216 "_Oslash") (Ugrave () 217 "_Ugrave") (Uacute () 218 "_Uacute") (Ucircumflex () 219 "_Ucirc") (Udiaeresis () 220 "_Uuml") (Yacute () 221 "_Yacute") (THORN () 222 "_THORN") (ssharp () 223 "_szlig") (agrave () 224 "_agrave") (aacute () 225 "_aacute") (acircumflex () 226 "_acirc") (atilde () 227 "_atilde") (adiaeresis () 228 "_auml") (aring () 229 "_aring") (ae () 230 "_aelig") (ccedilla () 231 "_ccedil") (egrave () 232 "_egrave") (eacute () 233 "_eacute") (ecircumflex () 234 "_ecirc") (ediaeresis () 235 "_euml") (igrave () 236 "_igrave") (iacute () 237 "_iacute") (icircumflex () 238 "_icirc") (idiaeresis () 239 "_iuml") (eth () 240 "_eth") (ntilde () 241 "_ntilde") (ograve () 242 "_ograve") (oacute () 243 "_oacute") (ocircumflex () 244 "_ocirc") (otilde () 245 "_otilde") (odiaeresis () 246 "_ouml") (division () 247 "_divide") (oslash () 248 "_oslash") (ugrave () 249 "_ugrave") (uacute () 250 "_uacute") (ucircumflex () 251 "_ucirc") (udiaeresis () 252 "_uuml") (yacute () 253 "_yacute") (thorn () 254 "_thorn") (ydiaeresis () 255 "_yuml")) "Table defining HASKELL entities, see `x-symbol-haskell-table'.") (defvar x-symbol-haskell-latinN-table '((Aogonek (non-l1) 260) (breve (non-l1) 728) (Lslash (non-l1) 321) (Lcaron (non-l1) 317) (Sacute (non-l1) 346) (Scaron (non-l1) 352 "_Scaron") (Scedilla (non-l1) 350) (Tcaron (non-l1) 356) (Zacute (non-l1) 377) (Zcaron (non-l1) 381) (Zdotaccent (non-l1) 379) (aogonek (non-l1) 261) (ogonek (non-l1) 731) (lslash (non-l1) 322) (lcaron (non-l1) 318) (sacute (non-l1) 347) (caron (non-l1) 711) (scaron (non-l1) 353 "_scaron") (scedilla (non-l1) 351) (tcaron (non-l1) 357) (zacute (non-l1) 378) (hungarumlaut (non-l1) 733) (zcaron (non-l1) 382) (zdotaccent (non-l1) 380) (Racute (non-l1) 340) (Abreve (non-l1) 258) (Lacute (non-l1) 313) (Cacute (non-l1) 262) (Ccaron (non-l1) 268) (Eogonek (non-l1) 280) (Ecaron (non-l1) 282) (Dcaron (non-l1) 270) (Dbar (non-l1) 272) (Nacute (non-l1) 323) (Ncaron (non-l1) 327) (Ohungarumlaut (non-l1) 336) (Rcaron (non-l1) 344) (Uring (non-l1) 366) (Uhungarumlaut (non-l1) 368) (Tcedilla (non-l1) 354) (racute (non-l1) 341) (abreve (non-l1) 259) (lacute (non-l1) 314) (cacute (non-l1) 263) (ccaron (non-l1) 269) (eogonek (non-l1) 281) (ecaron (non-l1) 283) (dcaron (non-l1) 271) (dbar (non-l1) 273) (nacute (non-l1) 324) (ncaron (non-l1) 328) (ohungarumlaut (non-l1) 337) (rcaron (non-l1) 345) (uring (non-l1) 367) (uhungarumlaut (non-l1) 369) (tcedilla (non-l1) 355) (dotaccent (non-l1) 729) (Hbar (non-l1) 294) (Hcircumflex (non-l1) 292) (Idotaccent (non-l1) 304) (Gbreve (non-l1) 286) (Jcircumflex (non-l1) 308) (hbar (non-l1) 295) (hcircumflex (non-l1) 293) (dotlessi (non-l1) 305) (gbreve (non-l1) 287) (jcircumflex (non-l1) 309) (Cdotaccent (non-l1) 266) (Ccircumflex (non-l1) 264) (Gdotaccent (non-l1) 288) (Gcircumflex (non-l1) 284) (Ubreve (non-l1) 364) (Scircumflex (non-l1) 348) (cdotaccent (non-l1) 267) (ccircumflex (non-l1) 265) (gdotaccent (non-l1) 289) (gcircumflex (non-l1) 285) (ubreve (non-l1) 365) (scircumflex (non-l1) 349) (euro (non-l1) 8364 "_euro") (OE (non-l1) 338 "_OElig") (oe (non-l1) 339 "_oelig") (Ydiaeresis (non-l1) 376 "_Yuml")) "Table defining HASKELL entities, see `x-symbol-haskell-table'.") (defvar x-symbol-haskell-xsymb0-table '((Delta (non-l1) 916 "_Delta") (Phi (non-l1) 934 "_Phi") (Gamma (non-l1) 915 "_Gamma") (theta1 (non-l1) 977 "_thetasym") (Lambda (non-l1) 923 "_Lambda") (Pi (non-l1) 928 "_Pi") (Theta (non-l1) 920 "_Theta") (Sigma (non-l1) 931 "_Sigma") (sigma1 (non-l1) 962 "_sigmaf") (Omega (non-l1) 937 "_Omega") (Xi (non-l1) 926 "_Xi") (Psi (non-l1) 936 "_Psi") (alpha (non-l1) 945 "_alpha") (beta (non-l1) 946 "_beta") (chi (non-l1) 967 "_chi") (delta (non-l1) 948 "_delta") (epsilon (non-l1) 949 "_epsilon") (phi (non-l1) 966 "_phi") (gamma (non-l1) 947 "_gamma") (eta (non-l1) 951 "_eta") (iota (non-l1) 953 "_iota") (kappa (non-l1) 954 "_kappa") (lambda (non-l1) 955 "_lambda") (mu (non-l1) 956 "_mu") (nu (non-l1) 957 "_nu") (pi (non-l1) 960 "_pi") (theta (non-l1) 952 "_theta") (rho (non-l1) 961 "_rho") (sigma (non-l1) 963 "_sigma") (tau (non-l1) 964 "_tau") (upsilon (non-l1) 965 "_upsilon") (omega1 (non-l1) 982 "_piv") (omega (non-l1) 969 "_omega") (xi (non-l1) 958 "_xi") (psi (non-l1) 968 "_psi") (zeta (non-l1) 950 "_zeta") (Upsilon1 (non-l1) 978 "_upsih") (florin (non-l1) 402 "_fnof") (bullet (non-l1) 8226 "_bull") (ellipsis (non-l1) 8230 "_hellip") (minute (non-l1) 8242 "_prime") (second (non-l1) 8243 "_Prime") (radicalex (non-l1) 8254 "_oline") (fraction (non-l1) 8260 "_frasl") (weierstrass (non-l1) 8472 "_weierp") (Ifraktur (non-l1) 8465 "_image") (Rfraktur (non-l1) 8476 "_real") (trademark (non-l1) 8482 "_trade") (aleph (non-l1) 8501 "_alefsym") (arrowleft (non-l1) 8592 "_larr") (arrowup (non-l1) 8593 "_uarr") (arrowright (non-l1) 8594 "_rarr") (arrowdown (non-l1) 8595 "_darr") (arrowboth (non-l1) 8596 "_harr") (carriagereturn (non-l1) 8629 "_crarr") (arrowdblleft (non-l1) 8656 "_lArr") (arrowdblup (non-l1) 8657 "_uArr") (arrowdblright (non-l1) 8658 "_rArr") (arrowdbldown (non-l1) 8659 "_dArr") (arrowdblboth (non-l1) 8660 "_hArr") (partialdiff (non-l1) 8706 "_part") (emptyset (non-l1) 8709 "_empty") (gradient (non-l1) 8711 "_nabla") (element (non-l1) 8712 "_isin") (notelement (non-l1) 8713 "_notin") (suchthat (non-l1) 8715 "_ni") (product (non-l1) 8719 "_prod") (summation (non-l1) 8721 "_sum") (minus1 (non-l1) 8722 "_minus") (asterisk1 (non-l1) 8727 "_lowast") (radical (non-l1) 8730 "_radic") (proportional (non-l1) 8733 "_prop") (infinity (non-l1) 8734 "_infin") (angle (non-l1) 8736 "_ang") (logicaland (non-l1) 8743 "_and") (logicalor (non-l1) 8744 "_or") (intersection (non-l1) 8745 "_cap") (union (non-l1) 8746 "_cup") (integral (non-l1) 8747 "_int") (similar (non-l1) 8764 "_sim") (congruent (non-l1) 8773 "_cong") (notequal (non-l1) 8800 "_ne") (equivalence (non-l1) 8801 "_equiv") (lessequal (non-l1) 8804 "_le") (greaterequal (non-l1) 8805 "_ge") (propersubset (non-l1) 8834 "_sub") (propersuperset (non-l1) 8835 "_sup") (notsubset (non-l1) 8836 "_nsub") (reflexsubset (non-l1) 8838 "_sube") (reflexsuperset (non-l1) 8839 "_supe") (circleplus (non-l1) 8853 "_oplus") (circlemultiply (non-l1) 8855 "_otimes") (perpendicular (non-l1) 8869 "_perp") (periodcentered1 (non-l1) 8901 "_sdot") (angleleft (non-l1) 9001 "_lang") (angleright (non-l1) 9002 "_rang") (lozenge (non-l1) 9674 "_loz") (spade (non-l1) 9824 "_spades") (club (non-l1) 9827 "_clubs") (heart (non-l1) 9829 "_hearts") (diamond (non-l1) 9830 "_diams")) "Table defining HASKELL entities, see `x-symbol-haskell-table'.") (defvar x-symbol-haskell-xsymb1-table '((ampersand2 () 38 "_amp") (quotedbl1 () 34 "_quot") (less2 () 60 "_lt") (greater2 () 62 "_gt") (universal1 (non-l1) 8704 "_forall") (existential1 (non-l1) 8707 "_exist") (circumflex (non-l1) 710 "_circ") (tilde (non-l1) 732 "_tilde") ;;(ensp (non-l1) 8194 "_ensp") ; en space, U+2002 ISOpub ;;(emsp (non-l1) 8195 "_emsp") ; em space, U+2003 ISOpub ;;(thinsp (non-l1) 8201 "_thinsp") ; thin space, U+2009 ISOpub ;;(zwnj (non-l1) 8204 "_zwnj") ; zero width non-joiner, U+200C NEW RFC 2070 ;;(zwj (non-l1) 8205 "_zwj") ; zero width joiner, U+200D NEW RFC 2070 ;;(lrm (non-l1) 8206 "_lrm") ; left-to-right mark, U+200E NEW RFC 2070 ;;(rlm (non-l1) 8207 "_rlm") ; right-to-left mark, U+200F NEW RFC 2070 (endash (non-l1) 8211 "_ndash") (emdash (non-l1) 8212 "_mdash") ;;(lsquo (non-l1) 8216 "_lsquo") ; left single quotation mark, U+2018 ISOnum ;;(rsquo (non-l1) 8217 "_rsquo") ; right single quotation mark, U+2019 ISOnum ;;(sbquo (non-l1) 8218 "_sbquo") ; single low-9 quotation mark, U+201A NEW ;;(ldquo (non-l1) 8220 "_ldquo") ; left double quotation mark, U+201C ISOnum ;;(rdquo (non-l1) 8221 "_rdquo") ; right double quotation mark, U+201D ISOnum ;;(bdquo (non-l1) 8222 "_bdquo") ; double low-9 quotation mark, U+201E NEW (dagger (non-l1) 8224 "_dagger") (daggerdbl (non-l1) 8225 "_Dagger") (perthousand (non-l1) 8240 "_permil") (guilsinglleft (non-l1) 8249 "_lsaquo") (guilsinglright (non-l1) 8250 "_rsaquo") (therefore1 (non-l1) 8756 "_there4") (ceilingleft (non-l1) 8968 "_lceil") (ceilingright (non-l1) 8969 "_rceil") (floorleft (non-l1) 8970 "_lfloor") (floorright (non-l1) 8971 "_rfloor") (asym (non-l1) 8776 "_asymp") ) "Table defining HASKELL entities, see `x-symbol-haskell-table'.") ;; Should I add symbols from http://www.bbsinc.com/iso8859.html ? (defvar x-symbol-haskell-table (append x-symbol-haskell-user-table '(nil) x-symbol-haskell-latin1-table x-symbol-haskell-latinN-table x-symbol-haskell-xsymb0-table x-symbol-haskell-xsymb1-table) "Complete table defining HASKELL entities. Use `x-symbol-haskell-user-table' to define/shadow private entities. See `x-symbol-init-language' and `x-symbol-haskell-token-list'.") ;;;=========================================================================== ;;; Subscript functions ;;;=========================================================================== (defun x-symbol-haskell-match-subscript (limit) ;; checkdoc-params: (limit) "Match and skip over super- and subscripts. Return nil if `x-symbol-mode' or `x-symbol-subscripts' is nil. Uses `x-symbol-haskell-font-lock-regexp'." (and x-symbol-mode x-symbol-subscripts (let (open-beg open-end close-end close-beg) (while (and (setq open-end (re-search-forward x-symbol-haskell-font-lock-regexp limit t)) (setq open-beg (match-beginning 0)) (not (and (setq close-end (re-search-forward x-symbol-haskell-font-lock-limit-regexp limit 'limit)) (setq close-beg (match-beginning 0)) (equal (cdr (assoc (downcase (buffer-substring open-beg open-end)) x-symbol-haskell-font-lock-alist)) (downcase (buffer-substring close-beg close-end))) (save-excursion (goto-char open-end) (re-search-forward x-symbol-haskell-font-lock-contents-regexp close-beg t)))))) (when open-end (store-match-data (list open-beg close-end open-beg open-end open-end close-beg close-beg close-end)) t)))) ;;; Local IspellPersDict: .ispell_xsymb ;;; x-symbol-haskell.el ends here --------------Boundary-00=_B3HAL8NDZMRFLJ7FPKJS Content-Type: text/plain; charset="iso-8859-1"; name="x-symbol-hooks.el" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x-symbol-hooks.el" ;;; x-symbol-hooks.el --- pre-loaded stuff for package x-symbol ;; Copyright (C) 1996-1999, 2001-2002 Free Software Foundation, Inc. ;; ;; Author: Christoph Wedler ;; Maintainer: (Please use `M-x x-symbol-package-bug' to contact the main= tainer) ;; Version: 4.4.X ;; Keywords: WYSIWYG, LaTeX, HTML, wp, math, internationalization ;; X-URL: http://x-symbol.sourceforge.net/ ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation; either version 2, or (at your option) ;; any later version. ;; ;; This program is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License ;; along with this program; if not, write to the Free Software ;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ;;; Commentary: ;; If you want to use package x-symbol, please visit the URL (use ;; \\[x-symbol-package-web]) and read the info (use \\[x-symbol-package-i= nfo]). ;; This file provides `autoload's for package x-symbol, adds functions to= hooks ;; for the automatic conversion and defines variables which control the ;; conversion. ;;; Code: (provide 'x-symbol-hooks) (require 'font-lock) (eval-when-compile (require 'cl)) (eval-when-compile (defvar x-symbol-coding-name-alist)=09; in "x-symbol-vars" (defvar x-symbol-image-colormap-allocation) ; here (defvar x-symbol-image-convert-colormap) ; here (defvar x-symbol-cstring-table)=09; in x-symbol.el, only needed if load= ed ) (eval-when-compile (defvar lazy-shot-minimum-size) (defvar comint-input-sender) (defvar comint-last-input-end) (defvar comint-last-output-start) (defvar fast-lock-save-faces) (defvar latex-mode-hook) (defvar LaTeX-mode-hook) (defvar LaTeX-math-insert-function) (defvar orig-buffer) (defvar reftex-translate-to-ascii-function) ) (put 'x-symbol-define-user-options 'lisp-indent-function 2) (put 'x-symbol-dolist-delaying 'lisp-indent-function 2) (put 'x-symbol-do-plist 'lisp-indent-function 1) (put 'x-symbol-while-charsym 'lisp-indent-function 1) (put 'x-symbol-encode-for-charsym 'lisp-indent-function 1) (put 'x-symbol-decode-for-charsym 'lisp-indent-function 2) (defvar x-symbol-warn-of-old-emacs t "If non-nil, issue warning when using a old/buggy XEmacs. XEmacs-21.0 to XEmacs-21.1.8 has been reported to core when using input method token.") ;; CW: if possible, back to x-symbol.el, do not load too many files at in= it (require (if (featurep 'xemacs) 'x-symbol-xmacs 'x-symbol-emacs)) =0C ;;;;#####################################################################= ##### ;;;; Variables ;;;;#####################################################################= ##### (defvar x-symbol-data-directory (or (locate-data-directory "x-symbol") (progn (warn "X-Symbol is not installed at the proper place") =09 nil)) "Directory of data files that come with package X-Symbol.") (defvar x-symbol-font-directory (and x-symbol-data-directory (expand-file-name "pcf/" x-symbol-data-directory)) "Directory for additional X-Symbol fonts. If non-nil, used in function `x-symbol-initialize'.") ;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D ;;; Custom groups ;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D (defgroup x-symbol nil "Semi WYSIWYG for LaTeX, HTML, etc using additional fonts." :group 'wp :link '(info-link "(x-symbol)") :link '(url-link "http://x-symbol.sourceforge.net/") :prefix "x-symbol-") (defgroup x-symbol-mode nil "Controlling whether and how to turn on X-Symbol mode." :group 'x-symbol :prefix "x-symbol-") (defgroup x-symbol-input-init nil "Initialization of input methods supported by X-Symbol." :group 'x-symbol :prefix "x-symbol-") (defgroup x-symbol-input-control nil "Control if input methods supported by X-Symbol." :group 'x-symbol :prefix "x-symbol-") (defgroup x-symbol-info-general nil "General customization of X-Symbol info in echo area." :group 'x-symbol :prefix "x-symbol-") (defgroup x-symbol-info-strings nil "Customization of X-Symbol info strings in echo area." :group 'x-symbol :prefix "x-symbol-") (defgroup x-symbol-miscellaneous nil "Miscellaneous customization for X-Symbol." :group 'x-symbol :prefix "x-symbol-") (defgroup x-symbol-image-general nil "General customization of images in X-Symbol buffers." :group 'x-symbol :prefix "x-symbol-")=09=09=09; not "x-symbol-image-" ! (defgroup x-symbol-image-language nil "Language dependent customization of images in X-Symbol buffers." :group 'x-symbol :prefix "x-symbol-")=09=09=09; not "x-symbol-image-" ! (defgroup x-symbol-tex nil "X-Symbol token language \"TeX macro\"." :group 'x-symbol :prefix "x-symbol-tex-") (defgroup x-symbol-sgml nil "X-Symbol token language \"SGML entity\"." :group 'x-symbol :prefix "x-symbol-sgml-") (defgroup x-symbol-haskell nil "X-Symbol token language \"HASKELL entity\"." :group 'x-symbol :prefix "x-symbol-haskell-") (defgroup x-symbol-bib nil "X-Symbol token language \"BibTeX macro\"." :group 'x-symbol :prefix "x-symbol-bib-") (defgroup x-symbol-texi nil "X-Symbol token language \"TeXinfo command\"." :group 'x-symbol :prefix "x-symbol-texi-") ;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D ;;; Custom widgets ;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D ;; Shouldn't this be a generally useful widget type? (define-widget 'x-symbol-key 'sexp "A key or mouse stroke." :tag "Key/Mouse stroke") (define-widget 'x-symbol-modes-or-regexp 'choice "Regexp or list of major modes." :value nil :args '((const :tag "Always" t) =09 (regexp :tag "When matched by") =09 (repeat :tag "In major modes" :menu-tag "In major modes" =09=09 (function :value text-mode)))) (define-widget 'x-symbol-auto-mode 'group "Auto-mode setup." :args '((x-symbol-modes-or-regexp :tag "Turn on") =09 (sexp :tag "Language (eval'd)") =09 (option =09 (group :inline t :extra-offset -4 =09=09 (sexp :tag "Coding (eval'd)") =09=09 (option =09=09 (group :inline t :extra-offset -4 =09=09=09 (sexp :tag "Save 8bit (eval'd)") =09=09=09 (option =09=09=09 (group :inline t :extra-offset -4 =09=09=09=09 (sexp :tag "Super/subscripts (eval'd)") =09=09=09=09 (option =09=09=09=09 (group :inline t :extra-offset -4 =09=09=09=09=09 (sexp :tag "Show images (eval'd)") =09=09=09=09=09 (option =09=09=09=09=09 (sexp :tag =09=09=09=09=09=09 "Unique decoding (eval'd)" =09=09=09=09=09=09 )))))))))))) ;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D ;;; Functions to set user options ;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D (defun x-symbol-define-user-options (var options &optional after-set set-= fn) "Define options and setting behavior for user option VAR. OPTIONS has the form (FALLBACK . ALIST) where ALIST has elements of the form (OPTION . MENU-TEXT). If ALIST is non-nil, one OPTION should be equal to FALLBACK, its MENU-TEXT is used for any values not being keys in ALIST. OPTIONS can also be a function which should return the form mention above. If ALIST is nil, `x-symbol-submenu-filter', which is used by `x-symbol-menu', uses a toggle button with FALLBACK as the non-nil value and \\[set-variable] offers completion with matches nil and FALLBACK. Otherwise, the menu uses radio buttons for all OPTIONs, where MENU-TEXT is the name of the menu item, and \\[set-variable] offers completion over all OPTIONs. `x-symbol-set-variable', which is invoked by the menu callbacks, uses SET-FN instead `set' to set the value of VAR if SET-FN is non-nil. Otherwise, all functions in AFTER-SET are invoked after `set'ting VAR." (put var 'x-symbol-options options) (put var 'variable-interactive (list 'x-symbol-variable-interactive (list 'quote var))) (while after-set (pushnew (pop after-set) (get var 'x-symbol-after-set-hook) :test 'eq= ual)) (if set-fn (put var 'x-symbol-set-function set-fn))) ;; CW: autoload important if var `x-symbol-auto-mode-suffixes' is saved b= y ;; custom ;;;###autoload (defun x-symbol-auto-mode-suffixes (&optional suffixes) "Return REGEXPs of three-value elements in `auto-mode-alist'. These REGEXPs are added to SUFFIXES." (setq suffixes (reverse suffixes)) (let ((alist auto-mode-alist)) (while alist (and (consp (cdar alist)) =09 (null (member (caar alist) suffixes)) =09 (push (caar alist) suffixes)) (setq alist (cdr alist))) (nreverse suffixes))) ;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D ;;; Initialization ;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D (defcustom x-symbol-initialize t "Whether to do an extended initialization of package X-Symbol. If t, do full initialization. Otherwise, the value should be a list with element. To enable, include * `languages' to register all supported token languages, * `global' to turn on X-Symbol's global mode, i.e., as files are loaded, execute `turn-on-x-symbol-conditionally', * `keys' to set up the usual X-Symbol key bindings in `global-map', * `font-path' to add `x-symbol-font-directory' to the font-path, * `comint' to make X-Symbol work with comint, * `fast-lock' to make X-Symbol work with fast-lock, * `auctex' to make X-Symbol optimally work with AucTeX 9.8a+, it changes AucTeX's `TeX-region-hook', `TeX-translate-location-hook', and `LaTeX-math-insert-function', * `reftex' to make X-Symbol optimally work with RefTeX 3.26+, * `bib-cite' to make X-Symbol not overwriting bib-cite's highlighting. You do not have to install the packages whose initialization is enabled." :group 'x-symbol-mode :type '(choice (const :tag "All" t) =09=09 (set :value (languages global keys font-path comint =09=09=09=09=09fast-lock auctex reftex bib-cite) =09=09 (const :tag "Token languages" languages) =09=09 (const :tag "Global mode" global) =09=09 (const :tag "Key bindings" keys) =09=09 (const :tag "Font path" font-path) =09=09 (const :tag "Package comint" comint) =09=09 (const :tag "Package fast-lock" fast-lock) =09=09 (const :tag "Package AucTeX" auctex) =09=09 (const :tag "Package RefTeX" reftex) =09=09 (const :tag "Package bib-cite" bib-cite)))) (defvar x-symbol-orig-comint-input-sender 'comint-simple-send "Original function which sends a string to the comint process.") ;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D ;;; Determine Locale ;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D (defun x-symbol-coding-system-from-locale () ;; See also EMACS/lisp/international/mule-cmds.el, `set-locale-environm= ent'. "Get value for `x-symbol-default-coding' from locale. Use \"locale -ck code_set_name charmap\" and search for the value of \"code_set_name\" or \"charmap\"." (save-excursion (set-buffer (get-buffer-create " *x-symbol-coding-system-from-locale*= ")) (erase-buffer) (call-process shell-file-name nil t nil shell-command-switch =09=09 "locale -ck code_set_name charmap") (goto-char (point-min)) (let* ((case-fold-search t) =09 ;; The GNU recode manual (www-find "recode charset iso646"), lists = a =09 ;; lot of aliases, there are a bit less on =09 ;; http://mail.nl.linux.org/linux-utf8/2001-10/msg00072.html, I =09 ;; added some. But this function shouldn't exceed 40 lines... =09 (map '((iso-8859-1 =09=09 "iso-8859-1" "iso8859-1" "iso88591" ; HP: iso88591 =09=09 ;; vendor-specific, supersets of ascii =09=09 "roman8"=09=09; HP: roman8 =09=09 ;; ascii =09=09 "ascii" "us-ascii" "ansi_x3.4-1968" "646" "iso646" =09=09 "iso_646.irv") =09=09 (iso-8859-2 =09=09 "iso-8859-2" "iso8859-2" "iso88592") ; HP: iso88592 =09=09 (iso-8859-3 =09=09 "iso-8859-3" "iso8859-3" "iso88593") ; HP: iso88593 =09=09 (iso-8859-9 =09=09 "iso-8859-9" "iso8859-9" "iso88599") =09=09 (iso-8859-15 =09=09 "iso-8859-15" "iso8859-15" "iso885915"))) ; HP: iso885915 =09 (charmap (and (re-search-forward "^[ \t]*\\(code_set_name\\|charmap= \\)[ \t]*=3D[ \t]*\"\\([^\n\"]+\\)\"" nil t) =09=09=09 (find (downcase (match-string 2)) map =09=09=09 :test 'member)))) (kill-buffer (current-buffer)) (car charmap)))) (defvar x-symbol-default-coding (cond (noninteractive 'iso-8859-1) =09((x-symbol-coding-system-from-locale)) =09(t =09 (warn "X-Symbol: cannot deduce default encoding, I'll assume `iso-885= 9-1'") =09 'iso-8859-1)) "Coding used for 8bit characters in buffers. Also used for a 8bit file codings where `x-symbol-coding' has value nil. Supported values are `iso-8859-1', `iso-8859-2', `iso-8859-3' and `iso-8859-9', it should correspond to the normal charset registry of your `default' face. WARNING: Under XEmacs/Mule, package x-symbol is only tested with value `iso-8859-1'! It is assumed that you have not changed any of the various Mule codings-system variables, i.e., it assumes iso-8859-1. Use \\[x-symbol-package-bug] to give the author some advice on Mule.") (unless (or (memq x-symbol-default-coding =09=09 '(iso-8859-1 iso-8859-2 iso-8859-3 iso-8859-9)) =09 (and (eq x-symbol-default-coding 'iso-8859-15) =09=09 (or (not (featurep 'xemacs)) =09=09 (not (featurep 'mule)) =09=09 (fboundp 'emacs-version>=3D) (emacs-version>=3D 21 5)))) (warn "X-Symbol: illegal `x-symbol-default-coding', I'll use `iso-8859-= 1'") (setq x-symbol-default-coding 'iso-8859-1)) ;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D ;;; General Configuration ;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D (defvar x-symbol-after-init-input-hook nil "Hook run after the initialization of all input methods. See `x-symbol-init-input'. If you want define key bindings starting with \\[x-symbol-map], do it here. It is a bad idea to use this for additional self insert commands, use \"character descriptions\" in `x-symbol-user-table' instead.") (add-hook 'x-symbol-after-init-input-hook 'x-symbol-init-default-keys) (defcustom x-symbol-compose-key '(control ?\=3D) "Key used to access command `x-symbol-map'. By default, pressing this key twice invokes the GRID: \\[x-symbol-grid]. This is a list, no vector!" :group 'x-symbol-input-init :type '(x-symbol-key :tag "Prefix key")) (defcustom x-symbol-auto-key-autoload t "*If non-nil, pressing `x-symbol-compose-key' initialize x-symbol. The binding of `x-symbol-compose-key' is redefined after initialization. With value nil, you must provide a prefix argument to initialize package X-Symbol." :group 'x-symbol-input-init :type 'boolean) (defvar x-symbol-auto-conversion-method 'auto-slow ;;(if (featurep 'crypt) 'slow 'fast) "Non-nil means, set up hooks for auto conversion. Fast methods are used if this variable has value `fast'. Otherwise, slower methods are used and \\[vc-register] or \\[vc-next-action] will fail to decode the buffer contents. You should set this variable to value `slowest' if, for example, the symbol for \\alpha looks like \\233a after \\[save-buffer] (this happens on some systems). Value `fast' should not be used, if some other package, e.g., crypt, adds a function to `write-file-hooks' which does not inspect the remaining functions in this hook. Default value `auto-slow' is set to `fast' after the initialization of XEmacs if package crypt has not been loaded by then.") ;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D ;;; Known Token Languages ;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D (defvar x-symbol-language-alist nil "Alist of currently registered token languages. Elements look like (LANGUAGE . NAME) where LANGUAGE is the symbol representing and NAME is the name normally presented to the user, see `x-symbol-language-text'. You should not set this variable directly, use `x-symbol-register-language' instead!") (defcustom x-symbol-charsym-name "x-symbol charsym" "Name of the pseudo token language x-symbol charsym. This pseudo language corresponds to `x-symbol-language' having value nil and is used for input methods, not for decoding and encoding. See `x-symbol-language-text'." :group 'x-symbol-miscellaneous :type 'string) (defcustom x-symbol-tex-name "TeX macro" "Name of token language `tex'. See `x-symbol-register-language'." :group 'x-symbol-tex :type 'string) (defcustom x-symbol-tex-modes '(tex-mode latex-mode plain-tex-mode noweb-mode) "Major modes using language `tex'. See `x-symbol-register-language'." :group 'x-symbol-tex :group 'x-symbol-mode :type '(repeat function)) (defcustom x-symbol-sgml-name "SGML entity" "Name of token language `sgml'. See `x-symbol-register-language'." :group 'x-symbol-sgml :type 'string) (defcustom x-symbol-sgml-modes '(sgml-mode html-mode) "Major modes using language `sgml'. See `x-symbol-register-language'." :group 'x-symbol-sgml :group 'x-symbol-mode :type '(repeat function)) (defcustom x-symbol-haskell-name "HASKELL entity" "Name of token language `haskell'. See `x-symbol-register-language'." :group 'x-symbol-haskell :type 'string) (defcustom x-symbol-haskell-modes '(haskell-mode) "Major modes using language `haskell'. See `x-symbol-register-language= '." :group 'x-symbol-haskell :group 'x-symbol-mode :type '(repeat function)) (defcustom x-symbol-texi-name "TeXinfo command" "Name of token language `tex'. See `x-symbol-register-language'." :group 'x-symbol-texi :type 'string) (defcustom x-symbol-texi-modes '(texinfo-mode) "Major modes using language `texi'. See `x-symbol-register-language'." :group 'x-symbol-texi :group 'x-symbol-mode :type '(repeat function)) (defcustom x-symbol-bib-name "BibTeX macro" "Name of token language `bib'. See `x-symbol-register-language'." :group 'x-symbol-bib :type 'string) (defcustom x-symbol-bib-modes '(bibtex-mode) "Major modes using language `bib'. See `x-symbol-register-language'." :group 'x-symbol-bib :group 'x-symbol-mode :type '(repeat function)) ;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D ;;; Buffer-locals ;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D (defvar x-symbol-mode nil "Non-nil if X-Symbol minor mode is enabled.") (make-variable-buffer-local 'x-symbol-mode) (x-symbol-define-user-options 'x-symbol-mode '(t) nil (lambda (dummy arg) (x-symbol-mode (if arg 1 0)))) (defvar x-symbol-language nil "*Token language used in current buffer. A valid value is required to turn on `x-symbol-mode' which also sets this variable to a reasonable value if the variable is not yet buffer-local. The value influences the conversion, i.e., decoding and encoding of X-Symbol characters, input methods TOKEN and READ-TOKEN, fontification of super- and subscripts, image command recognition, the info in the echo area, etc.") (make-variable-buffer-local 'x-symbol-language) (put 'x-symbol-language 'permanent-local t) (x-symbol-define-user-options 'x-symbol-language (lambda () (list* nil '(nil . "None") x-symbol-language-alist)) '(x-symbol-update-modeline)) (defvar x-symbol-coding nil "*Coding of 8bit characters in a file. Supported values are `iso-8859-1', `iso-8859-2', `iso-8859-3' and `iso-8859-9', value nil means the value of `x-symbol-default-coding'. Determines which characters are considered to be 8bit characters for file operations. Function `x-symbol-mode' sets this variable to a reasonable value if the variable is not yet buffer-local. During decoding, e.g., when visiting a file, the value is always important for the interpretation of 8bit characters, an invalid value is considered to be equivalent to value nil. During encoding, e.g., when saving a buffer, 8bit characters are not encoded to tokens if the value is valid and `x-symbol-8bits' is non-nil.") (make-variable-buffer-local 'x-symbol-coding) (put 'x-symbol-coding 'permanent-local t) (x-symbol-define-user-options 'x-symbol-coding (lambda () (cons x-symbol-default-coding x-symbol-coding-name-alist)) '(x-symbol-update-modeline)) (defvar x-symbol-8bits nil "*If non-nil, do not encode 8bit characters. Variable `x-symbol-coding' determines which characters are assumed to be 8bit characters. Note that tokens representing 8bit characters are always decoded. Function `x-symbol-mode' sets this variable to a reasonable value if the variable is not yet buffer-local.") ;; TODO: link to `x-symbol-unique' (make-variable-buffer-local 'x-symbol-8bits) (put 'x-symbol-8bits 'permanent-local t) (x-symbol-define-user-options 'x-symbol-8bits '(t) '(x-symbol-update-modeline)) (defvar x-symbol-unique nil "*If non-nil, only decode canonical tokens.") ;; TODO: link to `x-symbol-8bits' (make-variable-buffer-local 'x-symbol-unique) (put 'x-symbol-unique 'permanent-local t) (x-symbol-define-user-options 'x-symbol-unique '(t) '(x-symbol-update-modeline)) (defvar x-symbol-subscripts nil "*If non-nil, use special fonts to display super- and subscripts. This feature must be supported by the token language dependent font-lock keywords. Function `x-symbol-mode' sets this variable to a reasonable value if the variable is not yet buffer-local. Some parts of the text might be invisible, see also variable `x-symbol-reveal-invisible'.") (make-variable-buffer-local 'x-symbol-subscripts) (x-symbol-define-user-options 'x-symbol-subscripts '(t) '(x-symbol-update-modeline x-symbol-fontify)) (defvar x-symbol-image nil "*If non-nil, show little glyphs after image insertion commands. This feature must be supported by the token language dependent image keywords, see `x-symbol-image-parse-buffer'. Function `x-symbol-mode' sets this variable to a reasonable value if the variable is not yet buffer-local.") (make-variable-buffer-local 'x-symbol-image) (x-symbol-define-user-options 'x-symbol-image '(t) '(x-symbol-update-modeline) 'x-symbol-set-image) ;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D ;;; Minor mode control ;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D (defcustom x-symbol-buffer-mode-alist nil "*Alist to setup x-symbol values for specific buffers. Elements look like (BUFFER-NAME MODE-ON LANGUAGE CODING 8BIT SUBSCRIPTS IMAGE UNIQUE) If the name of the buffer in which command `x-symbol-mode' is invoked is equal to BUFFER, the rest of the element is used to setup some buffer-local x-symbol specific variables, see `x-symbol-auto-mode-alist' for details. MODE-ON is used directly as the value." :group 'x-symbol-mode :type '(repeat (group (string :tag "Use for buffer") =09=09=09(x-symbol-auto-mode :inline t)))) (defcustom x-symbol-auto-mode-suffixes (x-symbol-auto-mode-suffixes) "*Regexps matching file suffixes not to be considered. All suffixes from a file name matching these regexps are deleted before the file name is used for `x-symbol-auto-mode-alist'. The default value includes the REGEXP in all three-valued elements of `auto-mode-alist', at definition time, of course." :group 'x-symbol-mode :type '(repeat regexp)) (defcustom x-symbol-auto-8bit-search-limit nil "*Limits searching for 8bit characters in the file. Used when finding an appropriate value for `x-symbol-8bits'. See also `x-symbol-mode'." :group 'x-symbol-mode :type '(choice (const :tag "No limit" nil) (integer :tag "Limit"))) (defcustom x-symbol-auto-mode-alist '(((tex-mode latex-mode plain-tex-mode) "\\.tex\\'" 'tex (if x-symbol-mode =09 (x-symbol-auto-coding-alist x-symbol-tex-auto-coding-alist nil =09=09=09=09 (if x-symbol-tex-coding-master =09=09=09=09=09 'x-symbol-tex-auto-coding-alist))) x-symbol-coding x-symbol-mode x-symbol-mode (not x-symbol-mode)) ((sgml-mode html-mode) (html-mode) 'sgml (x-symbol-auto-coding-alist x-symbol-sgml-auto-coding-alist) x-symbol-coding x-symbol-mode x-symbol-mode (not x-symbol-mode)) ((bibtex-mode) t 'bib) ((texinfo-mode) t 'texi)) "*Alist to setup X-Symbol values for buffers visiting files. Elements look like (MATCH MODE-ON LANGUAGE CODING 8BIT SUBSCRIPTS IMAGE UNIQUE) If MATCH matches a buffer in which command `x-symbol-mode' is invoked, the rest of the element is used to setup some buffer-local x-symbol specific variables. If no element matches, set `x-symbol-language' to the symbol property `x-symbol-language' of the major mode symbol if the variable is not already buffer-local. If `x-symbol-mode' is not already buffer-local, MODE-ON determines whether to turn the mode on if `x-symbol-mode' is called with a cons as prefix argument. LANGUAGE, CODING, 8BIT, UNIQUE, SUBSCRIPTS and IMAGE are used to set `x-symbol-language', `x-symbol-coding', `x-symbol-8bits', `x-symbol-unique', `x-symbol-subscripts' and `x-symbol-image' if these values are not already buffer-local. MATCH and MODE-ON are either a list of major modes which must include the mode of the current buffer or a regexp matching the file name ignoring some suffixes, see `x-symbol-auto-mode-suffixes', or a value used directly. LANGUAGE, CODING, 8BIT, UNIQUE, SUBSCRIPTS and IMAGE are `eval'ed in that order. During the evaluation, `x-symbol-mode' is non-nil according to MODE-ON." ;; UNIQUE is at the end due to historic reasons :group 'x-symbol-mode :type '(repeat (group (x-symbol-modes-or-regexp :tag "Use") =09=09=09(x-symbol-auto-mode :inline t)))) ;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D ;;; Images ;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D (defun x-symbol-image-set-colormap (var value) "Set VAR's value to VALUE. Custom set function of `x-symbol-image-colormap-allocation' and `x-symbol-image-convert-colormap'." (if var (set var value)) (if (boundp 'x-symbol-image-convert-colormap) (put 'x-symbol-image-convert-colormap 'x-symbol-image-instance =09 (and (boundp 'x-symbol-image-colormap-allocation) =09=09x-symbol-image-colormap-allocation =09=09x-symbol-image-convert-colormap =09=09(if (featurep 'xemacs) =09=09 (make-image-instance =09=09 (vector x-symbol-image-colormap-allocation =09=09=09 :file x-symbol-image-convert-colormap) =09=09 nil nil t) =09=09 (create-image x-symbol-image-convert-colormap =09=09=09=09x-symbol-image-colormap-allocation)))))) (defcustom x-symbol-image-colormap-allocation 'xpm "If non-nil, prevent colors in colormap to be de-allocated. The non-nil value should be an image format. See `x-symbol-image-convert-colormap'." :group 'x-symbol-image-general :initialize 'custom-initialize-default :set 'x-symbol-image-set-colormap :type '(choice (const :tag "Colors can be de-allocated" nil) =09=09 (const :tag "Colormap is xpm file" xpm) =09=09 (symbol :tag "Other image format"))) (defcustom x-symbol-image-convert-colormap (and x-symbol-data-directory (expand-file-name "colormap138.xpm" x-symbol-data-directory)) "File name of colormap files. Used by `x-symbol-image-start-convert-colormap' for image cache file names not matched by `x-symbol-image-convert-mono-regexp'. See also `x-symbol-image-colormap-allocation'." :group 'x-symbol-image-general :initialize 'custom-initialize-default :set 'x-symbol-image-set-colormap :type '(choice (const :tag "No map" nil) file)) =0C ;;;;#####################################################################= ##### ;;;; Code ;;;;#####################################################################= ##### (defalias 'x-symbol-cset-registry 'caaar) (defalias 'x-symbol-cset-coding 'cdaar) (defalias 'x-symbol-cset-leading 'cadar) (defalias 'x-symbol-cset-score 'caddar) (defalias 'x-symbol-cset-left 'cadr) (defalias 'x-symbol-cset-right 'cddr) (defvar x-symbol-input-initialized nil "Internal. If non-nil, the input methods are initialized.") ;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D ;;; Key autoload ;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D ;;;###autoload (defun x-symbol-key-autoload (&optional arg) "Initialize package x-symbol and use the keys for this command again. Package x-symbol and the functions in `x-symbol-load-hook' should re-bind all key-sequence which invoke this command. You should provide a prefix argument ARG to this command if `x-symbol-auto-key-autoload' is nil." (interactive "P") (when x-symbol-input-initialized (error "%s should be rebound in `x-symbol-init-input-hook'" =09 (key-description (this-command-keys)))) (unless (or arg x-symbol-auto-key-autoload) (error "Use %s with prefix argument to initialize the input methods" =09 (key-description (this-command-keys)))) (let ((this (append (this-command-keys) nil))) ;; for some reason this loop is necessary... (while (and this (null (eq (key-binding (vector (car this))) this-com= mand))) (setq this (cdr this))) (setq prefix-arg arg) (setq unread-command-events this)) (x-symbol-init-input)) ;;;###autoload (defalias 'x-symbol-map-autoload 'x-symbol-key-autoload) ;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D ;;; Minor mode, fontification ;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D (defun x-symbol-auto-mode-alist () "Compute values to setup X-Symbol variables." (let ((name (file-name-sans-versions buffer-file-name)) =09(case-fold-search (eq system-type 'vax-vms)) =09(suffixes x-symbol-auto-mode-suffixes) =09(alist x-symbol-auto-mode-alist) =09matcher result) (while suffixes (if (string-match (pop suffixes) name) =09 (setq name (substring name 0 (match-beginning 0))))) (while alist (if (if (consp (setq matcher (caar alist))) =09 (memq major-mode matcher) =09 (if (stringp matcher) (string-match matcher name) matcher)) =09 (setq result (cdar alist) =09=09result (cons (if (consp (setq matcher (car result))) =09=09=09=09 (memq major-mode matcher) =09=09=09 (if (stringp matcher) =09=09=09=09 (string-match matcher name) =09=09=09=09 matcher)) =09=09=09 (cdr result)) =09=09alist nil) =09(setq alist (cdr alist)))) result)) (defun x-symbol-auto-set-variable (symbol form) "Set SYMBOL's value to evaluated FORM if SYMBOL is not buffer-local." (or (local-variable-p symbol (current-buffer)) (set symbol (eval form)))) ;;;###autoload (defun x-symbol-mode (&optional arg init) "Toggle X-Symbol mode. If ARG is a cons, e.g., when \\[x-symbol-mode] is preceded by one or more \\[universal-argument]'s with no digits, turn on X-Symbol mode conditionally, see MODE-ON in `x-symbol-auto-mode-alist'. Otherwise, turn X-Symbol mode on if ARG is positive, else turn it off. If some X-Symbol specific local variables are not buffer-local, set them to reasonable values according to `x-symbol-buffer-mode-alist' and `x-symbol-auto-mode-alist'. Turning X-Symbol mode on requires a valid `x-symbol-language' and also decodes tokens if the mode was turned off before, see \\[x-symbol-decode]. Turning X-Symbol mode off also encodes x-symbol characters if the mode was turned on before, see \\[x-symbol-encode]. If argument INIT is non-nil, the old mode status is assumed to be off." (interactive "P") (let ((old-mode x-symbol-mode) =09(values (or (cdr (assoc (buffer-name) x-symbol-buffer-mode-alist)) =09=09 (and buffer-file-name (x-symbol-auto-mode-alist)) =09=09 (get major-mode 'x-symbol-language)))) (when values (if (symbolp values) (setq values (list nil (list 'quote values)))) (let ((x-symbol-mode (car values))) =09;; bind value for functions in `x-symbol-auto-mode-alist' =09(x-symbol-auto-set-variable 'x-symbol-language (cadr values)) =09(x-symbol-auto-set-variable 'x-symbol-coding (caddr values)) =09(or (local-variable-p 'x-symbol-8bits (current-buffer)) =09 (setq x-symbol-8bits (or (eval (cadddr values)) =09=09=09=09 (x-symbol-auto-8bit-search)) =09=09 ;; use value `null' to disable 8bit char search =09=09 x-symbol-8bits (and (not (eq x-symbol-8bits 'null)) =09=09=09=09 x-symbol-8bits))) =09(x-symbol-auto-set-variable 'x-symbol-unique (nth 6 values)) =09(x-symbol-auto-set-variable 'x-symbol-subscripts (nth 4 values)) =09(x-symbol-auto-set-variable 'x-symbol-image (nth 5 values)))) (or (null x-symbol-language)=09; e.g., not buffer-local =09(and (symbolp x-symbol-language) =09 (get x-symbol-language 'x-symbol-feature)) =09(setq x-symbol-language nil)) (setq x-symbol-mode =09 (if arg =09 (if (consp arg) =09=09 (if (local-variable-p 'x-symbol-mode (current-buffer)) =09=09 (and x-symbol-mode t) =09=09 (car values)) =09=09(> (prefix-numeric-value arg) 0)) =09 (not x-symbol-mode))) (when (and x-symbol-mode (null x-symbol-language)) (setq x-symbol-mode nil) (or init =09 (not (interactive-p)) =09 (if (setq x-symbol-language =09=09 (x-symbol-read-language =09=09 "Token Language for X-Symbol mode: " nil 'cdr)) =09 (setq x-symbol-mode t) =09 (error "A valid token language is required to turn on X-Symbol")))= ) (if (assq 'x-symbol format-alist) =09(if x-symbol-mode =09 (push 'x-symbol buffer-file-format) =09 (setq buffer-file-format (delq 'x-symbol buffer-file-format)))) (if init =09(if x-symbol-mode (x-symbol-mode-internal t)) (x-symbol-mode-internal (and x-symbol-language =09=09=09=09 (eq (null old-mode) x-symbol-mode)))))) ;;;###autoload (defun turn-on-x-symbol-conditionally () "Turn on x-symbol mode conditionally, see `x-symbol-mode'. Call `x-symbol-mode' with a cons for ARG and a non-nil INIT. Used in `hack-local-variables-hook'." (if (if (local-variable-p 'x-symbol-mode (current-buffer)) x-symbol-mod= e t) (x-symbol-mode '(1) t))) ;;;###autoload (defun x-symbol-fontify (&optional beg end) "Re-fontify region between BEG and END." (interactive (and (region-active-p) (list (region-beginning) (region-en= d)))) (cond ((not font-lock-mode) (turn-on-font-lock)) =09((and (boundp 'lazy-shot-mode) lazy-shot-mode) =09 ;; copied from lazy-shot: =09 (setq font-lock-fontified =09 (and lazy-shot-minimum-size =09=09 (>=3D (buffer-size) lazy-shot-minimum-size))) =09 (if (fboundp 'lazy-shot-after-change-function) =09 ;; No, I'm not using `compiled-function-arglist' instead... =09 (lazy-shot-install-extents (point-min) (point-max)=09; XEmacs-20.= 4 =09=09=09=09=09font-lock-fontified) =09 (lazy-shot-install-extents font-lock-fontified))) ; XEmacs-20.3 =09((and (boundp 'lazy-lock-mode) lazy-lock-mode) =09 ;; copied from lazy-lock: =09 (let ((modified (buffer-modified-p)) (inhibit-read-only t) =09 (buffer-undo-list t) =09 ;;deactivate-mark =09 buffer-file-name buffer-file-truename) =09 (remove-text-properties (or beg 1) (or end (1+ (buffer-size))) =09=09=09=09 '(fontified nil)) =09 (or modified (set-buffer-modified-p nil)))) =09(t =09 (font-lock-fontify-buffer)))) ;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D ;;; comint support ;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D (defun x-symbol-comint-output-filter (dummy) ;; checkdoc-params: (dummy) "Decode output of comint's process. Used as value in `comint-output-filter-functions'." (and x-symbol-mode x-symbol-language (save-excursion =09 (x-symbol-decode-region (if (interactive-p) =09=09=09=09 comint-last-input-end =09=09=09=09 comint-last-output-start) =09=09=09=09 (process-mark (get-buffer-process =09=09=09=09=09=09(current-buffer))))))) (defun x-symbol-comint-send (proc string) "Encode STRING and send it to process PROC. Used as value of `comint-input-sender', uses `x-symbol-orig-comint-input-sender'." (and x-symbol-mode x-symbol-language (setq string =09 (save-excursion =09 (let ((orig-buffer (current-buffer)) =09=09 (selective selective-display)) =09=09 (set-buffer (get-buffer-create " x-symbol comint")) =09=09 (erase-buffer) =09=09 (insert string) =09=09 (x-symbol-inherit-from-buffer orig-buffer) =09=09 (x-symbol-encode-all) =09=09 (setq selective-display selective)) =09=09 (buffer-string)))) (funcall x-symbol-orig-comint-input-sender proc string)) ;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D ;;; Hooks for automatic conversion ;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D ;; For format fns: check whether read-only stuff is still necessary... (defun x-symbol-format-decode (start end) (if (and x-symbol-mode x-symbol-language) (save-restriction =09(let ((modified (buffer-modified-p)) ; t if `recover-file'! =09 ;;(buffer-undo-list t) ; do not record changes =09 ;; we cannot set buffer-undo-list to t even if the previous =09 ;; value is nil because M-x insert-file as the first command =09 ;; after reading a file would set the old insert-region =09 ;; boundaries into the undo-list =09 (buffer-read-only nil) ; always allow conversion =09 (inhibit-read-only t) =09 (first-change-hook nil) ; no `flyspell-mode' here =09 (after-change-functions nil)) ; no fontification ;;;=09 (and orig-buffer ;;;=09 (not (eq (current-buffer) orig-buffer)) ;;;=09 (x-symbol-inherit-from-buffer orig-buffer)) =09 (x-symbol-decode-all) =09 (or modified (set-buffer-modified-p nil)) =09 (point-max))) end)) (defun x-symbol-format-encode (start end orig-buffer) (let ((new-buffer (current-buffer))) (if (eq new-buffer orig-buffer) =09(and x-symbol-mode x-symbol-language =09 (save-restriction =09 (narrow-to-region start end) =09 (x-symbol-encode-all))) (set-buffer orig-buffer) (and x-symbol-mode x-symbol-language =09 (let ((selective selective-display)) =09 (x-symbol-encode-all new-buffer) =09 ;; set `selective-display' according to orig buffer =09 (setq selective-display selective)))))) (defun x-symbol-after-insert-file (len) ;; checkdoc-params: (len) "Decode tokens, e.g., after \\[vc-register] or \\[vc-next-action]. Added to `after-insert-file-functions' if `x-symbol-auto-conversion-method' has value `fast'." ;; Arg! In XEmacs, there is no way to know the start position of the r= egion. ;; If `insert-file-contents' is called with argument REPLACE being non-= nil, ;; it is not always point. Thus, we use `point-min', except when calle= d from ;; `M-x insert-file'. (and x-symbol-mode x-symbol-language (let ((insert-file-p (or (eq this-command 'insert-file) =09=09=09=09(and (memq this-command =09=09=09=09=09 '(minibuffer-complete-and-exit =09=09=09=09=09 exit-minibuffer)) =09=09=09=09 (eq (car-safe (car command-history)) =09=09=09=09=09 'insert-file))))) =09 (when (or (null insert-file-p) =09=09 (<=3D (+ (point) len) (point-max))) =09 (save-restriction =09 (if insert-file-p (narrow-to-region (point) (+ (point) len))) =09 (let ((origpos (point)) =09=09 (modified (buffer-modified-p)) ; t if `recover-file'! =09=09 ;;(buffer-undo-list t) ; do not record changes =09=09 ;; we cannot set buffer-undo-list to t even if the previous =09=09 ;; value is nil because M-x insert-file as the first command =09=09 ;; after reading a file would set the old insert-region =09=09 ;; boundaries into the undo-list =09=09 (buffer-read-only nil) ; always allow conversion =09=09 (inhibit-read-only t) =09=09 (first-change-hook nil) ; no `flyspell-mode' here =09=09 (after-change-functions nil)) ; no fontification =09 (x-symbol-decode-all) =09 (goto-char origpos) =09 (or modified (set-buffer-modified-p nil)) =09 ;; `len' is utterly wrong when not called in `insert-file', =09 ;; but there is no chance to get it right if we don't know the =09 ;; start position, see above. =09 (setq len (- (point-max) (point-min)))))))) len) (defun x-symbol-write-region-annotate-function (start end) ;; checkdoc-params: (start end) "Encode x-symbol characters using another buffer. Added to `write-region-annotate-functions' if `x-symbol-auto-conversion-method' has value `fast'." (and x-symbol-mode x-symbol-language (not (equal start ""))=09=09; kludgy feature of `write-region' ;; Without the test, "x-symbol.el" is loaded twice, the initializa= tion ;; done twice (resulting in warnings about charsym redefinitions). ;; Reason: in Emacs, `make-temp-name', used for the value of some = var in ;; "x-symbol-vars.el", required by "x-symbol.el", calls `write-reg= ion'. (let ((selective selective-display)) =09 (x-symbol-encode-all (get-buffer-create " x-symbol conversion") =09=09=09 start end) =09 ;; set `selective-display' according to orig buffer =09 (setq selective-display selective))) nil) (defun x-symbol-write-file-hook () "Encode x-symbol characters in current buffer. Added to `write-file-hooks' if `x-symbol-auto-conversion-method' has a value other than nil or `fast'. Refontifies buffer if `x-symbol-auto-conversion-method' has value `slowest'." (and x-symbol-mode x-symbol-language (let ((buffer-read-only nil) =09 (first-change-hook nil)=09; no `flyspell-mode' here =09 (after-change-functions nil)) ; no fontification! =09(widen) =09;; Called inside `save-recursion' and `save-restriction'. =09(call-with-transparent-undo =09 (lambda () =09 (x-symbol-encode-all)=09; not the safe version! =09 (continue-save-buffer))) =09(and (eq x-symbol-auto-conversion-method 'slowest) =09 font-lock-mode =09 (x-symbol-fontify)) =09(set-buffer-modified-p nil) =09'x-symbol-write-file-hook)))=09; do not write again ;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D ;;; Init ;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D (defvar x-symbol-modeline-string "" "String that should appear in the modeline when `x-symbol-mode' is on. Its value is set by `x-symbol-update-modeline'.") (make-variable-buffer-local 'x-symbol-modeline-string) (defvar x-symbol-mode-map (let ((m (make-sparse-keymap))) ;; (substitute-key-definition 'x-symbol-map-autoload 'x-symbol-map ;; =09=09=09 m global-map) m)) (add-minor-mode 'x-symbol-mode 'x-symbol-modeline-string x-symbol-mode-ma= p) (put 'x-symbol-mode :menu-tag "X-Symbol") (defun x-symbol-init-language-accesses (language alist) "Initialize accesses for token language LANGUAGE according to ALIST. The symbol property `x-symbol-feature' of LANGUAGE must be set before. See also `x-symbol-language-access-alist'." ;;If optional NO-TEST is nil, accesses which do not point to a bound ;;variable are not set. (let ((feature (get language 'x-symbol-feature)) =09symbol) (unless feature (error "Illegal X-Symbol token language `%s'" language)) (dolist (item alist) (and (null (get language (car item))) =09 (stringp =09 (setq symbol (if (consp (cdr item)) =09=09=09 (if (featurep 'mule) (cadr item) (cddr item)) =09=09=09 (cdr item)))) =09 (setq symbol (intern (format "%s-%s" feature symbol))) =09 (or (boundp symbol) =09 (progn (warn "X-Symbol language %s forgot to define `%s'" =09=09=09 language symbol) =09=09 nil)) =09 (put language (car item) symbol))))) ;;;###autoload (defun x-symbol-register-language (language feature modes) "Register token language LANGUAGE. FEATURE is a feature which `provide's LANGUAGE. MODES are major modes which typically use LANGUAGE. Using LANGUAGE's accesses will initialize LANGUAGE, see `x-symbol-language-value'." (unless (get language 'x-symbol-feature) (put language 'x-symbol-feature feature)) (x-symbol-init-language-accesses language '((x-symbol-name . "name"))) (unless (assq language x-symbol-language-alist) (setq x-symbol-language-alist =09 (nconc x-symbol-language-alist =09=09 (list (cons language =09=09=09 (symbol-value (get language 'x-symbol-name))))))) (dolist (mode modes) (put mode 'x-symbol-language language) (put mode 'x-symbol-font-lock-language language))) ;;;###autoload (defun x-symbol-initialize (&optional arg) "Initialize package X-Symbol. See variable `x-symbol-initialize' and function `x-symbol-after-init'. Also allocate colormap, see `x-symbol-image-colormap-allocation'. Unless optional argument ARG is non-nil, do not initialize package X-Symbol twice." (interactive "P") (unless (and (get 'x-symbol 'x-symbol-initialized) (null arg)) (put 'x-symbol 'x-symbol-initialized t) ;; X-Symbol doesn't make sense without the following. `ctl-arrow' is= a ;; boolean in Emacs, but not in XEmacs: despite its docstring, value = t ;; means the same as 256 (and 255 sometimes, which is probably wrong)= =2E (or (default-value 'ctl-arrow) (setq-default ctl-arrow 'iso-8859/1)) ;; Token languages --------------------------------------------------= ----- (when (or (eq x-symbol-initialize t) =09 (memq 'languages x-symbol-initialize)) (x-symbol-register-language 'tex 'x-symbol-tex x-symbol-tex-modes) (x-symbol-register-language 'sgml 'x-symbol-sgml x-symbol-sgml-mode= s) (x-symbol-register-language 'haskell 'x-symbol-haskell x-symbol-has= kell-modes) (x-symbol-register-language 'bib 'x-symbol-bib x-symbol-bib-modes) (x-symbol-register-language 'texi 'x-symbol-texi x-symbol-texi-mode= s)) ;; Global mode ------------------------------------------------------= ----- (when (or (eq x-symbol-initialize t) =09 (memq 'global x-symbol-initialize)) (add-hook 'hack-local-variables-hook 'turn-on-x-symbol-conditionall= y)) ;; Key bindings -----------------------------------------------------= ----- (when (or (eq x-symbol-initialize t) =09 (memq 'keys x-symbol-initialize)) (global-set-key (vector x-symbol-compose-key) 'x-symbol-map-autoloa= d) (unless (featurep 'xemacs) =09(define-key isearch-mode-map (vector x-symbol-compose-key) nil) =09(define-key isearch-mode-map [menu-bar X-Symbol] nil)) (global-set-key [(control ?\,)] 'x-symbol-modify-key) (global-set-key [(control ?\.)] 'x-symbol-rotate-key)) ;; Font path --------------------------------------------------------= ----- (and (or (eq x-symbol-initialize t) =09 (memq 'font-path x-symbol-initialize)) =09 x-symbol-font-directory =09 (file-accessible-directory-p x-symbol-font-directory) =09 ;; by Jim Radford : =09 (eq (console-type) 'x) =09 (if (fboundp 'x-set-font-path) =09 (let ((font-path (x-get-font-path))) =09 (unless (member x-symbol-font-directory font-path) =09=09 (x-set-font-path (nconc font-path =09=09=09=09=09 (list x-symbol-font-directory))))) =09 ;; This should be commented out until I can figure out how to =09 ;; get the display name into the -display arg for xset. =09 (with-temp-buffer =09 (call-process "xset" nil t nil "q") =09 (goto-char (point-min)) =09 (unless (search-forward x-symbol-font-directory nil t) =09 (call-process "xset" nil nil nil "fp+" =09=09=09 x-symbol-font-directory))))) ;; Package fast-lock ------------------------------------------------= ----- (when (or (eq x-symbol-initialize t) =09 (memq 'fast-lock x-symbol-initialize)) (setq fast-lock-save-faces nil)) ;; Package AucTeX ---------------------------------------------------= ------- (when (or (eq x-symbol-initialize t) =09 (memq 'auctex x-symbol-initialize)) (or (fboundp 'x-symbol-tex-error-location) ; esp for preview-latex =09 (fset 'x-symbol-tex-error-location 'ignore)) (add-hook 'TeX-translate-location-hook 'x-symbol-tex-error-location= ) (add-hook 'TeX-region-hook 'x-symbol-inherit-from-buffer) ; v9.8a+ (setq LaTeX-math-insert-function 'x-symbol-auctex-math-insert)) ; v= 9.8a+ ;; Package RefTeX ---------------------------------------------------= ----- (when (or (eq x-symbol-initialize t) =09 (memq 'reftex x-symbol-initialize)) (unless (and (boundp 'reftex-translate-to-ascii-function) =09=09 (fboundp reftex-translate-to-ascii-function) =09=09 (not (eq reftex-translate-to-ascii-function =09=09=09 'reftex-latin1-to-ascii))) =09(setq reftex-translate-to-ascii-function 'x-symbol-translate-to-ascii)= ) (add-hook 'reftex-pre-refontification-functions =09=09'x-symbol-inherit-from-buffer) (unless (featurep 'mule) =09;; RefTeX might be invoked from a TeX buffer without X-Symbol =09(or (fboundp 'x-symbol-nomule-fontify-cstrings) =09 (fset 'x-symbol-nomule-fontify-cstrings 'ignore)) =09(add-hook 'reftex-display-copied-context-hook =09=09 'x-symbol-nomule-fontify-cstrings))) ;; Miscellaneous ----------------------------------------------------= ----- (x-symbol-image-set-colormap nil nil) (if init-file-loaded =09(x-symbol-after-init) (add-hook 'after-init-hook 'x-symbol-after-init)))) (defun x-symbol-after-init () "Late initialization for package X-Symbol. See function `x-symbol-initialize' and variables `x-symbol-initialize' and `x-symbol-auto-conversion-method'. Also add elements to `x-symbol-auto-mode-suffixes' if necessary." (when x-symbol-auto-conversion-method (and (eq x-symbol-auto-conversion-method 'auto-slow) =09 (null (featurep 'crypt)) =09 (setq x-symbol-auto-conversion-method 'fast)) (cond ((eq x-symbol-auto-conversion-method 'format) =09 (or (assq 'x-symbol format-alist) =09 (push '(x-symbol "X-Symbol" nil =09=09=09=09x-symbol-format-decode x-symbol-format-encode =09=09=09=09t x-symbol-mode t) =09=09 format-alist))) =09 ((eq x-symbol-auto-conversion-method 'fast) =09 (add-hook 'after-insert-file-functions =09=09 'x-symbol-after-insert-file t) =09 (add-hook 'write-region-annotate-functions =09=09 'x-symbol-write-region-annotate-function)) =09 (t =09 (add-hook 'write-file-hooks 'x-symbol-write-file-hook)))) ;; misc user additions to `auto-mode-alist': (setq x-symbol-auto-mode-suffixes (x-symbol-auto-mode-suffixes =09=09=09=09 x-symbol-auto-mode-suffixes)) ;; Package comint -----------------------------------------------------= ----- (when (or (eq x-symbol-initialize t) =09 (memq 'comint x-symbol-initialize)) (add-hook 'comint-output-filter-functions 'x-symbol-comint-output-fil= ter) (and (boundp 'comint-input-sender) =09 (not (eq comint-input-sender 'x-symbol-comint-send)) =09 (setq x-symbol-orig-comint-input-sender comint-input-sender)) (setq comint-input-sender 'x-symbol-comint-send)) ;; Package bib-cite: X-Symbol decoding would overwrite cite highlightin= g with ;; normal installation of bib-cite ------------------------------------= ----- (when (and (or (eq x-symbol-initialize t) =09=09 (memq 'bib-cite x-symbol-initialize)) =09 (or (and (boundp 'LaTeX-mode-hook) =09=09 (memq 'turn-on-bib-cite LaTeX-mode-hook)) =09=09 (and (boundp 'latex-mode-hook) =09=09 (memq 'turn-on-bib-cite latex-mode-hook)))) (remove-hook 'LaTeX-mode-hook 'turn-on-bib-cite) (remove-hook 'latex-mode-hook 'turn-on-bib-cite) (add-hook 'find-file-hooks 'x-symbol-turn-on-bib-cite))) ;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D ;;; Support for other packages ;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D (defun x-symbol-inherit-from-buffer (&optional parent action) "Inherit X-Symbol's buffer-local variables from buffer PARENT. Inherit `x-symbol-mode', `x-symbol-coding', `x-symbol-8bits', `x-symbol-language', and `x-symbol-subscripts' from PARENT and set `x-symbol-image' to nil. If PARENT is nil, `orig-buffer' is used if it is bound. ACTION is ignored." (and (null parent) (boundp 'orig-buffer) (setq parent orig-buffer)) ;; I don't care too much that people who use X-Symbol in the master buf= fer, ;; but not in the buffer where they invoke M-x TeX-command-region from,= won't ;; have the X-Symbol characters in the "master envelope" decoded... (if (buffer-live-p (get-buffer parent)) (let (mode-on coding 8bits unique language subscripts) =09(save-excursion =09 (set-buffer parent) =09 (setq mode-on x-symbol-mode =09=09coding x-symbol-coding =09=098bits=09 x-symbol-8bits =09=09unique x-symbol-unique =09=09language x-symbol-language =09=09subscripts x-symbol-subscripts)) =09(setq x-symbol-mode mode-on) =09(if (local-variable-p 'x-symbol-coding parent) =09 (setq x-symbol-coding coding)) =09(if (local-variable-p 'x-symbol-8bits parent) =09 (setq x-symbol-8bits 8bits)) =09(if (local-variable-p 'x-symbol-unique parent) =09 (setq x-symbol-unique unique)) =09(if (local-variable-p 'x-symbol-language parent) =09 (setq x-symbol-language language)) =09(if (local-variable-p 'x-symbol-subscripts parent) =09 (setq x-symbol-subscripts subscripts)) =09(setq x-symbol-image nil)))) (defun x-symbol-auctex-math-insert (string) "Insert the character for \\STRING. Used as value for `LaTeX-math-insert-function'." (let ((cstring (and x-symbol-mode x-symbol-language =09=09 (x-symbol-decode-single-token (concat "\\" string))))) (if cstring =09(insert cstring) (TeX-insert-macro string)))) (defun x-symbol-turn-on-bib-cite () "Run `turn-on-bib-cite' if we are in `latex-mode'. Added to `find-file-hooks' if the initialization for X-Symbol has removed `turn-on-bib-cite' from `LaTeX-mode-hook' or `latex-mode-hook'. See variable `x-symbol-initialize'." (if (eq major-mode 'latex-mode) (turn-on-bib-cite))) ;;; Local IspellPersDict: .ispell_xsymb ;;; x-symbol-hooks.el ends here --------------Boundary-00=_B3HAL8NDZMRFLJ7FPKJS-- From jscott@planetinternet.be Tue Aug 6 00:56:36 2002 From: jscott@planetinternet.be (Scott J.) Date: Tue, 6 Aug 2002 01:56:36 +0200 Subject: multiple C compilers Message-ID: <008001c23cdb$bf02c790$2097fea9@janxp> This is a multi-part message in MIME format. ------=_NextPart_000_007D_01C23CEC.7F602130 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi, This is perhaps an idiot question , but I would like to know if one has = to stick with one c compiler or if one can use different c compilers for = Haskell2C ? Thx Scott ------=_NextPart_000_007D_01C23CEC.7F602130 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hi,
 
This is perhaps an idiot question , but = I would=20 like to know if one has to stick with one c compiler or if one can use = different=20 c compilers for Haskell2C ?
 
Thx
 
Scott
------=_NextPart_000_007D_01C23CEC.7F602130-- From jscott@planetinternet.be Tue Aug 6 01:00:38 2002 From: jscott@planetinternet.be (Scott J.) Date: Tue, 6 Aug 2002 02:00:38 +0200 Subject: Jcreator Message-ID: <008b01c23cdc$4bec1530$2097fea9@janxp> This is a multi-part message in MIME format. ------=_NextPart_000_0088_01C23CED.0F487E00 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi,=20 can Jcreator be used also with GHC or only with Hugs as an IDE for = Haskell? Thx Scott ------=_NextPart_000_0088_01C23CED.0F487E00 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hi,
 
can Jcreator be used also with GHC or = only with=20 Hugs as an IDE for Haskell?
 
Thx
 
Scott
------=_NextPart_000_0088_01C23CED.0F487E00-- From ck15@cs.waikato.ac.nz Thu Aug 8 12:25:56 2002 From: ck15@cs.waikato.ac.nz (ck15) Date: Thu, 08 Aug 2002 23:25:56 +1200 Subject: Unicode Message-ID: <3D525544.22A1DC90@cs.waikato.ac.nz> Hi, Is there a way to include symbols like set union , set intersection etc in Haskell code ? Chitra From jadrian@mat.uc.pt Thu Aug 8 12:34:42 2002 From: jadrian@mat.uc.pt (Jorge Adriano) Date: Thu, 8 Aug 2002 12:34:42 +0100 Subject: Unicode In-Reply-To: <3D525544.22A1DC90@cs.waikato.ac.nz> References: <3D525544.22A1DC90@cs.waikato.ac.nz> Message-ID: <200208081234.42593.jadrian@mat.uc.pt> > Hi, > Is there a way to include symbols like set union , set > intersection etc in Haskell code ? > Chitra One very simple idea to use this (in Xemacs) would be to make an X-Symbol= for=20 haskell (http://x-symbol.sourceforge.net/) . It doesn't seem that complic= ated=20 but I know nothing abuot elisp at this time. Ths mode can map tokens into math symbols and vice-versa. We can define the tokens and the associations, one simple idea would be t= o map=20 _alpha into alphas, =3D> into real arrows, etc. J.A. From d95mback@dtek.chalmers.se Thu Aug 8 13:21:49 2002 From: d95mback@dtek.chalmers.se (Martin =?ISO-8859-1?Q?Norb=E4ck?=) Date: 08 Aug 2002 14:21:49 +0200 Subject: Unicode In-Reply-To: <3D525544.22A1DC90@cs.waikato.ac.nz> References: <3D525544.22A1DC90@cs.waikato.ac.nz> Message-ID: <1028809310.10034.27.camel@caesar.safelogic.se> --=-efIKESDgFcvUkHkB4pey Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable tor 2002-08-08 klockan 13.25 skrev ck15: > Hi, > Is there a way to include symbols like set union , set > intersection etc in Haskell code ? Reference from http://www.haskell.org/onlinereport/lexemes.html (Haskell 98 report) "Haskell uses a pre-processor to convert non-Unicode character sets into Unicode. This pre-processor converts all characters to Unicode and uses the escape sequence \uhhhh, where the "h" are hex digits, to denote escaped Unicode characters. Since this translation occurs before the program is compiled, escaped Unicode characters may appear in identifiers and any other place in the program." So, you should be able to use the following: \u222a =3D set union \u2229 =3D set intersection etc. These characters should be allowed as operators, since they are unicode symbols, but neither ghc 5.04, hugs December 2001 or nhc98 1.14 accepts this syntax. As a matter of fact they all complain about an unexpected \. I couldn't find any compiler flag to make it compile either. The programs tested was a \u222a b =3D undefined I also tested the more normal \u0061 =3D undefined but none worked. Am I wrong here or is nobody following the standard? Another question is what happens to layout with these characters (6 spaces or 1?). Would it be feasible to allow, say, UTF-8 input instead, by some pragma or compiler flag? Would be very slick, since many editors support UTF-8, but not many support the \uhhhh notation. Same problem with layout of course. Regards, Martin --=20 Martin Norb=E4ck d95mback@dtek.chalmers.se =20 Kapplandsgatan 40 +46 (0)708 26 33 60 =20 S-414 78 G=D6TEBORG http://www.dtek.chalmers.se/~d95mback/ SWEDEN OpenPGP ID: 3FA8580B --=-efIKESDgFcvUkHkB4pey Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: För information se http://www.gnupg.org/ iD8DBQA9UmJdkXyAGj+oWAsRAoTKAJ9pCxgf0FfYh7APr2JEiKqwZQyynwCgjgkS 0e7X85vycVWe3fuo2QC60Q8= =iojC -----END PGP SIGNATURE----- --=-efIKESDgFcvUkHkB4pey-- From listman@garbett.org Thu Aug 8 20:11:54 2002 From: listman@garbett.org (Shawn P. Garbett) Date: Thu, 8 Aug 2002 14:11:54 -0500 Subject: Modification of State Transformer Message-ID: I'm trying to modify Richard Bird's state transformer. The example in his book (_Introduction_to_Functional_Programming_using_Haskell_) has State defined as a explicit type. I.e. Here's the relevant snippet: -- State transformer definition newtype St a = MkSt (State -> (a, State)) type State = Int -- State transformer applied to state apply :: St a -> State -> (a, State) apply (MkSt f) s = f s -- State monad instance Monad St where return x = MkSt f where f s = (x,s) p >>= q = MkSt f where f s = apply (q x) s' where (x, s') = apply p s ----------------------------------------- What I want is something like this, so that the state transformer has a generic state type: newtype St a s = MkSt (s -> (a, s)) apply :: St a s -> s -> (a, s) apply (MkSt f) s = f s instance Monad St where return x = MkSt f where f s = (x,s) p >>= q = MkSt f where f s = apply (q x) s' where (x, s') = apply p s ----------------------------------------------------------- The trouble occurs on the instance line Couldn't match `*' against `* -> *' Expected kind: (* -> *) -> * Inferred kind: (* -> * -> *) -> * When checking kinds in `Monad St' In the instance declaration for `Monad St' Failed, modules loaded: none. From Tom.Pledger@peace.com Thu Aug 8 21:52:15 2002 From: Tom.Pledger@peace.com (Tom Pledger) Date: Fri, 9 Aug 2002 08:52:15 +1200 Subject: Modification of State Transformer In-Reply-To: References: Message-ID: <15698.55807.584319.9845@waytogo.peace.co.nz> Shawn P. Garbett writes: : | What I want is something like this, so that the state transformer has a | generic state type: | | newtype St a s = MkSt (s -> (a, s)) | | apply :: St a s -> s -> (a, s) | apply (MkSt f) s = f s | | instance Monad St where | return x = MkSt f where f s = (x,s) | p >>= q = MkSt f where f s = apply (q x) s' | where (x, s') = apply p s | ----------------------------------------------------------- | The trouble occurs on the instance line | Couldn't match `*' against `* -> *' | Expected kind: (* -> *) -> * | Inferred kind: (* -> * -> *) -> * Let's compare your declaration of St with the type signatures in class Monad. class Monad m where return :: a -> m a (>>=) :: m a -> (a -> m b) -> m b -- etc. If we instantiate m as St, we get a type of a -> St a for return, which lacks the state variable s. In turn, s corresponds to the third * in the inferred kind in the error message. Try partially applying St to its state variable, and declaring a Monad instance of that partial application, which will have the right kind *->*. Regards, Tom From Tom.Pledger@peace.com Thu Aug 8 21:58:33 2002 From: Tom.Pledger@peace.com (Tom Pledger) Date: Fri, 9 Aug 2002 08:58:33 +1200 Subject: Modification of State Transformer In-Reply-To: <15698.55807.584319.9845@waytogo.peace.co.nz> References: <15698.55807.584319.9845@waytogo.peace.co.nz> Message-ID: <15698.56185.868738.950112@waytogo.peace.co.nz> Tom Pledger writes: | Shawn P. Garbett writes: : | | Inferred kind: (* -> * -> *) -> * : | In turn, s corresponds to the third * in the inferred kind in the | error message. Oops! Sorry, the third * is the result of applying St to two types. The second of those two types, s, corresponds to the second *. From ken@digitas.harvard.edu Thu Aug 8 22:03:40 2002 From: ken@digitas.harvard.edu (Ken Shan) Date: Thu, 8 Aug 2002 17:03:40 -0400 Subject: Modification of State Transformer In-Reply-To: References: Message-ID: <20020808210340.GC6497@proper.eecs.harvard.edu> --PHCdUe6m4AxPMzOu Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2002-08-08T14:11:54-0500, Shawn P. Garbett wrote: > newtype St a s =3D MkSt (s -> (a, s)) > instance Monad St where This line should say instance Monad (St a) where because it is (St a) that is a Monad, not St by itself. --=20 Edit this signature at http://www.digitas.harvard.edu/cgi-bin/ken/sig http://www.ethnologue.com/ --PHCdUe6m4AxPMzOu Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (GNU/Linux) iD8DBQE9UtyrzjAc4f+uuBURAmjGAJ9RRgPZmwAyqqKNxRV5+gFernRPgwCggx9V oGNBAFQrwcAfdmagZI0anTw= =uuaz -----END PGP SIGNATURE----- --PHCdUe6m4AxPMzOu-- From jcast@ou.edu Thu Aug 8 23:33:10 2002 From: jcast@ou.edu (Jon Cast) Date: Thu, 08 Aug 2002 17:33:10 -0500 Subject: Modification of State Transformer In-Reply-To: Message from "Shawn P. Garbett" of "Thu, 08 Aug 2002 14:11:54 CDT." Message-ID: <200208082233.g78MXBIl002435@localhost.localdomain> "Shawn P. Garbett" wrote: > I'm trying to modify Richard Bird's state transformer. The example > in his book (_Introduction_to_Functional_Programming_using_Haskell_) > has State defined as a explicit type. > I.e. Here's the relevant snippet: > -- State transformer definition > newtype St a = MkSt (State -> (a, State)) > type State = Int > -- State transformer applied to state > apply :: St a -> State -> (a, State) > apply (MkSt f) s = f s > -- State monad > instance Monad St where > return x = MkSt f where f s = (x,s) > p >>= q = MkSt f where f s = apply (q x) s' > where (x, s') = apply p s > ----------------------------------------- > What I want is something like this, so that the state transformer > has a generic state type: Btw: This has already been done, in GHC: see the ST module in GHC's library . To answer your specific question, though: > newtype St a s = MkSt (s -> (a, s)) These are in the wrong order (see below); you want: > newtype St s a = MkSt (s -> (a, s)) > apply :: St a s -> s -> (a, s) > apply (MkSt f) s = f s Again, s/St a s/St s a/. > instance Monad St where > return x = MkSt f where f s = (x,s) > p >>= q = MkSt f where f s = apply (q x) s' > where (x, s') = apply p s > ----------------------------------------------------------- > The trouble occurs on the instance line > Couldn't match `*' against `* -> *' > Expected kind: (* -> *) -> * > Inferred kind: (* -> * -> *) -> * > When checking kinds in `Monad St' > In the instance declaration for `Monad St' > Failed, modules loaded: none. Right. The problem here is that St is a type constructor with two arguments (i.e., of kind (* -> * -> *)), whereas Monad wants a type constructor with one argument (i.e., of kind (* -> *)). Hence the error. This is the same type of error you'd get if you tried to declare an instance for `Eq Tree', where `Tree' is a standard (polymorphic) BST. The way you solve that is to instantiate `Eq (Tree a)', and it's the same thing here: instantiate `Monad (St s)'. Of course, you need to switch the order of the arguments to St first (as done above), so Haskell knows `s' is a the state type, not the result type. HTH Jon Cast From oleg@pobox.com Fri Aug 9 00:43:48 2002 From: oleg@pobox.com (oleg@pobox.com) Date: Thu, 8 Aug 2002 16:43:48 -0700 (PDT) Subject: Transformations of cyclic graphs [Was: Efficiency of list indices in definitions] Message-ID: <200208082343.QAA44063@adric.fnmoc.navy.mil> [Moved to Haskell-Cafe] Hello! Cycles sure make it difficult to transform graphs in a pure non-strict language. Cycles in a source graph require us to devise a way to mark traversed nodes -- however we cannot mutate nodes and cannot even compare nodes with a generic ('derived') equality operator. Cycles in a destination graph require us to keep track of the already built nodes so we can complete a cycle. An obvious solution is to use a state monad and IORefs. There is also a monad-less solution, which is less obvious: we can't add a node to the dictionary of constructed nodes until we have built the node, then means we can't use the updated dictionary when building descendants -- which need the dictionary when linking back. The problem can be overcome however with a credit card transform (a.k.a. "buy now, pay later" transform). To avoid hitting the bottom, we just have to "pay" by the "due date". The will use as an example the NFA->DFA transformation considered earlier. Perhaps we should first attempt a few obvious optimizations of a NFA/DFA recognizer. It seems that performance matters. finAuAcceptStringQ startStates string = or [faStateAcceptStringQ s string | s <- startStates] where faStateAcceptStringQ (FaState _ acceptQ _) [] = acceptQ faStateAcceptStringQ (FaState _ _ trans) (a:as) | null followerStates = False | otherwise = or [ faStateAcceptStringQ s as | s <- followerStates ] where followerStates = if a > (length trans) - 1 then [] else trans!!a Computing (length trans) when determining the followerStates is inefficient: even if 'a' is zero, we still have to traverse the whole list 'trans'. If our alphabet is binary, perhaps its better to specialize the FaState correspondingly and write: -- Automata over a binary alphabet data (Ord l,Show l) => FaState l = FaState {label :: l, acceptQ :: Bool, trans0:: [FaState l], trans1:: [FaState l]} -- Then a finite automaton is merely a list of starting FaStates: type FinAu l = [FaState l] --So, for example, an automaton equivalent to the regular expression --0*(0(0+1)*)* could be defined as: dom18 = [one] where one = FaState 1 True [one,two] [] two = FaState 2 True [two,one] [one,two] The acceptance function can be written as finAuAcceptStringQ start_states str = foldr (\l seed -> acceptP l str || seed) False start_states where acceptP (FaState _ acceptQ _ _) [] = acceptQ acceptP (FaState _ _ t0 t1) (s:rest) = finAuAcceptStringQ (if s then t1 else t0) rest We have simplified the original expression, and manually deforested it. test1= finAuAcceptStringQ dom18 $ map (>0) [0,1,0,1] test2= finAuAcceptStringQ dom18 $ map (>0) [1,1,0,1] test3= finAuAcceptStringQ dom18 [True] test4= finAuAcceptStringQ dom18 [False] It would be great to be able to compare and print the nodes: instance (Ord l,Show l) => Eq (FaState l) where (FaState l1 _ _ _) == (FaState l2 _ _ _) = l1 == l2 but printing a node is already a slight problem. We need to keep track of the already printed nodes to avoid looping. -- a data class for an occurrence check class OCC occ where empty:: occ a seenp:: (Eq a) => a -> occ a -> Bool put:: a -> occ a -> occ a -- Currently, it's just a list. -- In the future, we can pull in something fancier from the Edison instance OCC [] where empty = [] seenp = elem put = (:) -- Depth-first, pre-order traversal of the graph, keeping track of -- already printed nodes instance (Ord l,Show l) => Show (FaState l) where show state = "{@" ++ showstates [state] (empty::[FaState l]) "@}" where -- showstates worklist seen_states suffix showstates [] states_seen suffix = suffix showstates (st:rest) states_seen suffix | st `seenp` states_seen = showstates rest states_seen suffix showstates (st@(FaState l accept t0 t1):rest) states_seen suffix = showstate st $ showstates (t0++t1++rest) (st `put` states_seen) suffix showstate (FaState l accept t0 t1) suffix = "{State " ++ (show l) ++ " " ++ (show accept) ++ " " ++ (show $ map label t0) ++ " " ++ (show $ map label t1) ++ "}" ++ suffix Now, "print dom18" prints as [{@{State 1 True [1,2] []}{State 2 True [2,1] [1,2]}@}] For the NFA->DFA conversion, we need to keep track of already built states. -- A dictionary of states class StateDict sd where emptyd :: sd (l,FaState l) locate :: (Eq l) => l -> sd (l,FaState l) -> Maybe (FaState l) putd :: (l,FaState l) -> sd (l,FaState l) -> sd (l,FaState l) -- if performance matters, we can use a fancier dictionary from the Edison instance StateDict [] where emptyd = [] locate = lookup putd = (:) -- [nfa_state] -> dictionary_of_seen_states -> ([dfa_state],updated_dictionary) -- [dfa_state] is a singleton list determinize_cc states converted_states = -- first, check the cache case dfa_label `locate` converted_states of Nothing -> build_state Just dfa_state -> ([dfa_state],converted_states) where -- [NFA_labels] -> DFA_labels det_labels = sort . nub . (map label) dfa_label = det_labels states -- find out NFA-followers for [nfa_state] upon ingestion of 0 and 1 (t0_followers,t1_followers) = foldr (\st (f0,f1) -> (trans0 st ++ f0, trans1 st ++ f1)) ([],[]) states acceptQ' = or (map acceptQ states) -- really build the dfa state and return ([dfa_state],updated_cache) build_state = let -- node, dfa_state is computed _below_ converted_states1 = (dfa_label,dfa_state) `putd` converted_states (t0', converted_states2) = (determinize_cc t0_followers converted_states1) (t1', converted_states3) = (determinize_cc t1_followers converted_states2) dfa_state = (FaState dfa_label acceptQ' t0' t1') in ([dfa_state],converted_states3) finAuDeterminize states = fst $ determinize_cc states [] At the heart of the credit card transform is the phrase converted_states1 = (dfa_label,dfa_state) `putd` converted_states we added to the dictionary of the computed states the state that we haven't built yet. Because (,) is non-strict in its arguments and `locate` is non-strict in its result, we can get away with a mere promise to "pay". We can print the DFA for dom18 to see what we've got: finAuDeterminize dom18 -- shows [{@{State [1] True [[1,2]] [[]] } {State [1,2] True [[1,2]] [[1,2]]} {State [] False [[]] [[]] }@}] which is a DFA (which happens to be minimal) recognizing (0+1)* - 1(0+1)* An example from the original message: dom19 = [one,two] where one = FaState 1 True [two] [] two = FaState 2 True [one] [one] finAuDeterminize dom19 -- shows [{@{State [1,2] True [[1,2]] [[1]] } {State [1] True [[2]] [[]] } {State [2] True [[1]] [[1]] } {State [] False [[]] [[]] }@}] which recognizes (0+1)* - (0+1)*11(0+1)* From Shawn@Garbett.org Fri Aug 9 02:16:12 2002 From: Shawn@Garbett.org (Shawn P. Garbett) Date: Thu, 8 Aug 2002 20:16:12 -0500 Subject: Modification of State Transformer In-Reply-To: <200208082233.g78MXBIl002435@localhost.localdomain> References: <200208082233.g78MXBIl002435@localhost.localdomain> Message-ID: > Btw: This has already been done, in GHC: see the ST module in GHC's > library > . This list is great. The implementation in the ST module solves the problem and I understand how it works. Shawn -- You're in a maze of twisty little statements, all alike. Public Key available from http://www.garbett.org/public-key From ajb@spamcop.net Fri Aug 9 02:54:00 2002 From: ajb@spamcop.net (Andrew J Bromage) Date: Fri, 9 Aug 2002 11:54:00 +1000 Subject: Combining type constraints Message-ID: <20020809015400.GC17064@smtp.alicorna.com> G'day all. I have a large number of functions all of which use the same set of type constraints, such as: > foo :: (Monad m, Ord t, Show t) => ... Ideally, I'd like to combine them into one typeclass. At the moment, I'm using the equivalent of: > class (Monad m, Ord t, Show t) => Constraints m t where { } > instance (Monad m, Ord t, Show t) => Constraints m t where { } > foo :: (Constraints m t) => ... This requires undecidable instances. Is there a way to do this that doesn't require non-98 features apart from multi-parameter type classes? If not, is there an argument for a language construction which supports this idiom, analogous to type synonyms, except for type classes? Cheers, Andrew Bromage From cbaratoff@xlnow.com Fri Aug 9 06:53:56 2002 From: cbaratoff@xlnow.com (Cyril Baratoff) Date: Fri, 9 Aug 2002 07:53:56 +0200 Subject: Haskell-Cafe -- confirmation of subscription -- request 321501 Message-ID: This is a multi-part message in MIME format. ------_=_NextPart_001_01C23F69.265719F0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable =20 ------_=_NextPart_001_01C23F69.265719F0 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

 

=00 ------_=_NextPart_001_01C23F69.265719F0-- From jscott@planetinternet.be Mon Aug 12 01:26:58 2002 From: jscott@planetinternet.be (Scott J.) Date: Mon, 12 Aug 2002 02:26:58 +0200 Subject: Modification of State Transformer References: <200208082233.g78MXBIl002435@localhost.localdomain> Message-ID: <005801c24196$f84b00c0$2097fea9@janxp> Hi, I invite you then to explain what happens with every step. The use of "forall" is misleading and fast to be misunderstood: I mention here the inner forall's. Thx Scott ----- Original Message ----- From: "Shawn P. Garbett" To: "Jon Cast" Cc: Sent: Friday, August 09, 2002 3:16 AM Subject: Re: Modification of State Transformer > > Btw: This has already been done, in GHC: see the ST module in GHC's > > library > > . > > This list is great. The implementation in the ST module solves the problem > and I understand how it works. > > Shawn > > > -- > You're in a maze of twisty little statements, all alike. > Public Key available from http://www.garbett.org/public-key > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From apeake@comac.com Mon Aug 12 01:36:21 2002 From: apeake@comac.com (Alex Peake) Date: Sun, 11 Aug 2002 17:36:21 -0700 Subject: Newbie question on "statefullness" Message-ID: I am new to Haskell. I want to do something very simple (I thought) but got lost in the world of Monads. I want to implement something like the C idea of: n += i So how does one doe this in Haskell? Thanks, Alex From mlc67@columbia.edu Mon Aug 12 02:50:18 2002 From: mlc67@columbia.edu (mike castleman) Date: Sun, 11 Aug 2002 21:50:18 -0400 Subject: Newbie question on "statefullness" In-Reply-To: References: Message-ID: <20020812015018.GG19910@pinetree.dhs.org> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Sun, Aug 11, 2002 at 05:36:21PM -0700, Alex Peake wrote: > n += i > > So how does one doe this in Haskell? Usually, one doesn't. What are you actually trying to accomplish? mike - -- mike castleman / mlc67@columbia.edu / http://mlcastle.net current location: sharon, ma, us columbia univ. grad student employees united: ¡sí se puede! http://www.gseu.net/ -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (GNU/Linux) iD8DBQE9VxRarbXc6n5AevkRAm/OAJ99Ly1o2i2mncZPo2khdPfYrLR6WQCgnzbv QpTyrQlZTt7H5hHVgObvmB0= =cRVI -----END PGP SIGNATURE----- From apeake@comac.com Mon Aug 12 03:03:04 2002 From: apeake@comac.com (Alex Peake) Date: Sun, 11 Aug 2002 19:03:04 -0700 Subject: Newbie question on "statefullness" In-Reply-To: <20020812015018.GG19910@pinetree.dhs.org> Message-ID: I am trying to implement a long-lived "accumulator" Alex > -----Original Message----- > From: haskell-cafe-admin@haskell.org > [mailto:haskell-cafe-admin@haskell.org]On Behalf Of mike castleman > Sent: Sunday, August 11, 2002 6:50 PM > To: haskell-cafe@haskell.org > Subject: Re: Newbie question on "statefullness" >=20 >=20 > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 >=20 > On Sun, Aug 11, 2002 at 05:36:21PM -0700, Alex Peake wrote: > > n +=3D i > >=20 > > So how does one doe this in Haskell? >=20 > Usually, one doesn't. What are you actually trying to accomplish? >=20 > mike >=20 > - --=20 > mike castleman / mlc67@columbia.edu / http://mlcastle.net > current location: sharon, ma, us > columbia univ. grad student employees united: =C2=A1s=C3=AD se puede! > http://www.gseu.net/ > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.0.7 (GNU/Linux) >=20 > iD8DBQE9VxRarbXc6n5AevkRAm/OAJ99Ly1o2i2mncZPo2khdPfYrLR6WQCgnzbv > QpTyrQlZTt7H5hHVgObvmB0=3D > =3DcRVI > -----END PGP SIGNATURE----- > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe >=20 From ajb@spamcop.net Mon Aug 12 03:23:22 2002 From: ajb@spamcop.net (Andrew J Bromage) Date: Mon, 12 Aug 2002 12:23:22 +1000 Subject: Newbie question on "statefullness" In-Reply-To: References: <20020812015018.GG19910@pinetree.dhs.org> Message-ID: <20020812022322.GA13486@smtp.alicorna.com> G'day all. On Sun, Aug 11, 2002 at 07:03:04PM -0700, Alex Peake wrote: > I am trying to implement a long-lived "accumulator" How long is long? Over what kind of code must it be preserved? In what kind of code do you want to modify it and in what kind of code do you want to read it? By "what kind", I mean things like: - Is it just needed at the "top level" of your program? - Do you need I/O (or some other monadic construction) in the same places as this accumulator or is it in different places? - What other "state" do you have? How cleanly does it separate from the rest of your code? - Is there some identifiable part of your program where the "state" is "read only", some where it is "write only" and/or some where it is "read/write"? These are important considerations. C has no automatic memory management, so you must (usually) structure your code around the lifetimes of your data. Similarly, Haskell has no automatic state, so you must (usually) structure your code around the scope of the state that you intend to simulate. Cheers, Andrew Bromage From ajb@spamcop.net Mon Aug 12 02:27:44 2002 From: ajb@spamcop.net (Andrew J Bromage) Date: Mon, 12 Aug 2002 11:27:44 +1000 Subject: Newbie question on "statefullness" In-Reply-To: References: Message-ID: <20020812012744.GA12830@smtp.alicorna.com> G'day all. On Sun, Aug 11, 2002 at 05:36:21PM -0700, Alex Peake wrote: > I am new to Haskell. I want to do something very simple (I thought) > but got lost in the world of Monads. > > I want to implement something like the C idea of: > n += i > > So how does one doe this in Haskell? I think this needs to be an FAQ. The short answer is that if you find yourself needing to do this, especially if you're new to Haskell, you're probably thinking about the problem in the wrong way. Haskell does not support the "n += i" idiom in the same way that C does not support, say, higher-order functions. The flip side is that Haskell _does_ support the "n += i" idiom in the same way that C _does_ support higher-order functions, in that with some effort (sometimes a little, sometimes a lot) you can simulate the same functionality if you find you really need it (using monads, continuations or whatever). However, most of the time where you would use this idiom in C, you would not use it in the equivalent Haskell program, simply because there's usually a more appropriate way of phrasing your intentions. Cheers, Andrew Bromage From ashley@semantic.org Mon Aug 12 07:48:06 2002 From: ashley@semantic.org (Ashley Yakeley) Date: Sun, 11 Aug 2002 23:48:06 -0700 Subject: Newbie question on "statefullness" Message-ID: <200208120648.XAA00598@mail4.halcyon.com> At 2002-08-11 17:36, Alex Peake wrote: >I want to implement something like the C idea of: >n += i > >So how does one doe this in Haskell? do { val <- readIORef n; writeIORef n (val + i); }; -- Ashley Yakeley, Seattle WA From ashley@semantic.org Mon Aug 12 09:31:09 2002 From: ashley@semantic.org (Ashley Yakeley) Date: Mon, 12 Aug 2002 01:31:09 -0700 Subject: Newbie question on "statefullness" Message-ID: <200208120831.BAA03658@mail4.halcyon.com> At 2002-08-11 23:48, I wrote: >>I want to implement something like the C idea of: >>n += i >> >>So how does one doe this in Haskell? > > do { > val <- readIORef n; > writeIORef n (val + i); > }; Or even... modifyIORef n ((+) i); -- Ashley Yakeley, Seattle WA From john@repetae.net Mon Aug 12 12:19:38 2002 From: john@repetae.net (John Meacham) Date: Mon, 12 Aug 2002 04:19:38 -0700 Subject: Newbie question on "statefullness" In-Reply-To: <20020812012744.GA12830@smtp.alicorna.com> References: <20020812012744.GA12830@smtp.alicorna.com> Message-ID: <20020812111938.GA30768@momenergy.repetae.net> grr. this used to be in a FAQ at the Wiki. whatever happened to that? The haskell wiki was just starting to pick up and gain momentum and now it disapeared. how about we migrate the content to a more stable Wiki platform? http://c2.com/cgi/wiki?WikiEngines John On Mon, Aug 12, 2002 at 11:27:44AM +1000, Andrew J Bromage wrote: > G'day all. > > On Sun, Aug 11, 2002 at 05:36:21PM -0700, Alex Peake wrote: > > > I am new to Haskell. I want to do something very simple (I thought) > > but got lost in the world of Monads. > > > > I want to implement something like the C idea of: > > n += i > > > > So how does one doe this in Haskell? > > I think this needs to be an FAQ. > > The short answer is that if you find yourself needing to do this, > especially if you're new to Haskell, you're probably thinking about > the problem in the wrong way. Haskell does not support the "n += i" > idiom in the same way that C does not support, say, higher-order > functions. > > The flip side is that Haskell _does_ support the "n += i" idiom in > the same way that C _does_ support higher-order functions, in that > with some effort (sometimes a little, sometimes a lot) you can simulate > the same functionality if you find you really need it (using monads, > continuations or whatever). However, most of the time where you > would use this idiom in C, you would not use it in the equivalent > Haskell program, simply because there's usually a more appropriate > way of phrasing your intentions. > > Cheers, > Andrew Bromage > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- --------------------------------------------------------------------------- John Meacham - California Institute of Technology, Alum. - john@foo.net --------------------------------------------------------------------------- From Shawn@Garbett.org Mon Aug 12 15:19:35 2002 From: Shawn@Garbett.org (Shawn P. Garbett) Date: Mon, 12 Aug 2002 09:19:35 -0500 Subject: Modification of State Transformer In-Reply-To: <005801c24196$f84b00c0$2097fea9@janxp> References: <200208082233.g78MXBIl002435@localhost.localdomain> <005801c24196$f84b00c0$2097fea9@janxp> Message-ID: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Sunday 11 August 2002 07:26 pm, Scott J. wrote: > Hi, > > I invite you then to explain what happens with every step. > > The use of "forall" is misleading and fast to be misunderstood: I mention > here the inner forall's. > > Thx > > Scott > > This list is great. The implementation in the ST module solves the > > problem and I understand how it works. > > > > Shawn Given the level of detailed explanations to date, I don't see the point. But I'll go ahead and do so anyway, by summarizing what I've learned from the previous posts. I had read the example in Bird'd book on state transformers. The definition of state however was a fixed type in the examples. Wanting to extend the definition and make it more general I was trying to figure out how to modify the type. Bird's definition was: newtype St a = MkSt (State -> (a,State)) type State = type I had attempted to extend the type as follows newtype St a s = MkSt (s -> (a,s)) This died in the compiler when declaring this type as an instance of Monad: instance Monad St where return x = MkSt f where f s = (x,s) p >>= q = MkSt f where f s = apply(q x) s' where (x,s') = apply p s ghc returned the following (referencing the instance line): Couldn't match `*' against `* -> *' Expected kind: (* -> *) -> * Inferred kind: (* -> * -> *) -> * When checking kinds in `Monad St' In the instance declaration for `Monad St' When a type constructor has an argument it has a type of `* -> *'. When a type constructor has two arguments it has a type of `* -> * -> *'. This construction of the type can be extended to n arguments by having the number of `->' match the n arguments of type and the `*' be n+1. The class definition of Monad contains the following: class Monad m where return :: a -> m a (>>=) :: m a -> (a -> m b) -> m b So the class of St a s needs reduction from `* -> * -> *' to `* -> *' to fit the single argument type constructor of the Monad class. By using (St a) which causes the type constructor to be of type `(* -> *) -> *'. Since `(* -> *)' can be used as `*', by creation of another type. This because equivalent to `* -> *'. The only thing left is reversing the order so that the result type is of the correct form in the Monad usage. I.e, in my initial ordering the `return' of the Monad would end up returning something of type `s' which is not particularly useful, since type `a' is the desired return type from the transformer. So the corrected version of State becomes: newtype St s a = MkSt (s -> (a, s)) instance Monad (St s) where ... Shawn Garbett - -- You're in a maze of twisty little statements, all alike. Public Key available from http://www.garbett.org/public-key -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (GNU/Linux) iD8DBQE9V8P4DtpPjAQxZ6ARAq0VAJ9toEiEm+d58vgbKEofzXBISyXrEACfasbc eaEg2zVi9y90vk+fXKGSrt0= =OrwN -----END PGP SIGNATURE----- From jscott@planetinternet.be Mon Aug 12 20:08:47 2002 From: jscott@planetinternet.be (Scott J.) Date: Mon, 12 Aug 2002 21:08:47 +0200 Subject: Fw: Modification of State Transformer Message-ID: <003301c24233$b07491b0$2097fea9@janxp> ----- Original Message ----- From: "Scott J." To: "Shawn P. Garbett" Sent: Monday, August 12, 2002 9:04 PM Subject: Re: Modification of State Transformer > I 'm sorry, > > What I meant was discussion about the state transformer ST s a itself. And > how it works. What does mean the second inner forall loop and so on. I can't > find explanations of this in the Haskell library. > > Regards > > Scott > ----- Original Message ----- > From: "Shawn P. Garbett" > To: "Scott J." > Cc: > Sent: Monday, August 12, 2002 4:19 PM > Subject: Re: Modification of State Transformer > > > > -----BEGIN PGP SIGNED MESSAGE----- > > Hash: SHA1 > > > > On Sunday 11 August 2002 07:26 pm, Scott J. wrote: > > > Hi, > > > > > > I invite you then to explain what happens with every step. > > > > > > The use of "forall" is misleading and fast to be misunderstood: I > mention > > > here the inner forall's. > > > > > > Thx > > > > > > Scott > > > > This list is great. The implementation in the ST module solves the > > > > problem and I understand how it works. > > > > > > > > Shawn > > > > Given the level of detailed explanations to date, I don't see the point. > But > > I'll go ahead and do so anyway, by summarizing what I've learned from the > > previous posts. > > > > I had read the example in Bird'd book on state transformers. The > definition > > of state however was a fixed type in the examples. Wanting to extend the > > definition and make it more general I was trying to figure out how to > modify > > the type. > > > > Bird's definition was: > > newtype St a = MkSt (State -> (a,State)) > > type State = type > > > > I had attempted to extend the type as follows > > newtype St a s = MkSt (s -> (a,s)) > > > > This died in the compiler when declaring this type as an instance of > Monad: > > instance Monad St where > > return x = MkSt f where f s = (x,s) > > p >>= q = MkSt f where f s = apply(q x) s' > > where (x,s') = apply p s > > ghc returned the following (referencing the instance line): > > Couldn't match `*' against `* -> *' > > Expected kind: (* -> *) -> * > > Inferred kind: (* -> * -> *) -> * > > When checking kinds in `Monad St' > > In the instance declaration for `Monad St' > > > > When a type constructor has an argument it has a type of `* -> *'. > > When a type constructor has two arguments it has a type of `* -> * -> *'. > > This construction of the type can be extended to n arguments by having the > > number of `->' match the n arguments of type and the `*' be n+1. > > > > The class definition of Monad contains the following: > > class Monad m where > > return :: a -> m a > > (>>=) :: m a -> (a -> m b) -> m b > > > > > > So the class of St a s needs reduction from `* -> * -> *' to `* -> *' to > fit > > the single argument type constructor of the Monad class. By using (St a) > > which causes the type constructor to be of type `(* -> *) -> *'. Since > `(* -> > > *)' can be used as `*', by creation of another type. This because > equivalent > > to `* -> *'. > > > > The only thing left is reversing the order so that the result type is of > the > > correct form in the Monad usage. I.e, in my initial ordering the `return' > of > > the Monad would end up returning something of type `s' which is not > > particularly useful, since type `a' is the desired return type from the > > transformer. > > > > So the corrected version of State becomes: > > newtype St s a = MkSt (s -> (a, s)) > > > > instance Monad (St s) where > > ... > > > > Shawn Garbett > > - -- > > You're in a maze of twisty little statements, all alike. > > Public Key available from http://www.garbett.org/public-key > > -----BEGIN PGP SIGNATURE----- > > Version: GnuPG v1.0.7 (GNU/Linux) > > > > iD8DBQE9V8P4DtpPjAQxZ6ARAq0VAJ9toEiEm+d58vgbKEofzXBISyXrEACfasbc > > eaEg2zVi9y90vk+fXKGSrt0= > > =OrwN > > -----END PGP SIGNATURE----- > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe@haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > From Shawn@Garbett.org Mon Aug 12 20:24:10 2002 From: Shawn@Garbett.org (Shawn P. Garbett) Date: Mon, 12 Aug 2002 14:24:10 -0500 Subject: Fw: Modification of State Transformer In-Reply-To: <003301c24233$b07491b0$2097fea9@janxp> References: <003301c24233$b07491b0$2097fea9@janxp> Message-ID: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Monday 12 August 2002 02:08 pm, Scott J. wrote: > ----- Original Message ----- > From: "Scott J." > > What I meant was discussion about the state transformer ST s a itself. > > And how it works. What does mean the second inner forall loop and so on. > > I can't find explanations of this in the Haskell library. Oh! If you look in the paper that's mentioned: _Lazy_Functional_State_Threads_, by John Launchbury and Simon Jones, 1994, there's a big section on this. To quote: Section 2.4 Encapsulaion "So far we have been able to combine state transformers to make larger state transformers, but how can we make a state transformer part of a larger program which does not manipulate state at all? What we need is a function, runST, with a type something like the following: runST :: ST s a -> a" "The idea is that runST takes a state transformer as its argument, conjures up an initial empty state, applies the state transformer to it, and returns the result while discarding the final state." ... Discussion of usage implications, and how this initial guess at type creates all kinds of potential usage problems ... "To put it another way, the argument of runST should no make any assumptions about what has already been allocated in the initial state, That is, runST should work regardless of what initial state it is given. So the type of runST should be: runST :: forall a . (forall s.ST s a) -> a This is not a Hindley-Milner type, because the quantifiers are not all at the top level; it is an example of rank-2 polymorphism (McCracken [1984]). Section 5.2 Types "Most of the type rules are the usual Hindley-Milner rules. The most interesting addition is the typing judgement for runST. Treating it as a language construct avoids the need to go beyond Hindley-Milner types. So rather than actually give runST the type runST :: forall a . (forall s.ST s a) -> a as suggested in the introduction, we ensure that its typing judgment has the same effect." - -- You're in a maze of twisty little statements, all alike. Public Key available from http://www.garbett.org/public-key -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (GNU/Linux) iD8DBQE9WAthDtpPjAQxZ6ARAgsqAJ9i+oIdWHvQB80xmEhugQTklOtpvQCdFbM5 ol6XOKjp7FGdM3oetPUTw+E= =+exg -----END PGP SIGNATURE----- From alistair@abayley.org Mon Aug 12 22:06:51 2002 From: alistair@abayley.org (Alistair Bayley) Date: Mon, 12 Aug 2002 22:06:51 +0100 Subject: Newbie question on "statefullness" In-Reply-To: <20020812012744.GA12830@smtp.alicorna.com> References: <20020812012744.GA12830@smtp.alicorna.com> Message-ID: This has been coming up a lot, probably because of Paul Graham's challenge: http://www.paulgraham.com/accgen.html So the answer is probably: it has to be done this way because that's what the challenge specifies. Paul's language of choice is Lisp, and he combines a higher-order function with a side-effect to give a very short and simple solution. In a side-effect free language the answer will tend to be more cumbersome, because you have to jump through some hoops to manage the state. This is certainly not a great introductory problem for someone trying to learn a _pure_ functional language. OTOH, if you want to do anything useful with any language you have to learn to do IO (and simple IO is tackled early in most languages), and therefore you must deal with Monads. I often wish that Haskell books and tutorials would introduce IO earlier; it is often near the end, in the "advanced" topics (after you've been dazzled/saturated by the magic you can do with list functions and comprehensions, and how easy it is to create abstract datatypes, and write parsers, etc...). Alistair ---- Original Message: From: Andrew J Bromage Sent: Monday 12 Aug 2002 02:27 Subject: Re: Newbie question on "statefullness" G'day all. On Sun, Aug 11, 2002 at 05:36:21PM -0700, Alex Peake wrote: > I am new to Haskell. I want to do something very simple (I thought) > but got lost in the world of Monads. > > I want to implement something like the C idea of: > n += i > > So how does one doe this in Haskell? I think this needs to be an FAQ. The short answer is that if you find yourself needing to do this, especially if you're new to Haskell, you're probably thinking about the problem in the wrong way. Haskell does not support the "n += i" idiom in the same way that C does not support, say, higher-order functions. The flip side is that Haskell _does_ support the "n += i" idiom in the same way that C _does_ support higher-order functions, in that with some effort (sometimes a little, sometimes a lot) you can simulate the same functionality if you find you really need it (using monads, continuations or whatever). However, most of the time where you would use this idiom in C, you would not use it in the equivalent Haskell program, simply because there's usually a more appropriate way of phrasing your intentions. Cheers, Andrew Bromage From simonmar@microsoft.com Tue Aug 13 12:13:17 2002 From: simonmar@microsoft.com (Simon Marlow) Date: Tue, 13 Aug 2002 12:13:17 +0100 Subject: Text in Haskell: a second proposal Message-ID: <9584A4A864BD8548932F2F88EB30D1C609FFC7AB@TVP-MSG-01.europe.corp.microsoft.com> > At 2002-08-09 03:26, Simon Marlow wrote: >=20 > >Why combine I/O and {en,de}coding? Firstly, efficiency.=20 >=20 > Hmm... surely the encoding functions can be defined efficiently? >=20 > decodeISO88591 :: [Word8] -> [Char]; > encodeISO88591 :: [Char] -> [Word8]; -- uses low octet of=20 > codepoint >=20 > You could surely define them as native functions very efficiently, if=20 > necessary. That depends what you mean by efficient: these functions represent an extra layer of intermediate list between the handle buffer and the final [Char], and furthermore they don't work with partial reads - the input has to be a lazy stream gotten from hGetContents. I don't want to be forced to use lazy I/O. > A monadic stream-transformer: >=20 > decodeStreamUTF8 :: (Monad m) =3D> m Word8 -> m Char; >=20 > hGetChar h =3D decodeStreamUTF8 (hGetWord8 h); >=20 > This works provided each Char corresponds to a contiguous block of=20 > Word8s, with no state between them. I think that includes all the=20 > standard character encoding schemes. This is better: it doesn't force you to use lazy I/O, and when specialised to the IO monad it might get decent performance. The problem is that in general I don't think you can assume the lack of state. For example: UTF-7 has a state which needs to be retained between characters, and UTF-16 and UTF-32 have an endianness state which can be changed by a special sequence at the beginning of the file. Some other encodings have states too. Cheers, Simon From paul.hudak@yale.edu Tue Aug 13 14:05:25 2002 From: paul.hudak@yale.edu (Paul Hudak) Date: Tue, 13 Aug 2002 09:05:25 -0400 Subject: Newbie question on "statefullness" References: <20020812012744.GA12830@smtp.alicorna.com> Message-ID: <3D590415.D8F15DA1@yale.edu> Alistair Bayley wrote: > OTOH, if you want to do anything useful with any language you have to > learn to do IO (and simple IO is tackled early in most languages), and > therefore you must deal with Monads. I often wish that Haskell books > and tutorials would introduce IO earlier; it is often near the end, in > the "advanced" topics (after you've been dazzled/saturated by the > magic you can do with list functions and comprehensions, and how easy > it is to create abstract datatypes, and write parsers, etc...). I agree with this. And for what it's worth, in my textbook "The Haskell School of Expression" (http://haskell.org/soe), I introduce IO on page 37, Chapter 3 (out of 350 pages and 24 chapters). This is even before I talk about polymorphism and higher-order functions! I talk about "actions" and "sequencing", and I use the do syntax, but I do not mention monads at all. Monads are introduced on page 251, Chapter 18. -Paul Hudak From listman@garbett.org Tue Aug 13 14:34:24 2002 From: listman@garbett.org (Shawn P. Garbett) Date: Tue, 13 Aug 2002 08:34:24 -0500 Subject: Newbie question on "statefullness" In-Reply-To: References: <20020812012744.GA12830@smtp.alicorna.com> Message-ID: > OTOH, if you want to do anything useful with any language you have to learn > to do IO (and simple IO is tackled early in most languages), and therefore > you must deal with Monads. I often wish that Haskell books and tutorials > would introduce IO earlier; it is often near the end, in the "advanced" > topics (after you've been dazzled/saturated by the magic you can do with > list functions and comprehensions, and how easy it is to create abstract > datatypes, and write parsers, etc...). I think the fact that IO and efficient array updates, etc., are all best (to our current knowledge) handled in a pure function language by monads shows the actual underlying complexity that is hidden in many imperative languages. I drew an analogy between a state machine and an object that contained several variables once in a conversation. Vehement denial about an object being at all like a state machine came from the other parties. After much discussion, they conceded that yes an object really was a state machine but they'd never thought about it that way. The human mind is amazing in the level of complexity that it can deal with and the computations it can perform. Hidden complexity in programming languages however has led to numerous software problems that are common throughout the industry. I just completed a project (with several others) that takes C code and crudely converts it into it's functional equivalent. The next step is to convert the output in a pseudo-language into true functional code. The number of side effects to deal with from some of the simplest expressions has been staggering. Most of the effort in the project was spent on the increment/decrement operators and switch and loop statements. Don't worry, there won't be a c2h (C -> Haskell) anytime soon for those who remember dealing with f2c (Fortran -> C) code, that's not the purpose of this project. On a side note, Stroustroup recently wrote in an article about how the "hello, world" example was starting new C++ programmers down the wrong path from the beginning. He, of course, advocated using the iostreams and then went on to show several examples of wonderful things that could be done with iostreams. Iostreams seem to be closer to a functional concept than then clib printf variations. I think the book, _Structure_and_Interpretation_of_Computer_Programs_, by Abelson and Sussman is a much better freshman text because of it's functional approach. Real solid examples about the dangers of imperative constructs. After years of warping my brain on C++ code, I'm enjoying learning the IO monad. It's starting to make sense at a much deeper level to me. Shawn Garbett From Shawn@Garbett.org Tue Aug 13 19:16:33 2002 From: Shawn@Garbett.org (Shawn P. Garbett) Date: Tue, 13 Aug 2002 13:16:33 -0500 Subject: Analyzing Efficiency Message-ID: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I've come up with three different methods of approach to solve the same problem in haskell. I would like to compare the three in terms of reductions, memory usage, and overall big O complexity. What's the quickest way to gather these stats? I usually use the ghc compiler, but also have hugs installed. The big O complexity probably has to be done by hand, but maybe there's a tool out there to do it automagically. Shawn - -- You're in a maze of twisty little statements, all alike. Public Key available from http://www.garbett.org/public-key -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (GNU/Linux) iD8DBQE9WU0BDtpPjAQxZ6ARAkTKAJ9qixYy5MT5QGyJ/95NGLNgVTECCQCfVVVV GHELk++jO8XzaWUbp/mb9Og= =MYjn -----END PGP SIGNATURE----- From Shawn@Garbett.org Tue Aug 13 19:43:05 2002 From: Shawn@Garbett.org (Shawn P. Garbett) Date: Tue, 13 Aug 2002 13:43:05 -0500 Subject: Analyzing Efficiency In-Reply-To: References: Message-ID: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Tuesday 13 August 2002 01:37 pm, you wrote: > > I would like to compare the three in terms of reductions, memory > > usage, and overall big O complexity. > > I wouldn't use number of reductions as a guide if I was you. Number of reductions does make a difference in this case, because it's a simple test problem with three equivalent implementations (in the same compiler). Nothing to create confusion like a system call, well actually all three solutions must call a set of IO calls in the same order. So I think it would make a good baseline comparison. I do agree that it's not a good general measurement of efficiency, and really doesn't reflect the scalability of the solution either (whereas big O notation would). Thanks for the heads up though. The other tips and hints you gave me are exactly what I was looking for. No I just need a huge data set to pump into so it does a significant amount of garbage collection, and memory management... Shawn Garbett - -- You're in a maze of twisty little statements, all alike. Public Key available from http://www.garbett.org/public-key -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (GNU/Linux) iD8DBQE9WVM5DtpPjAQxZ6ARAn2XAJ98Y4jNmnCocHzHEFpUM/vN3kTGmACfTnkf Vk3m8x1OYHGyckskR4DDKQo= =OWav -----END PGP SIGNATURE----- From ajb@spamcop.net Wed Aug 14 00:03:11 2002 From: ajb@spamcop.net (Andrew J Bromage) Date: Wed, 14 Aug 2002 09:03:11 +1000 Subject: Newbie question on "statefullness" In-Reply-To: References: <20020812012744.GA12830@smtp.alicorna.com> Message-ID: <20020813230311.GA1435@smtp.alicorna.com> G'day all. On Mon, Aug 12, 2002 at 10:06:51PM +0100, Alistair Bayley wrote: > OTOH, if you want to do anything useful with any language you have to learn > to do IO (and simple IO is tackled early in most languages), and therefore > you must deal with Monads. I often wish that Haskell books and tutorials > would introduce IO earlier; it is often near the end, in the "advanced" > topics (after you've been dazzled/saturated by the magic you can do with list > functions and comprehensions, and how easy it is to create abstract > datatypes, and write parsers, etc...). Being fair for a moment, most Haskell books are intended as undergraduate computer science textbooks. There are many purposes of these introductory courses, but learning a particular programming language is not one of them. You can teach a lot of computer science without getting bogged down in the details of doing IO. Cheers, Andrew Bromage From ajb@spamcop.net Wed Aug 14 00:13:37 2002 From: ajb@spamcop.net (Andrew J Bromage) Date: Wed, 14 Aug 2002 09:13:37 +1000 Subject: Haskell wiki problems In-Reply-To: <20020812111938.GA30768@momenergy.repetae.net> References: <20020812012744.GA12830@smtp.alicorna.com> <20020812111938.GA30768@momenergy.repetae.net> Message-ID: <20020813231337.GB1435@smtp.alicorna.com> G'day all. On Mon, Aug 12, 2002 at 04:19:38AM -0700, John Meacham wrote: > grr. this used to be in a FAQ at the Wiki. whatever happened to that? Unfortunately, the ReportingProblems page is one of the ones which died. It's also not in the google cache. Does anyone know who's responsible for the wiki? Cheers, Andrew Bromage From jcp@ragged.cs.yale.edu Wed Aug 14 00:25:14 2002 From: jcp@ragged.cs.yale.edu (John C. Peterson) Date: Tue, 13 Aug 2002 19:25:14 -0400 Subject: Haskell wiki problems In-Reply-To: <20020813231337.GB1435@smtp.alicorna.com> (message from Andrew J Bromage on Wed, 14 Aug 2002 09:13:37 +1000) References: <20020812012744.GA12830@smtp.alicorna.com> <20020812111938.GA30768@momenergy.repetae.net> <20020813231337.GB1435@smtp.alicorna.com> Message-ID: <200208132325.g7DNPEb28710@ragged.cs.yale.edu> Hi all. Too many people on vacation is the real problem with the wiki. Should be back in operation soon. John From ashley@semantic.org Wed Aug 14 02:55:09 2002 From: ashley@semantic.org (Ashley Yakeley) Date: Tue, 13 Aug 2002 18:55:09 -0700 Subject: Text in Haskell: a second proposal Message-ID: <200208140155.SAA13022@mail4.halcyon.com> At 2002-08-13 04:13, Simon Marlow wrote: >That depends what you mean by efficient: these functions represent an >extra layer of intermediate list between the handle buffer and the final >[Char], and furthermore they don't work with partial reads - the input >has to be a lazy stream gotten from hGetContents. For ISO-8859-1 each Char is exactly one Word8, so surely it would work fine with partial reads? decodeCharISO88591 :: Word8 -> Char; encodeCharISO88591 :: Char -> Word8; decodeISO88591 :: [Word8] -> [Char]; decodeISO88591 = fmap decodeCharISO88591; encodeISO88591 :: [Char] -> [Word8]; encodeISO88591 = fmap encodeCharISO88591; >> A monadic stream-transformer: >> >> decodeStreamUTF8 :: (Monad m) => m Word8 -> m Char; >> >> hGetChar h = decodeStreamUTF8 (hGetWord8 h); >> >> This works provided each Char corresponds to a contiguous block of >> Word8s, with no state between them. I think that includes all the >> standard character encoding schemes. > >This is better: it doesn't force you to use lazy I/O, and when >specialised to the IO monad it might get decent performance. The >problem is that in general I don't think you can assume the lack of >state. For example: UTF-7 has a state which needs to be retained >between characters, and UTF-16 and UTF-32 have an endianness state which >can be changed by a special sequence at the beginning of the file. Some >other encodings have states too. But it is possible to do this in Haskell... The rule for the many functions in the standard libraries seems to be "implement as much in Haskell as possible". Why is it any different with the file APIs? -- Ashley Yakeley, Seattle WA From ketil@ii.uib.no Wed Aug 14 07:56:46 2002 From: ketil@ii.uib.no (Ketil Z. Malde) Date: 14 Aug 2002 08:56:46 +0200 Subject: Analyzing Efficiency In-Reply-To: References: Message-ID: "Shawn P. Garbett" writes: > I've come up with three different methods of approach to solve the same > problem in haskell. I would like to compare the three in terms of reductions, > memory usage, and overall big O complexity. > > What's the quickest way to gather these stats? I don't know about quickest, but if you haven't yet tried GHC's profiling, this might be a good time to do so. Build your project, using e.g. ghc --make -prof -auto-all ... (I like to add '-hisuf p.hi -osuf p.o' in order to keep files apart from non-profiling builds, since linking with both kinds will crash your program) Then run it with ./a.out (or whatever) +RTS -p -RTS and look at the resulting file a.out.prof. Replace -p with -h to do heap profiling. Have a look at the online GHC documentation for all the details, it's pretty comprehensive and readable, IMO. -kzm -- If I haven't seen further, it is by standing in the footprints of giants From simonmar@microsoft.com Wed Aug 14 10:25:27 2002 From: simonmar@microsoft.com (Simon Marlow) Date: Wed, 14 Aug 2002 10:25:27 +0100 Subject: Analyzing Efficiency Message-ID: <9584A4A864BD8548932F2F88EB30D1C609FFC9E1@TVP-MSG-01.europe.corp.microsoft.com> > I've come up with three different methods of approach to=20 > solve the same=20 > problem in haskell. I would like to compare the three in=20 > terms of reductions,=20 > memory usage, and overall big O complexity. >=20 > What's the quickest way to gather these stats? I usually use the ghc=20 > compiler, but also have hugs installed. The big O complexity=20 > probably has to=20 > be done by hand, but maybe there's a tool out there to do it=20 > automagically. Apart from the "normal" ways (profiling, Unix 'time', GHC's +RTS -sstderr), here's another one I've been using recently: cachegrind. It's the wonderful cache profiling extension by Nick Nethercote that comes with Julian Seward's Valgrind. The great thing is that you don't even need to recompile the program - you just do 'cachegrind ', and it runs (very slowly) and outputs reliable cache statistics including how many instructions were executed. Get it from=20 http://developer.kde.org/~sewardj/ Oh, it only works on Linux BTW. Cheers, Simon From haskell-i18n@haskell.org Thu Aug 15 10:36:21 2002 From: haskell-i18n@haskell.org (Simon Marlow) Date: Thu, 15 Aug 2002 10:36:21 +0100 Subject: Text in Haskell: a second proposal Message-ID: <9584A4A864BD8548932F2F88EB30D1C609FFCCCC@TVP-MSG-01.europe.corp.microsoft.com> [ moving to haskell-i18n@haskell.org ] > For ISO-8859-1 each Char is exactly one Word8, so surely it=20 > would work fine with partial reads? >=20 > decodeCharISO88591 :: Word8 -> Char; >=20 > encodeCharISO88591 :: Char -> Word8; >=20 > decodeISO88591 :: [Word8] -> [Char]; > decodeISO88591 =3D fmap decodeCharISO88591; >=20 > encodeISO88591 :: [Char] -> [Word8]; > encodeISO88591 =3D fmap encodeCharISO88591; Sorry, I thought you were just using ISO8859-1 as an example. > >This is better: it doesn't force you to use lazy I/O, and when > >specialised to the IO monad it might get decent performance. The > >problem is that in general I don't think you can assume the lack of > >state. For example: UTF-7 has a state which needs to be retained > >between characters, and UTF-16 and UTF-32 have an endianness=20 > state which > >can be changed by a special sequence at the beginning of the=20 > file. Some > >other encodings have states too. >=20 > But it is possible to do this in Haskell... >=20 > The rule for the many functions in the standard libraries seems to be=20 > "implement as much in Haskell as possible". Why is it any=20 > different with the file APIs? I think we've lost track of the discussion here... I'll try to summarise. I think character encoding/decoding should be built-in to the I/O system. I also think there should be a low-level I/O interface that doesn't do any encoding, and high-level interfaces to the various encodings. Now, you can by all means specify the high-level I/O in terms of the low-level I/O + encodings, but I strongly suspect that implementing it that way will be expensive. Character I/O in Haskell is *already* very slow (see Doug Bagely's language shootout for evidence), and I don't want to add another factor of 2 or more to that. The point is that by building encoding into the I/O interface the implementor gets the opportunity to optimise. Cheers, Simon From Andrew.Harris@jhuapl.edu Thu Aug 15 23:54:56 2002 From: Andrew.Harris@jhuapl.edu (Harris, Andrew) Date: Thu, 15 Aug 2002 18:54:56 -0400 Subject: question about parsing integers and floats with Parsec Message-ID: <6B3C0EEAB4FED3119F5F009027DC5E9E05093F85@spacemsg3a.jhuapl.edu> Hi - This isn't a pure "Haskell" question, but I'm trying to use the Parsec library to parse out space separated numbers, which could be integers or floats and either positive or negative. I was using the "naturalOrFloat" lexeme parser from the ParsecToken module, until I realized that it doesn't seem to handle negative integers. I've been poking with trying to pair the integer and float lexeme parsers with try() blocks, but I ain't no parsing expert and am not making good progress. Any help/hints would be appreciated! thanks, -andrew --- Andrew Harris andrew.harris@jhuapl.edu From Andrew.Harris@jhuapl.edu Fri Aug 16 06:08:03 2002 From: Andrew.Harris@jhuapl.edu (Harris, Andrew) Date: Fri, 16 Aug 2002 01:08:03 -0400 Subject: question about parsing integers and floats with Parsec Message-ID: <6B3C0EEAB4FED3119F5F009027DC5E9E05093F86@spacemsg3a.jhuapl.edu> Hi - After a bit of monkeying around, it seems the following parser works to detect both integers and floats, both positive and negative. I'm sure you wizards have many better ways of doing this. Anyway here it is for your amusement: import Parsec import qualified ParsecToken as P import ParsecLanguage (emptyDef) lexer = P.makeTokenParser emptyDef integer = P.integer lexer float = P.float lexer genericgrab :: Parser (Either Integer Double) genericgrab = try ( do { n <- char '-' ; f <- float ; return (Right (-f)) } ) <|> try ( do { f <- float ; return (Right f) } ) <|> try ( do { f <- integer ; return (Left f) } ) -andrew > -----Original Message----- > From: Harris, Andrew [mailto:Andrew.Harris@jhuapl.edu] > Sent: Thursday, August 15, 2002 6:55 PM > To: 'haskell-cafe@haskell.org' > Subject: question about parsing integers and floats with Parsec > > > Hi - > > This isn't a pure "Haskell" question, but I'm trying to use the > Parsec library to parse out space separated numbers, which > could be integers > or floats and either positive or negative. I was using the > "naturalOrFloat" > lexeme parser from the ParsecToken module, until I realized > that it doesn't > seem to handle negative integers. I've been poking with > trying to pair the > integer and float lexeme parsers with try() blocks, but I > ain't no parsing > expert and am not making good progress. > > Any help/hints would be appreciated! > > thanks, > -andrew > > --- > Andrew Harris andrew.harris@jhuapl.edu > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From kort@science.uva.nl Fri Aug 16 15:29:36 2002 From: kort@science.uva.nl (Jan Kort) Date: Fri, 16 Aug 2002 16:29:36 +0200 Subject: question about parsing integers and floats with Parsec References: <6B3C0EEAB4FED3119F5F009027DC5E9E05093F85@spacemsg3a.jhuapl.edu> Message-ID: <3D5D0C50.58A9DBED@wins.uva.nl> "Harris, Andrew" wrote: > > Hi - > > This isn't a pure "Haskell" question, but I'm trying to use the > Parsec library to parse out space separated numbers, which could be integers > or floats and either positive or negative. I was using the "naturalOrFloat" > lexeme parser from the ParsecToken module, until I realized that it doesn't > seem to handle negative integers. I've been poking with trying to pair the > integer and float lexeme parsers with try() blocks, but I ain't no parsing > expert and am not making good progress. > Hi Andrew, I don't know much about Parsec, but "natural" means positive integers only. Isn't there an "integerOrFloat" ? As for the program in your other mail, "float" and "integer" contain both positive and negative numbers, so you shouldn't have to check for the minus sign. Jan From arthurb@cs.uu.nl Fri Aug 16 16:31:52 2002 From: arthurb@cs.uu.nl (Arthur Baars) Date: Fri, 16 Aug 2002 17:31:52 +0200 Subject: question about parsing integers and floats with Parsec In-Reply-To: <6B3C0EEAB4FED3119F5F009027DC5E9E05093F86@spacemsg3a.jhuapl.edu> Message-ID: Hi, Here is a solution that does not use "try". import Parsec import qualified ParsecToken as P import ParsecLanguage (emptyDef) lexer = P.makeTokenParser emptyDef -- naturalOrFloat parses a float or an integer without sign naturalOrFloat = P.naturalOrFloat lexer data Sign = Positive | Negative applySign :: Num a => Sign -> a -> a applySign Positive = id applySign Negative = negate sign :: Parser Sign sign = do { char '-' ; return Negative } <|> do { char '+' ; return Positive } <|> return Positive genericgrab :: Parser (Either Integer Double) genericgrab = do { s <- sign ; num <- naturalOrFloat ; return (case num of Right x -> Right (applySign s x) Left x -> Left (applySign s x) ) } On 16/8/02 7:08, "Harris, Andrew" wrote: > Hi - > > After a bit of monkeying around, it seems the following parser works > to detect both integers and floats, both positive and negative. I'm sure > you wizards have many better ways of doing this. Anyway here it is for your > amusement: > > import Parsec > import qualified ParsecToken as P > import ParsecLanguage (emptyDef) > > lexer = P.makeTokenParser emptyDef > integer = P.integer lexer > float = P.float lexer > > genericgrab :: Parser (Either Integer Double) > genericgrab = try ( do { n <- char '-' > ; f <- float > ; return (Right (-f)) > } > ) > <|> try ( do { f <- float > ; return (Right f) > } > ) > <|> try ( do { f <- integer > ; return (Left f) > } > ) > > -andrew > >> -----Original Message----- >> From: Harris, Andrew [mailto:Andrew.Harris@jhuapl.edu] >> Sent: Thursday, August 15, 2002 6:55 PM >> To: 'haskell-cafe@haskell.org' >> Subject: question about parsing integers and floats with Parsec >> >> >> Hi - >> >> This isn't a pure "Haskell" question, but I'm trying to use the >> Parsec library to parse out space separated numbers, which >> could be integers >> or floats and either positive or negative. I was using the >> "naturalOrFloat" >> lexeme parser from the ParsecToken module, until I realized >> that it doesn't >> seem to handle negative integers. I've been poking with >> trying to pair the >> integer and float lexeme parsers with try() blocks, but I >> ain't no parsing >> expert and am not making good progress. >> >> Any help/hints would be appreciated! >> >> thanks, >> -andrew >> >> --- >> Andrew Harris andrew.harris@jhuapl.edu >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From jscott@planetinternet.be Sat Aug 17 04:57:46 2002 From: jscott@planetinternet.be (Scott J.) Date: Sat, 17 Aug 2002 05:57:46 +0200 Subject: Question aboutthe use of an inner forall Message-ID: <003801c245a2$42068fe0$2097fea9@janxp> This is a multi-part message in MIME format. ------=_NextPart_000_0035_01C245B3.02659730 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi, It goes about the State tansformer monad ST s a. I think how it works = but as a logician the use of an internal forall is difficult to swallow. Let's first see a statement in Haskell. One can type foo :: a -> b as a function We can be not sloppy (but this = gives unnecessary clutter in the program I think) and type it as: forall a,b foo :: a -> b Now this is a statement in logic, it can be true or false.=20 However what for heaven's sake should I think of runST :: forall a ( forall s ST s a) -> a ? In logic forall x forall y statement(x.y) is equivalent to: forall y = forall x statement(x,y). Why the use of the inner forall in runST?This is not a normal function = declaration in mathematics. Since Haskell is Hindley-Milner typed and = can't use an inner forall . Why the use an inner forall. Has imagination = dried up (sorry, if this seems impolite)? Thx Scott ------=_NextPart_000_0035_01C245B3.02659730 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hi,
 
It goes about the State tansformer = monad ST=20 s a. I think how it works but as a logician the use of an = internal=20 forall is difficult to swallow.
 
Let's first see a statement = in=20 Haskell.
 
One can type foo :: a -> = b as a=20 function We can be not sloppy (but this gives unnecessary clutter in the = program=20 I think) and type it as:
 
forall a,b foo :: a = ->=20 b
Now this is a statement in logic, it = can be true or=20 false.
 
However what for heaven's sake should I = think=20 of
 
runST :: forall a ( forall s ST s a) = -> a=20 ?
 
In logic forall x forall y=20 statement(x.y) is equivalent to: forall y = forall=20 x statement(x,y).
 
Why the use of the inner forall in = runST?This is=20 not a normal function declaration in mathematics. Since Haskell is=20 Hindley-Milner typed and can't use an inner forall . Why the use an = inner=20 forall. Has imagination dried up (sorry, if this seems = impolite)?
 
Thx
 
Scott
------=_NextPart_000_0035_01C245B3.02659730-- From ashley@semantic.org Sat Aug 17 05:15:24 2002 From: ashley@semantic.org (Ashley Yakeley) Date: Fri, 16 Aug 2002 21:15:24 -0700 Subject: Question aboutthe use of an inner forall Message-ID: <200208170415.VAA26257@mail4.halcyon.com> At 2002-08-16 20:57, Scott J. wrote: >However what for heaven's sake should I think of > >runST :: forall a ( forall s ST s a) -> a ? runST :: forall a. ((forall s. ST s a) -> a) "For all a, if (for all s, (ST s a)) then a." You may apply runST to anything with a type of the form (forall s. ST s a), for any 'a'. -- Ashley Yakeley, Seattle WA From shandley_42@yahoo.com Mon Aug 19 02:07:43 2002 From: shandley_42@yahoo.com (S H) Date: Sun, 18 Aug 2002 18:07:43 -0700 (PDT) Subject: Newbie question, installing hugs on redhat 7.2 Message-ID: <20020819010743.86404.qmail@web13401.mail.yahoo.com> I'm trying to install the current version of hugs on a red hat 7.1 system (running on VMWare 2.0.1 on top of Win 2K). I downloaded the file hugs98-Dec2001-1.i386.rpm onto the freshly-installed red hat 7.1 (no other software has been installed). It complains that libreadline.so.4 is needed. The system has the package readline-4.1-9 installed which provides libreadline.so.4.1. It appears to require exactly libreadline.so.4 (not >= 4). So, I tried uninstalling readline-4.1-9 so as to install the older package but it complained (unsurprisingly) that lots of packages rely on readline so it wouldn't erase it. I could try a --force with the erase but that seems a tad drastic. Does anyone know a workaround for this, or please tell me if I'm just doing something stupid. Thanks! Simon Handley Palo Alto, CA, USA __________________________________________________ Do You Yahoo!? HotJobs - Search Thousands of New Jobs http://www.hotjobs.com From jscott@planetinternet.be Mon Aug 19 02:19:13 2002 From: jscott@planetinternet.be (Scott J.) Date: Mon, 19 Aug 2002 03:19:13 +0200 Subject: Question aboutthe use of an inner forall References: <200208170415.VAA26257@mail4.halcyon.com> Message-ID: <005901c2471e$6e897b90$2097fea9@janxp> This is a multi-part message in MIME format. ------=_NextPart_000_0056_01C2472F.316A4BC0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable A question: s is not a type variable as a isn't it? I mean a can be of = type Integer while s cannot. Regards, Scott ----- Original Message -----=20 From: "Ashley Yakeley" To: "Scott J." ; "Haskell Cafe List" = Sent: Saturday, August 17, 2002 6:15 AM Subject: Re: Question aboutthe use of an inner forall > At 2002-08-16 20:57, Scott J. wrote: >=20 > >However what for heaven's sake should I think of > > > >runST :: forall a ( forall s ST s a) -> a ? >=20 > runST :: forall a. ((forall s. ST s a) -> a) >=20 > "For all a, if (for all s, (ST s a)) then a." >=20 > You may apply runST to anything with a type of the form (forall s. ST = s=20 > a), for any 'a'. >=20 >=20 > --=20 > Ashley Yakeley, Seattle WA >=20 > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe >=20 ------=_NextPart_000_0056_01C2472F.316A4BC0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
A question: = s is=20 not a type variable as a isn't it? I mean = a=20 can be of type Integer while s cannot.
 
Regards,
 
Scott
 
 
----- Original Message -----
From: "Ashley Yakeley" <ashley@semantic.org>
To: "Scott J." <jscott@planetinternet.be>; "Haskell=20 Cafe List" <haskell-cafe@haskell.org>
Sent: Saturday, August 17, 2002 6:15=20 AM
Subject: Re: Question aboutthe use of = an inner=20 forall

> At 2002-08-16 20:57, Scott J. wrote:
>
> = >However=20 what for heaven's sake should I think of
> >
> >runST = ::=20 forall a ( forall s ST s a) -> a ?
>
>   runST :: = forall a.=20 ((forall s. ST s a) -> a)
>
> "For all a, if (for all s, = (ST s=20 a)) then a."
>
> You may apply runST to anything with a = type of the=20 form (forall s. ST s
> a), for any 'a'.
>
>
> = --=20
> Ashley Yakeley, Seattle WA
>
>=20 _______________________________________________
> Haskell-Cafe = mailing=20 list
>
Haskell-Cafe@haskell.org
>=20 http://www.haskell.org/mailman/listinfo/haskell-cafe<= BR>> ------=_NextPart_000_0056_01C2472F.316A4BC0-- From jcast@ou.edu Mon Aug 19 02:48:44 2002 From: jcast@ou.edu (Jon Cast) Date: Sun, 18 Aug 2002 20:48:44 -0500 Subject: Question aboutthe use of an inner forall In-Reply-To: Message from "Scott J." of "Mon, 19 Aug 2002 03:19:13 +0200." <005901c2471e$6e897b90$2097fea9@janxp> Message-ID: <200208190148.g7J1mirh014831@localhost.localdomain> "Scott J." wrote: > A question: s is not a type variable as a isn't it? I mean a can be > of type Integer while s cannot. Guessing at your question: a has no type (and neither does s); it /is/ a type. In Haskell, types have kinds. And, both a and s have kind *. Now then, the user can instantiate a to Integer, yes. And the user cannot instantiate s to anything---that's what the `forall' is for. runST will (theoretically) instantiate s to something. That could be Integer if the language implementors felt like it. The user of runST certainly has to be prepared for the possibility. Does that come close to answering your question? > Regards, > Scott Jon Cast From jscott@planetinternet.be Mon Aug 19 03:09:24 2002 From: jscott@planetinternet.be (Scott J.) Date: Mon, 19 Aug 2002 04:09:24 +0200 Subject: Question aboutthe use of an inner forall References: <200208190148.g7J1mirh014831@localhost.localdomain> Message-ID: <00a301c24725$713891d0$2097fea9@janxp> Still some question: Ok a is a type and Integer is a type . But a can be instantiated to integer. This comes pretty close to call a therefore a type variable. Regards Scott ----- Original Message ----- From: "Jon Cast" To: "Scott J." Cc: "Ashley Yakeley" ; Sent: Monday, August 19, 2002 3:48 AM Subject: Re: Question aboutthe use of an inner forall > "Scott J." wrote: > > A question: s is not a type variable as a isn't it? I mean a can be > > of type Integer while s cannot. > > Guessing at your question: > > a has no type (and neither does s); it /is/ a type. In Haskell, types > have kinds. And, both a and s have kind *. > > Now then, the user can instantiate a to Integer, yes. And the user > cannot instantiate s to anything---that's what the `forall' is for. > runST will (theoretically) instantiate s to something. That could be > Integer if the language implementors felt like it. The user of runST > certainly has to be prepared for the possibility. > > Does that come close to answering your question? > > > Regards, > > > Scott > > Jon Cast > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From jscott@planetinternet.be Mon Aug 19 03:15:40 2002 From: jscott@planetinternet.be (Jan Brosius) Date: Mon, 19 Aug 2002 04:15:40 +0200 Subject: Fw: Question aboutthe use of an inner forall Message-ID: <00b501c24726$5088d7f0$2097fea9@janxp> Still some question: Ok a is not a type but Integer is a type . But a can be instantiated to integer. This comes pretty close to call a therefore a type variable, Isn't it? And otherwise why writing forall a etc. Regards Scott ----- Original Message ----- From: "Scott J." To: "Jon Cast" Cc: Sent: Monday, August 19, 2002 4:09 AM Subject: Re: Question aboutthe use of an inner forall > Still some question: Ok a is a type and Integer is a type . But a can be > instantiated to integer. This comes pretty close to call a therefore a type > variable. > > Regards > > Scott > > ----- Original Message ----- > From: "Jon Cast" > To: "Scott J." > Cc: "Ashley Yakeley" ; > Sent: Monday, August 19, 2002 3:48 AM > Subject: Re: Question aboutthe use of an inner forall > > > > "Scott J." wrote: > > > A question: s is not a type variable as a isn't it? I mean a can be > > > of type Integer while s cannot. > > > > Guessing at your question: > > > > a has no type (and neither does s); it /is/ a type. In Haskell, types > > have kinds. And, both a and s have kind *. > > > > Now then, the user can instantiate a to Integer, yes. And the user > > cannot instantiate s to anything---that's what the `forall' is for. > > runST will (theoretically) instantiate s to something. That could be > > Integer if the language implementors felt like it. The user of runST > > certainly has to be prepared for the possibility. > > > > Does that come close to answering your question? > > > > > Regards, > > > > > Scott > > > > Jon Cast > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe@haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From jscott@planetinternet.be Mon Aug 19 03:19:28 2002 From: jscott@planetinternet.be (Scott J.) Date: Mon, 19 Aug 2002 04:19:28 +0200 Subject: Fw: Question aboutthe use of an inner forall Message-ID: <00c901c24726$d8b36500$2097fea9@janxp> Sorry there are two mailers on this machine Regards SCott ----- Original Message ----- From: "Jan Brosius" To: "Jon Cast" Cc: Sent: Monday, August 19, 2002 4:15 AM Subject: Fw: Question aboutthe use of an inner forall > Still some question: Ok a is not a type but Integer is a type . But a can > be > instantiated to integer. This comes pretty close to call a therefore a type > variable, Isn't it? > > And otherwise why writing forall a etc. > > Regards > > Scott > > ----- Original Message ----- > From: "Scott J." > To: "Jon Cast" > Cc: > Sent: Monday, August 19, 2002 4:09 AM > Subject: Re: Question aboutthe use of an inner forall > > > > Still some question: Ok a is a type and Integer is a type . But a can be > > instantiated to integer. This comes pretty close to call a therefore a > type > > variable. > > > > Regards > > > > Scott > > > > ----- Original Message ----- > > From: "Jon Cast" > > To: "Scott J." > > Cc: "Ashley Yakeley" ; > > Sent: Monday, August 19, 2002 3:48 AM > > Subject: Re: Question aboutthe use of an inner forall > > > > > > > "Scott J." wrote: > > > > A question: s is not a type variable as a isn't it? I mean a can be > > > > of type Integer while s cannot. > > > > > > Guessing at your question: > > > > > > a has no type (and neither does s); it /is/ a type. In Haskell, types > > > have kinds. And, both a and s have kind *. > > > > > > Now then, the user can instantiate a to Integer, yes. And the user > > > cannot instantiate s to anything---that's what the `forall' is for. > > > runST will (theoretically) instantiate s to something. That could be > > > Integer if the language implementors felt like it. The user of runST > > > certainly has to be prepared for the possibility. > > > > > > Does that come close to answering your question? > > > > > > > Regards, > > > > > > > Scott > > > > > > Jon Cast > > > _______________________________________________ > > > Haskell-Cafe mailing list > > > Haskell-Cafe@haskell.org > > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > > > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe@haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > From ashley@semantic.org Mon Aug 19 03:26:39 2002 From: ashley@semantic.org (Ashley Yakeley) Date: Sun, 18 Aug 2002 19:26:39 -0700 Subject: Question aboutthe use of an inner forall Message-ID: <200208190226.TAA07409@mail4.halcyon.com> At 2002-08-18 18:19, Scott J. wrote: >A question: s is not a type variable as a isn't it? Both are quantified type variables. But only one of those quantifiers can be placed at the top level of the expression. runST :: forall a. ((forall s. ST s a) -> a) > I mean a can be of type Integer while s cannot. Well yes, you can specialise "forall a" to Integer. So runST can be specialised to this type: runST ::[special] (forall s. ST s Integer) -> Integer ...whereas you cannot specialise "s" in the same way. Think of it in terms of logic, if for all a: f(a), then by simple specialisation f(Integer). -- Ashley Yakeley, Seattle WA From ashley@semantic.org Mon Aug 19 03:31:30 2002 From: ashley@semantic.org (Ashley Yakeley) Date: Sun, 18 Aug 2002 19:31:30 -0700 Subject: Fw: Question aboutthe use of an inner forall Message-ID: <200208190231.TAA07564@mail4.halcyon.com> At 2002-08-18 19:15, Jan Brosius wrote: >Still some question: Ok a is not a type but Integer is a type . But a can >be > instantiated to integer. This comes pretty close to call a therefore a type > variable, Isn't it? "a" is a type variable. "Integer" is a type. "forall a. a" is also a type, but frequently "forall"s at the top level are elided. -- Ashley Yakeley, Seattle WA From jscott@planetinternet.be Mon Aug 19 04:12:44 2002 From: jscott@planetinternet.be (Scott J.) Date: Mon, 19 Aug 2002 05:12:44 +0200 Subject: Question aboutthe use of an inner forall References: <200208190226.TAA07409@mail4.halcyon.com> Message-ID: <000e01c2472e$4fc34460$2097fea9@janxp> This is a multi-part message in MIME format. ------=_NextPart_000_0009_01C2473F.0CFB6930 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Ok, a and s are type variables. It may be common usage for computer = people but for someone with a math background it is difficult to call = forall a a type . In logic one expects a statement in the scope of = forall a like this (forall a) statement. The statement may or may not depend on a. So let's come backe to runST. runST ::( forall s) (ST s a )-> a So I insist what is the statement ST s a ? Scott ----- Original Message -----=20 From: "Ashley Yakeley" To: "Scott J." Cc: "Haskell Cafe List" Sent: Monday, August 19, 2002 4:26 AM Subject: Re: Question aboutthe use of an inner forall > At 2002-08-18 18:19, Scott J. wrote: >=20 > >A question: s is not a type variable as a isn't it? >=20 > Both are quantified type variables. But only one of those quantifiers = can=20 > be placed at the top level of the expression. >=20 > runST :: forall a. ((forall s. ST s a) -> a) >=20 > > I mean a can be of type Integer while s cannot. >=20 > Well yes, you can specialise "forall a" to Integer. So runST can be=20 > specialised to this type: >=20 > runST ::[special] (forall s. ST s Integer) -> Integer >=20 > ...whereas you cannot specialise "s" in the same way. Think of it in=20 > terms of logic, if for all a: f(a), then by simple specialisation=20 > f(Integer). >=20 > --=20 > Ashley Yakeley, Seattle WA >=20 >=20 ------=_NextPart_000_0009_01C2473F.0CFB6930 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Ok, a and s are type variables. It may = be common=20 usage for computer people but for someone with a math background it is = difficult=20 to call forall a a type . In logic one expects a = statement in=20 the scope of forall a like this
 
(forall a) statement. The statement may or may not = depend on=20 a.
 
So let's come backe to = runST.
 
runST ::( forall s) (ST s a )->=20 a
 
So I insist what is the = statement=20 ST s a ?
 
Scott
 
 
----- Original Message -----
From: "Ashley Yakeley" <ashley@semantic.org>
To: "Scott J." <jscott@planetinternet.be>
Cc: "Haskell Cafe List" <haskell-cafe@haskell.org>
Sent: Monday, August 19, 2002 4:26 = AM
Subject: Re: Question aboutthe use of = an inner=20 forall

> At 2002-08-18 18:19, Scott J. wrote:
>
> = >A=20 question: s is not a type variable as a isn't it?
>
> Both = are=20 quantified type variables. But only one of those quantifiers can =
> be=20 placed at the top level of the expression.
>
>    = runST=20 :: forall a. ((forall s. ST s a) -> a)
>
> > I mean a = can be=20 of type Integer while s cannot.
>
> Well yes, you can = specialise=20 "forall a" to Integer. So runST can be
> specialised to this=20 type:
>
>    runST ::[special] (forall s. ST s = Integer)=20 -> Integer
>
> ...whereas you cannot specialise "s" in = the same=20 way. Think of it in
> terms of logic, if for all a: f(a), then by = simple=20 specialisation
> f(Integer).
>
> --
> Ashley = Yakeley,=20 Seattle WA
>
>
------=_NextPart_000_0009_01C2473F.0CFB6930-- From sqrtofone@yahoo.com Mon Aug 19 04:19:47 2002 From: sqrtofone@yahoo.com (Jay Cox) Date: Sun, 18 Aug 2002 22:19:47 -0500 Subject: Question aboutthe use of an inner forall References: <200208170415.VAA26257@mail4.halcyon.com> Message-ID: <00a701c2472f$6820a4c0$0201a8c0@elaine> ----- Original Message ----- From: "Ashley Yakeley" To: "Scott J." ; "Haskell Cafe List" Sent: Friday, August 16, 2002 11:15 PM Subject: Re: Question aboutthe use of an inner forall > At 2002-08-16 20:57, Scott J. wrote: > > >However what for heaven's sake should I think of > > > >runST :: forall a ( forall s ST s a) -> a ? > > runST :: forall a. ((forall s. ST s a) -> a) > > "For all a, if (for all s, (ST s a)) then a." > > You may apply runST to anything with a type of the form (forall s. ST s > a), for any 'a'. I'm very fuzzy to the details of type theory in general so please forgive any errors. I noted the same question as Scott's when I first learned about ST threads. When you have a rank-2 polymorphic function, like runST::forall a . ( forall s . ST s a) -> a the type means the function takes an argument ***at least as polymorphic*** as (forall s . ST s (some type a independent of s)). If (runST stthread ) has type String, then stthread must at least have type ST s String. Why do you need this apparent mumbo jumbo about Rank-2 polymorphism? It insures your ST threads are threadsafe (or so I have been led to believe). You will not be able to throw a mutable reference outside of the thread. take this long interaction from ghci (the ST> is the prompt, and what follows on the same line is the code entered. For instance :type gives the type of the following code. I have separated ghci input/ouput from comments by placing # in front of the IO). #ST> :type newSTRef (3::Prelude.Int) #forall s. ST s (STRef s PrelBase.Int) The type variable a is replaced by, or a has the value of, (STRef s PrelBase.Int). but this depends on s. #ST> :type readSTRef #forall s a. STRef s a -> ST s a #ST> :type (do x<-newSTRef (3::Prelude.Int);readSTRef x) #forall s. ST s PrelBase.Int a here is replaced by PrelBase.Int. the code in the do statement is runnable with runST #ST> runST (newSTRef (3::Prelude.Int)) # #Ambiguous type variable(s) `a' in the constraint `PrelShow.Show a' #arising from use of `PrelIO.print' at #In a 'do' expression pattern binding: PrelIO.print it # #:1: # Inferred type is less polymorphic than expected # Quantified type variable `s' escapes # It is reachable from the type variable(s) `a' # which is free in the signature # Signature type: forall s. ST s a # Type to generalise: ST s1 (STRef s1 PrelBase.Int) # When checking an expression type signature # In the first argument of `runST', namely # `(newSTRef (3 :: PrelBase.Int))' # In the definition of `it': runST (newSTRef (3 :: PrelBase.Int)) above is a demonstration of how the type checking prevents using/reading/modifying references outside of the ST world. I realize this is a bit of an incomplete explanation: Some questions I would like to answer to help your comprehension but cannot due to my ignorance are: 1. how do you measure the polymorphic nature of a type so that you can say it is "at least as polymorphic"? I have a fuzzy idea and some examples (Num a => a vs. forall a . a vs. forall a . [a], etc.) but I haven't yet found out for myself a precise definition. 2. what does it mean that type variable "escapes", and why is it bad? A reasonable answer isn't popping into my head right now. Something about how the type of a program should be fully resolved pops into my head but nothing cohesive. Maybe that helps. Jay Cox From ashley@semantic.org Mon Aug 19 04:30:33 2002 From: ashley@semantic.org (Ashley Yakeley) Date: Sun, 18 Aug 2002 20:30:33 -0700 Subject: Question aboutthe use of an inner forall Message-ID: <200208190330.UAA09469@mail4.halcyon.com> At 2002-08-18 20:12, Scott J. wrote: >So let's come backe to runST. > >runST ::( forall s) (ST s a )-> a > >So I insist what is the statement ST s a ? Oh it's not really a statement, it just plays a similar role in types that statements play in logic. The comparison runs something like this: type variable variable type statement type constructor function "->" implies application derivation "forall" universal quantification type specialisation specialisation For instance, in logic if you have "A" and you have "A implies B", you can derive "B". Likewise, if you have a value of type "a", and a value of type "a -> b", by using function application you can obtain a value of type "b". The type theory has the same structure as the logic, merely a different interpretation. -- Ashley Yakeley, Seattle WA From jscott@planetinternet.be Mon Aug 19 04:41:31 2002 From: jscott@planetinternet.be (Scott J.) Date: Mon, 19 Aug 2002 05:41:31 +0200 Subject: Question aboutthe use of an inner forall References: <200208170415.VAA26257@mail4.halcyon.com> <00a701c2472f$6820a4c0$0201a8c0@elaine> Message-ID: <001f01c24732$4e99e2c0$2097fea9@janxp> This is a multi-part message in MIME format. ------=_NextPart_000_001C_01C24743.11FDECB0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Well I don't feel alone anymore. Here follows how I think runST :: (forall s. ST s a) -> a works: if a is represented by e.g. MutVar s a . Then the compiler complains = because it did find an s in the "data" represented by a. This s must = first be eliminated by some other combinators(?) .=20 I agree that something must be written for the argument of runST to warn = programmers about the possible "representations" of a. But I still have = problems that one has chosen forall. Scott ----- Original Message -----=20 From: "Jay Cox" To: "Scott J." ; "Haskell Cafe List" = Sent: Monday, August 19, 2002 5:19 AM Subject: Re: Question aboutthe use of an inner forall >=20 > ----- Original Message ----- > From: "Ashley Yakeley" > To: "Scott J." ; "Haskell Cafe List" > > Sent: Friday, August 16, 2002 11:15 PM > Subject: Re: Question aboutthe use of an inner forall >=20 >=20 > > At 2002-08-16 20:57, Scott J. wrote: > > > > >However what for heaven's sake should I think of > > > > > >runST :: forall a ( forall s ST s a) -> a ? > > > > runST :: forall a. ((forall s. ST s a) -> a) > > > > "For all a, if (for all s, (ST s a)) then a." > > > > You may apply runST to anything with a type of the form (forall s. = ST s > > a), for any 'a'. >=20 > I'm very fuzzy to the details of type theory in general so please = forgive > any errors. >=20 > I noted the same question as Scott's when I first learned about ST = threads. >=20 > When you have a rank-2 polymorphic function, like >=20 > runST::forall a . ( forall s . ST s a) -> a >=20 > the type means the function takes an argument ***at least as = polymorphic*** > as > (forall s . ST s (some type a independent of s)). If (runST stthread = ) has > type String, then stthread must at least have type ST s String. >=20 > Why do you need this apparent mumbo jumbo about Rank-2 polymorphism? = It > insures your ST threads are threadsafe (or so I have been led to = believe). > You will not be able to throw a mutable reference outside of the = thread. >=20 > take this long interaction from ghci (the ST> is the prompt, and what > follows > on the same line is the code entered. For instance :type gives the = type of > the following code. I have separated ghci input/ouput from comments = by > placing # in front of the IO). >=20 > #ST> :type newSTRef (3::Prelude.Int) > #forall s. ST s (STRef s PrelBase.Int) >=20 > The type variable a is replaced by, or a has the value of, (STRef s > PrelBase.Int). but this depends on s. >=20 > #ST> :type readSTRef > #forall s a. STRef s a -> ST s a > #ST> :type (do x<-newSTRef (3::Prelude.Int);readSTRef x) > #forall s. ST s PrelBase.Int >=20 > a here is replaced by PrelBase.Int. the code in the do statement is = runnable > with runST >=20 > #ST> runST (newSTRef (3::Prelude.Int)) > # > #Ambiguous type variable(s) `a' in the constraint `PrelShow.Show a' > #arising from use of `PrelIO.print' at > #In a 'do' expression pattern binding: PrelIO.print it > # > #:1: > # Inferred type is less polymorphic than expected > # Quantified type variable `s' escapes > # It is reachable from the type variable(s) `a' > # which is free in the signature > # Signature type: forall s. ST s a > # Type to generalise: ST s1 (STRef s1 PrelBase.Int) > # When checking an expression type signature > # In the first argument of `runST', namely > # `(newSTRef (3 :: PrelBase.Int))' > # In the definition of `it': runST (newSTRef (3 :: PrelBase.Int)) >=20 > above is a demonstration of how the type checking prevents > using/reading/modifying references outside of the ST world. >=20 > I realize this is a bit of an incomplete explanation: Some questions = I > would like to answer to help your comprehension but cannot due to my > ignorance are: >=20 > 1. how do you measure the polymorphic nature of a type so that you = can say > it is "at least as polymorphic"? I have a fuzzy idea and some examples = (Num > a =3D> a vs. forall a . a vs. forall a . [a], etc.) but I haven't = yet found > out for myself a precise definition. > 2. what does it mean that type variable "escapes", and why is it bad? = A > reasonable answer isn't popping into my head right now. Something = about how > the type of a program should be fully resolved pops into my head but = nothing > cohesive. >=20 > Maybe that helps. >=20 > Jay Cox >=20 >=20 >=20 ------=_NextPart_000_001C_01C24743.11FDECB0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Well I don't feel alone = anymore.
 
Here follows how I think runST :: = (forall s. ST s=20 a) -> a works:
 
if  a is represented  by = e.g.=20 MutVar s a . Then the compiler complains because it did = find  an s in the "data" represented by a. This=20 s must first be eliminated by some other combinators(?) = .=20
 
I agree that something must be written = for the=20 argument of runST to warn programmers about the possible = "representations" of a.=20 But I still have problems that one has chosen=20 forall.
 
Scott
 
 
----- Original Message -----
From: "Jay Cox" <sqrtofone@yahoo.com>
To: "Scott J." <jscott@planetinternet.be>; "Haskell=20 Cafe List" <haskell-cafe@haskell.org>
Sent: Monday, August 19, 2002 5:19 = AM
Subject: Re: Question aboutthe use of = an inner=20 forall

>
> ----- Original Message -----
> From: = "Ashley Yakeley"=20 <
ashley@semantic.org>
> To:=20 "Scott J." <
jscott@planetinternet.be>; "Haskell=20 Cafe List"
> <
haskell-cafe@haskell.org>
> Sent: Friday, August 16, 2002 11:15 PM
> = Subject: Re:=20 Question aboutthe use of an inner forall
>
>
> > = At=20 2002-08-16 20:57, Scott J. wrote:
> >
> > >However = what for=20 heaven's sake should I think of
> > >
> > >runST = ::=20 forall a ( forall s ST s a) -> a ?
> >
> = >  =20 runST :: forall a. ((forall s. ST s a) -> a)
> >
> = > "For=20 all a, if (for all s, (ST s a)) then a."
> >
> > You = may apply=20 runST to anything with a type of the form (forall s. ST s
> > = a), for=20 any 'a'.
>
> I'm very fuzzy to the details of type theory = in=20 general so please forgive
> any errors.
>
> I noted = the same=20 question as Scott's when I first learned about ST threads.
> =
> When=20 you have a rank-2 polymorphic function, like
>
> = runST::forall a .=20 ( forall s . ST s a) -> a
>
> the type means the = function takes=20 an argument ***at least as polymorphic***
> as
> (forall s . = ST s=20 (some type a independent of s)).  If (runST stthread ) has
> = type=20 String, then stthread must at least have type ST s String.
> =
> Why=20 do you need this apparent mumbo jumbo about Rank-2 polymorphism? =20 It
> insures your ST threads are threadsafe (or so I have been led = to=20 believe).
> You will not be able to throw a mutable reference = outside of=20 the thread.
>
> take this long interaction from  ghci = (the=20 ST> is the prompt, and what
> follows
> on the same line = is the=20 code entered.  For instance :type gives the type of
> the = following=20 code.  I have separated ghci input/ouput from comments by
> = placing #=20 in front of the IO).
>
> #ST> :type newSTRef=20 (3::Prelude.Int)
> #forall s. ST s (STRef s PrelBase.Int)
> =
>=20 The type variable a is replaced by, or a has the value of, (STRef = s
>=20 PrelBase.Int). but this depends on s.
>
> #ST> :type=20 readSTRef
> #forall s a. STRef s a -> ST s a
> #ST> = :type (do=20 x<-newSTRef (3::Prelude.Int);readSTRef x)
> #forall s. ST s=20 PrelBase.Int
>
> a here is replaced by PrelBase.Int. the = code in=20 the do statement is runnable
> with runST
>
> #ST> = runST=20 (newSTRef (3::Prelude.Int))
> #
> #Ambiguous type = variable(s) `a' in=20 the constraint `PrelShow.Show a'
> #arising from use of = `PrelIO.print' at=20 <No locn>
> #In a 'do' expression pattern binding: = PrelIO.print=20 it
> #
> #<interactive>:1:
> #    = Inferred type is less polymorphic than expected
>=20 #        Quantified type variable `s' = escapes
> #        It is = reachable from=20 the type variable(s) `a'
>=20 #          which is free in = the=20 signature
> #    Signature = type:    =20 forall s. ST s a
> #    Type to generalise: ST s1 = (STRef s1=20 PrelBase.Int)
> #    When checking an expression = type=20 signature
> #    In the first argument of `runST',=20 namely
> #        `(newSTRef (3 = ::=20 PrelBase.Int))'
> #    In the definition of `it': = runST=20 (newSTRef (3 :: PrelBase.Int))
>
> above is a demonstration = of how=20 the type checking prevents
> using/reading/modifying references = outside of=20 the ST world.
>
> I realize this is a bit of an incomplete=20 explanation:  Some questions I
> would like to answer to help = your=20 comprehension but cannot due to my
> ignorance are:
> =
> 1.=20 how do you measure the polymorphic nature of a type  so that you = can=20 say
> it is "at least as polymorphic"? I have a fuzzy idea and = some=20 examples (Num
> a =3D> a vs. forall a . a vs.  forall a . = [a],=20 etc.)  but I haven't yet found
> out for myself a precise=20 definition.
> 2. what does it mean that type variable "escapes", = and why=20 is it bad?  A
> reasonable answer isn't popping into my head = right=20 now.  Something about how
> the type of a program should be = fully=20 resolved pops into my head but nothing
> cohesive.
> =
> Maybe=20 that helps.
>
> Jay Cox
>
>
>=20
------=_NextPart_000_001C_01C24743.11FDECB0-- From jscott@planetinternet.be Mon Aug 19 04:46:29 2002 From: jscott@planetinternet.be (Scott J.) Date: Mon, 19 Aug 2002 05:46:29 +0200 Subject: Fw: Question aboutthe use of an inner forall Message-ID: <002b01c24733$00c6fbe0$2097fea9@janxp> This is a multi-part message in MIME format. ------=_NextPart_000_0028_01C24743.C432A6F0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Again a typo. Please read something like MutVar s Bool. Sorry Scott ----- Original Message -----=20 From: Scott J.=20 To: Jay Cox=20 Cc: haskell-cafe@haskell.org=20 Sent: Monday, August 19, 2002 5:41 AM Subject: Re: Question aboutthe use of an inner forall Well I don't feel alone anymore. Here follows how I think runST :: (forall s. ST s a) -> a works: if a is represented by e.g. MutVar s a . Then the compiler complains = because it did find an s in the "data" represented by a. This s must = first be eliminated by some other combinators(?) .=20 I agree that something must be written for the argument of runST to warn = programmers about the possible "representations" of a. But I still have = problems that one has chosen forall. Scott ----- Original Message -----=20 From: "Jay Cox" To: "Scott J." ; "Haskell Cafe List" = Sent: Monday, August 19, 2002 5:19 AM Subject: Re: Question aboutthe use of an inner forall >=20 > ----- Original Message ----- > From: "Ashley Yakeley" > To: "Scott J." ; "Haskell Cafe List" > > Sent: Friday, August 16, 2002 11:15 PM > Subject: Re: Question aboutthe use of an inner forall >=20 >=20 > > At 2002-08-16 20:57, Scott J. wrote: > > > > >However what for heaven's sake should I think of > > > > > >runST :: forall a ( forall s ST s a) -> a ? > > > > runST :: forall a. ((forall s. ST s a) -> a) > > > > "For all a, if (for all s, (ST s a)) then a." > > > > You may apply runST to anything with a type of the form (forall s. = ST s > > a), for any 'a'. >=20 > I'm very fuzzy to the details of type theory in general so please = forgive > any errors. >=20 > I noted the same question as Scott's when I first learned about ST = threads. >=20 > When you have a rank-2 polymorphic function, like >=20 > runST::forall a . ( forall s . ST s a) -> a >=20 > the type means the function takes an argument ***at least as = polymorphic*** > as > (forall s . ST s (some type a independent of s)). If (runST stthread = ) has > type String, then stthread must at least have type ST s String. >=20 > Why do you need this apparent mumbo jumbo about Rank-2 polymorphism? = It > insures your ST threads are threadsafe (or so I have been led to = believe). > You will not be able to throw a mutable reference outside of the = thread. >=20 > take this long interaction from ghci (the ST> is the prompt, and what > follows > on the same line is the code entered. For instance :type gives the = type of > the following code. I have separated ghci input/ouput from comments = by > placing # in front of the IO). >=20 > #ST> :type newSTRef (3::Prelude.Int) > #forall s. ST s (STRef s PrelBase.Int) >=20 > The type variable a is replaced by, or a has the value of, (STRef s > PrelBase.Int). but this depends on s. >=20 > #ST> :type readSTRef > #forall s a. STRef s a -> ST s a > #ST> :type (do x<-newSTRef (3::Prelude.Int);readSTRef x) > #forall s. ST s PrelBase.Int >=20 > a here is replaced by PrelBase.Int. the code in the do statement is = runnable > with runST >=20 > #ST> runST (newSTRef (3::Prelude.Int)) > # > #Ambiguous type variable(s) `a' in the constraint `PrelShow.Show a' > #arising from use of `PrelIO.print' at > #In a 'do' expression pattern binding: PrelIO.print it > # > #:1: > # Inferred type is less polymorphic than expected > # Quantified type variable `s' escapes > # It is reachable from the type variable(s) `a' > # which is free in the signature > # Signature type: forall s. ST s a > # Type to generalise: ST s1 (STRef s1 PrelBase.Int) > # When checking an expression type signature > # In the first argument of `runST', namely > # `(newSTRef (3 :: PrelBase.Int))' > # In the definition of `it': runST (newSTRef (3 :: PrelBase.Int)) >=20 > above is a demonstration of how the type checking prevents > using/reading/modifying references outside of the ST world. >=20 > I realize this is a bit of an incomplete explanation: Some questions = I > would like to answer to help your comprehension but cannot due to my > ignorance are: >=20 > 1. how do you measure the polymorphic nature of a type so that you = can say > it is "at least as polymorphic"? I have a fuzzy idea and some examples = (Num > a =3D> a vs. forall a . a vs. forall a . [a], etc.) but I haven't = yet found > out for myself a precise definition. > 2. what does it mean that type variable "escapes", and why is it bad? = A > reasonable answer isn't popping into my head right now. Something = about how > the type of a program should be fully resolved pops into my head but = nothing > cohesive. >=20 > Maybe that helps. >=20 > Jay Cox >=20 >=20 >=20 ------=_NextPart_000_0028_01C24743.C432A6F0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Again a typo. Please read something = like MutVar s=20 Bool. Sorry
 
Scott
 
----- Original Message -----=20
From: Scott=20 J.
To: Jay Cox
Sent: Monday, August 19, 2002 5:41 AM
Subject: Re: Question aboutthe use of an inner = forall

Well I don't feel alone = anymore.
 
Here follows how I think runST :: = (forall s. ST s=20 a) -> a works:
 
if  a is represented  by = e.g.=20 MutVar s a . Then the compiler complains because it did = find  an s in the "data" represented by a. This=20 s must first be eliminated by some other combinators(?) = .=20
 
I agree that something must be written = for the=20 argument of runST to warn programmers about the possible = "representations" of a.=20 But I still have problems that one has chosen=20 forall.
 
Scott
 
 
----- Original Message -----
From: "Jay Cox" <sqrtofone@yahoo.com>
To: "Scott J." <jscott@planetinternet.be>; "Haskell=20 Cafe List" <haskell-cafe@haskell.org>
Sent: Monday, August 19, 2002 5:19 = AM
Subject: Re: Question aboutthe use of = an inner=20 forall

>
> ----- Original Message -----
> From: = "Ashley Yakeley"=20 <
ashley@semantic.org>
> To:=20 "Scott J." <
jscott@planetinternet.be>; "Haskell=20 Cafe List"
> <
haskell-cafe@haskell.org>
> Sent: Friday, August 16, 2002 11:15 PM
> = Subject: Re:=20 Question aboutthe use of an inner forall
>
>
> > = At=20 2002-08-16 20:57, Scott J. wrote:
> >
> > >However = what for=20 heaven's sake should I think of
> > >
> > >runST = ::=20 forall a ( forall s ST s a) -> a ?
> >
> = >  =20 runST :: forall a. ((forall s. ST s a) -> a)
> >
> = > "For=20 all a, if (for all s, (ST s a)) then a."
> >
> > You = may apply=20 runST to anything with a type of the form (forall s. ST s
> > = a), for=20 any 'a'.
>
> I'm very fuzzy to the details of type theory = in=20 general so please forgive
> any errors.
>
> I noted = the same=20 question as Scott's when I first learned about ST threads.
> =
> When=20 you have a rank-2 polymorphic function, like
>
> = runST::forall a .=20 ( forall s . ST s a) -> a
>
> the type means the = function takes=20 an argument ***at least as polymorphic***
> as
> (forall s . = ST s=20 (some type a independent of s)).  If (runST stthread ) has
> = type=20 String, then stthread must at least have type ST s String.
> =
> Why=20 do you need this apparent mumbo jumbo about Rank-2 polymorphism? =20 It
> insures your ST threads are threadsafe (or so I have been led = to=20 believe).
> You will not be able to throw a mutable reference = outside of=20 the thread.
>
> take this long interaction from  ghci = (the=20 ST> is the prompt, and what
> follows
> on the same line = is the=20 code entered.  For instance :type gives the type of
> the = following=20 code.  I have separated ghci input/ouput from comments by
> = placing #=20 in front of the IO).
>
> #ST> :type newSTRef=20 (3::Prelude.Int)
> #forall s. ST s (STRef s PrelBase.Int)
> =
>=20 The type variable a is replaced by, or a has the value of, (STRef = s
>=20 PrelBase.Int). but this depends on s.
>
> #ST> :type=20 readSTRef
> #forall s a. STRef s a -> ST s a
> #ST> = :type (do=20 x<-newSTRef (3::Prelude.Int);readSTRef x)
> #forall s. ST s=20 PrelBase.Int
>
> a here is replaced by PrelBase.Int. the = code in=20 the do statement is runnable
> with runST
>
> #ST> = runST=20 (newSTRef (3::Prelude.Int))
> #
> #Ambiguous type = variable(s) `a' in=20 the constraint `PrelShow.Show a'
> #arising from use of = `PrelIO.print' at=20 <No locn>
> #In a 'do' expression pattern binding: = PrelIO.print=20 it
> #
> #<interactive>:1:
> #    = Inferred type is less polymorphic than expected
>=20 #        Quantified type variable `s' = escapes
> #        It is = reachable from=20 the type variable(s) `a'
>=20 #          which is free in = the=20 signature
> #    Signature = type:    =20 forall s. ST s a
> #    Type to generalise: ST s1 = (STRef s1=20 PrelBase.Int)
> #    When checking an expression = type=20 signature
> #    In the first argument of `runST',=20 namely
> #        `(newSTRef (3 = ::=20 PrelBase.Int))'
> #    In the definition of `it': = runST=20 (newSTRef (3 :: PrelBase.Int))
>
> above is a demonstration = of how=20 the type checking prevents
> using/reading/modifying references = outside of=20 the ST world.
>
> I realize this is a bit of an incomplete=20 explanation:  Some questions I
> would like to answer to help = your=20 comprehension but cannot due to my
> ignorance are:
> =
> 1.=20 how do you measure the polymorphic nature of a type  so that you = can=20 say
> it is "at least as polymorphic"? I have a fuzzy idea and = some=20 examples (Num
> a =3D> a vs. forall a . a vs.  forall a . = [a],=20 etc.)  but I haven't yet found
> out for myself a precise=20 definition.
> 2. what does it mean that type variable "escapes", = and why=20 is it bad?  A
> reasonable answer isn't popping into my head = right=20 now.  Something about how
> the type of a program should be = fully=20 resolved pops into my head but nothing
> cohesive.
> =
> Maybe=20 that helps.
>
> Jay Cox
>
>
>=20
------=_NextPart_000_0028_01C24743.C432A6F0-- From Malcolm.Wallace@cs.york.ac.uk Mon Aug 19 11:09:00 2002 From: Malcolm.Wallace@cs.york.ac.uk (Malcolm Wallace) Date: Mon, 19 Aug 2002 11:09:00 +0100 Subject: Newbie question, installing hugs on redhat 7.2 In-Reply-To: <20020819010743.86404.qmail@web13401.mail.yahoo.com> References: <20020819010743.86404.qmail@web13401.mail.yahoo.com> Message-ID: <20020819110900.165ed30d.Malcolm.Wallace@cs.york.ac.uk> S H writes: > I downloaded the file hugs98-Dec2001-1.i386.rpm onto > the freshly-installed red hat 7.1 (no other software > has been installed). It complains that > libreadline.so.4 is needed. The system has the > package readline-4.1-9 installed which provides > libreadline.so.4.1. It appears to require exactly > libreadline.so.4 (not >= 4). Try making a symbolic link from libreadline.so.4 to libreadline.so.4.1, i.e. cd /usr/lib; ln -s libreadline.so.4.1 libreadline.so.4 Regards, Malcolm From ashley@semantic.org Mon Aug 19 11:30:45 2002 From: ashley@semantic.org (Ashley Yakeley) Date: Mon, 19 Aug 2002 03:30:45 -0700 Subject: Question aboutthe use of an inner forall Message-ID: <200208191030.DAA20215@mail4.halcyon.com> At 2002-08-18 20:19, Jay Cox wrote: >#ST> runST (newSTRef (3::Prelude.Int)) ># >#Ambiguous type variable(s) `a' in the constraint `PrelShow.Show a' >#arising from use of `PrelIO.print' at >#In a 'do' expression pattern binding: PrelIO.print it I don't understand this either, actually: $ ghci -fglasgow-exts -package lang ___ ___ _ / _ \ /\ /\/ __(_) / /_\// /_/ / / | | GHC Interactive, version 5.04, for Haskell 98. / /_\\/ __ / /___| | http://www.haskell.org/ghc/ \____/\/ /_/\____/|_| Type :? for help. Loading package base ... linking ... done. Loading package haskell98 ... linking ... done. Loading package lang ... linking ... done. Prelude> :module ST Prelude ST> :type runST Inferred type is less polymorphic than expected Quantified type variable `s' escapes Expected type: ST s a -> t Inferred type: (forall s1. ST s1 a) -> a Prelude ST> What's up with that? Can't I even look at the type? Is this the monomorphism restriction or something? -- Ashley Yakeley, Seattle WA From alastair@reid-consulting-uk.ltd.uk Mon Aug 19 12:33:41 2002 From: alastair@reid-consulting-uk.ltd.uk (Alastair Reid) Date: 19 Aug 2002 12:33:41 +0100 Subject: Newbie question, installing hugs on redhat 7.2 In-Reply-To: <20020819010743.86404.qmail@web13401.mail.yahoo.com> References: <20020819010743.86404.qmail@web13401.mail.yahoo.com> Message-ID: > Does anyone know a workaround for this, or please tell me if I'm > just doing something stupid. It sounds like there's a problem in the RPM package since Hugs itself isn't that fussy. You could install Hugs from source yourself. 1) Download the tarfile from http://haskell.org/hugs 2) Untar it 3) cd hugs98/src/unix ./configure --prefix=$HOME --with-readline cd .. make install This should significantly less than 5 minutes. -- Alastair Reid alastair@reid-consulting-uk.ltd.uk Reid Consulting (UK) Limited http://www.reid-consulting-uk.ltd.uk/alastair/ From alastair@reid-consulting-uk.ltd.uk Mon Aug 19 12:55:27 2002 From: alastair@reid-consulting-uk.ltd.uk (Alastair Reid) Date: 19 Aug 2002 12:55:27 +0100 Subject: Question aboutthe use of an inner forall In-Reply-To: <200208190330.UAA09469@mail4.halcyon.com> References: <200208190330.UAA09469@mail4.halcyon.com> Message-ID: Ashley's comparision of types and logic misses out one important point of comparision: types logic value/expression of type T proof of logical statement T For example, consider a statement like: A /\ B => A The corresponding type is forall a,b. (a,b) -> a or, in English, for any a and b you choose, given a pair of an a and a b, I will give you an a. Now think of a and b as being proofs of a and b: for any propositions a and b you choose, given a pair of a proof of a and a proof of b, I will give you a proof of a. In other words, a function with type 'forall a,b. (a,b) -> a' can be used to construct a proof of A given a proof of A /\ B. This correspondance is known as the Curry-Howard Isomorphism. You can read a lot more about it on Phil Wadler's web page and you can read about how it applies specifically to runST on John Launchbury and Simon Peyton Jones' web pages. http://www.research.avayalabs.com/user/wadler/ http://www.cse.ogi.edu/~jl/ http://research.microsoft.com/Users/simonpj/ -- Alastair Reid alastair@reid-consulting-uk.ltd.uk Reid Consulting (UK) Limited http://www.reid-consulting-uk.ltd.uk/alastair/ Scott J. wrote: >> So let's come backe to runST. >> >> runST ::( forall s) (ST s a )-> a >> >> So I insist what is the statement ST s a ? Ashley Yakeley writes: > Oh it's not really a statement, it just plays a similar role in > types that statements play in logic. The comparison runs something > like this: > type variable variable > type statement > type constructor function > "->" implies > application derivation > "forall" universal quantification > type specialisation specialisation > For instance, in logic if you have "A" and you have "A implies B", > you can derive "B". Likewise, if you have a value of type "a", and a > value of type "a -> b", by using function application you can obtain > a value of type "b". > The type theory has the same structure as the logic, merely a > different interpretation. From lps@po.cwru.edu Mon Aug 19 18:06:59 2002 From: lps@po.cwru.edu (Leon Smith) Date: Mon, 19 Aug 2002 13:06:59 -0400 Subject: The Curry-Howard Isomorphism Message-ID: <20020819170659.31726.qmail@wedge.scl.cwru.edu> For an explanation why runST has the type it does, see page 4 of Simon Peyton-Jones and John Launchbury's paper "Lazy functional state threads" http://research.microsoft.com/Users/simonpj/Papers/lazy-functional-state-threads.ps.Z On Friday 16 August 2002 23:57, Scott J. wrote: >runST :: forall a ( forall s ST s a) -> a ? > >In logic forall x forall y statement(x.y) is equivalent to: > forall y forall x statement(x,y). True, but that isn't runST's type. "forall a" quantifies over the entire type, whereas "forall s" quantifies over the left hand side of the implication. In other words, you have "forall a. statement(a)", where statement includes a substatement "forall s. substatement(s,a)" Now, using a different argument, since "s" does not appear free on the R.H.S of the implication, "forall s" can be moved outside the implication to quantify over the entire type. However, this brings up an important point about the Curry-Howard Isomorphism, which basically says that types are statements in first-order logic, and the corresponding values are proofs of those statements. When we work in logic, we care mainly about the *statements*. Proofs are ways of justifying new statements. Equivalent statements are in a sense "equal", and can usually be freely substituted for each other. When we have a statement such as P /\ Q, where P and Q are statements such as "John is wearing a kilt" and "John is Scottish", it doesn't really matter which order they come in. Mathematicians generally understand that /\ is commutative, and thus we can use P /\ Q and Q /\ P interchangeably throughout our discussion. (Unless you are writing proofs in certain highly formal proof systems, such as Coq, Isabelle, or Haskell's type system) When we work in type theory, we care mainly about the *proofs*. Statements are ways of constraining our proofs to ensure they are at least somewhat sensible. When we have a type (Int, Char), where Int is the statement "my value is a 32-bit integer", and Char says "my value is a character", order does matter. Here, (4,'H') is a "proof" of the proposition (Int,Char), and ('H', 4) is a proof of the proposition (Char, Int). Although (Int, Char) <=> (Char, Int) are logically equivalent, (4,'H') is a different value than ('H', 4). This equivalence can be "proven" using the function: swap :: (a,b) -> (b,a) swap (x,y) = (y, x) Which, using the Curry-Howard isomorphism, is also a proof that /\ is commutative. In short, just because a type "a" implies type "b", and type "b" implies type "a", doesn't mean they are interchangeable as statements are in logic. Hope this helps, leon From jeff@galois.com Mon Aug 19 19:00:57 2002 From: jeff@galois.com (Jeffrey R Lewis) Date: Mon, 19 Aug 2002 11:00:57 -0700 Subject: Newbie question, installing hugs on redhat 7.2 In-Reply-To: References: <20020819010743.86404.qmail@web13401.mail.yahoo.com> Message-ID: <200208191100.57548.jeff@galois.com> On Monday 19 August 2002 04:33 am, Alastair Reid wrote: > > Does anyone know a workaround for this, or please tell me if I'm > > just doing something stupid. > > It sounds like there's a problem in the RPM package since Hugs itself > isn't that fussy. You could install Hugs from source yourself. Alternate approach, which works in general for RPM, assuming you have acc= ess=20 to src packages: Download the src RPM from the hugs web page=20 http://cvs.haskell.org/Hugs/downloads/hugs98-Dec2001-1.src.rpm Then, rebuild the package. This will cause the dependencies to be calcul= ated=20 based on what you have on your machine. # rpm --rebuild hugs98-Dec2001-1.src.rpm # rpm -Uvh /usr/src/redhat/RPMS/i386/hugs98-Dec2001-1.i386.rpm (Newly built packages get dumped in /usr/src/redhat/RPMS, you can change = that=20 directory, but it's probably not worth it for a one-off) --Jeff From jcast@ou.edu Mon Aug 19 19:15:40 2002 From: jcast@ou.edu (Jon Cast) Date: Mon, 19 Aug 2002 13:15:40 -0500 Subject: Fw: Question aboutthe use of an inner forall In-Reply-To: Message from Jan Brosius of "Mon, 19 Aug 2002 04:15:40 +0200." <00b501c24726$5088d7f0$2097fea9@janxp> Message-ID: <200208191815.g7JIFexE003059@localhost.localdomain> Jan Brosius wrote: > Still some question: Ok a is not a type but Integer is a type . > But a can be instantiated to integer. This comes pretty close to > call a therefore a type variable, Isn't it? > And otherwise why writing forall a etc. If s, t are types, the type s -> t says ``give me a value of type s, and I'll give you a value of type t''. If a is a type variable, and (given a is a type) s is a type, then forall a. s says ``give me a type t, and I'll give you a value of type s[t]''. More specifically, if you write > f :: a -> b f has the form (\ x :: a -> (y :: b)), where the \ binds values. If you write > f :: forall a. a f has the form (/\ a -> (x :: a)), where the /\ binds types. Now, runST's argument has type forall s. ST s a. In other words, it's essentially a function over types---and it has to take /any/ type runST wants to hand it. > Regards > Scott Jon Cast From jcast@ou.edu Mon Aug 19 19:22:41 2002 From: jcast@ou.edu (Jon Cast) Date: Mon, 19 Aug 2002 13:22:41 -0500 Subject: Question aboutthe use of an inner forall In-Reply-To: Message from "Scott J." of "Mon, 19 Aug 2002 05:12:44 +0200." <000e01c2472e$4fc34460$2097fea9@janxp> Message-ID: <200208191822.g7JIMfRR003079@localhost.localdomain> "Scott J." wrote: > Ok, a and s are type variables. It may be common usage for computer > people Bingo. You're trying to impose a non-CS understanding on a CS statement. If you're familiar with the analogy, it's like a French speaker trying to insist that ``demand'' in English cannot mean an insistence, since it doesn't mean that in English. > but for someone with a math background it is difficult Get used to difficulty. Seriously. > to call forall a a type . In logic one expects a statement in the > scope of forall a like this forall a is not a type (nor a statement) :) It's a phrase in any number of languages, including formal logic and type theory (and it has different, although cognate, meanings in those languages). > (forall a) statement. The statement may or may not depend on a. True. But if you have (forall a. type), that doesn't fit your form. And, just like (forall a. statement) is a statement, (forall a. type) is a type. Easy, no? > So let's come backe to runST. > runST ::( forall s) (ST s a )-> a May I ask a favor? If you're going to discuss type theory, learn our notation: > runST :: (forall s. ST s a) -> a Just a minor nit. > So I insist what is the statement ST s a ? It's not a statement, and forall s. is not a logic quantifier. ST s a is a type, and forall s. is a type quantifier. > Scott Jon Cast From jcast@ou.edu Mon Aug 19 19:40:25 2002 From: jcast@ou.edu (Jon Cast) Date: Mon, 19 Aug 2002 13:40:25 -0500 Subject: Question aboutthe use of an inner forall In-Reply-To: Message from Jay Cox of "Sun, 18 Aug 2002 22:19:47 CDT." <00a701c2472f$6820a4c0$0201a8c0@elaine> Message-ID: <200208191840.g7JIePXK003139@localhost.localdomain> Jay Cox wrote: > From: "Ashley Yakeley" > > At 2002-08-16 20:57, Scott J. wrote: > > >However what for heaven's sake should I think of > > >runST :: forall a ( forall s ST s a) -> a ? > > runST :: forall a. ((forall s. ST s a) -> a) > > "For all a, if (for all s, (ST s a)) then a." > > You may apply runST to anything with a type of the form (forall > > s. ST s a), for any 'a'. > I'm very fuzzy to the details of type theory in general so please > forgive any errors. > I noted the same question as Scott's when I first learned about > ST threads. > When you have a rank-2 polymorphic function, like > runST::forall a . ( forall s . ST s a) -> a > the type means the function takes an argument ***at least as > polymorphic*** as (forall s . ST s (some type a independent of s)). I'm not sure I understand polymorphic types, but here's my best guess: Polymorphic types form a sub-typing system, with the basic sub-typing judgment: (forall a. S) < [T/a]S where T and S are types, and a may occur free in S, and (<) is the sub-typing relation. From this comes the typing judgment S < T x :: S ----------------- x :: T For the purposes of runST, we only need to worry about one other judgment, the standard judgment for sub-typing function arguments: S < T ------------------- (T -> R) < (S -> R) Justification: basically, the sub-typing statement (S < T) says that every element of S is an element of T. The typing statement (f :: S -> R) says that f can take any value of type S and deliver a value of type R (divergence is a value in Haskell!). Now, if every element of S is an element of T, and f can take every element of T, it follows that f can take every element of S. (x :: S) -> (x :: T) (x :: T) -> (f x :: R) ---------------------------------------------------- (x :: S) -> (f x :: R) is an equivalent way of stating the above judgment. So, runST's types are the super-types of (forall a. (forall s. ST s a) -> a), which means all functions types for which the argument is a super-type of (forall s. ST s a). Does that clarify things any? Jon Cast From jcast@ou.edu Mon Aug 19 19:46:24 2002 From: jcast@ou.edu (Jon Cast) Date: Mon, 19 Aug 2002 13:46:24 -0500 Subject: Question aboutthe use of an inner forall In-Reply-To: Message from "Scott J." of "Mon, 19 Aug 2002 05:41:31 +0200." <001f01c24732$4e99e2c0$2097fea9@janxp> Message-ID: <200208191846.g7JIkOcB003175@localhost.localdomain> "Scott J." wrote: > Well I don't feel alone anymore. > Here follows how I think runST :: (forall s. ST s a) -> a works: > if a is represented by e.g. MutVar s a . Then the compiler complains > because it did find an s in the "data" represented by a. This s must > first be eliminated by some other combinators(?). Right. The `s' is appearing outside the area it is defined in. > I agree that something must be written for the argument of runST to > warn programmers about the possible "representations" of a. But I > still have problems that one has chosen forall. `forall' and `Pi' are the basic names for this sort of thing in type theory. See the discussion of the Howard-Curry isomorphism for `forall'. You probably don't want to know about `Pi'. > Scott Jon Cast From jscott@planetinternet.be Mon Aug 19 22:18:34 2002 From: jscott@planetinternet.be (Scott J.) Date: Mon, 19 Aug 2002 23:18:34 +0200 Subject: Question about the use of an inner forall Message-ID: <009101c247c5$fa0f47b0$2097fea9@janxp> This is a multi-part message in MIME format. ------=_NextPart_000_008E_01C247D6.BD610220 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi, I am going to stop this discussion . What counts for me at this moment = is that I know how it works.=20 I thank everybody who replied to my email. As for the discussion about Curry Howard isomorphism and more about type = theory, I shall gladly discuss these things further but than in private = email. Hey, I hope really that I know how it works but this seems to be = confirmed in these emails. I left Ocamel for Haskell for it's more functional approach.=20 I think documentation about the features extending Haskell 98 is very = needed=20 for those who want only to program with the language Haskell.=20 Thx for all replies Scott ------=_NextPart_000_008E_01C247D6.BD610220 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hi,
 
I am going to stop this discussion . = What counts=20 for me at this moment is that I know how it works.
 
I thank everybody who replied to my=20 email.
 
As for the discussion about Curry = Howard=20 isomorphism and more about type theory, I shall gladly discuss these = things=20 further but than in private email.
 
Hey, I hope really that I know how it = works but=20 this seems to be confirmed in these emails.
 
I left Ocamel for Haskell for it's more = functional=20 approach.
 
I think documentation about the = features extending=20 Haskell 98 is very needed
for those who want only to program with = the=20 language Haskell.
 
Thx for all replies
 
Scott
------=_NextPart_000_008E_01C247D6.BD610220-- From jcast@ou.edu Tue Aug 20 00:13:20 2002 From: jcast@ou.edu (Jon Cast) Date: Mon, 19 Aug 2002 18:13:20 -0500 Subject: Question about the use of an inner forall In-Reply-To: Message from "Scott J." of "Mon, 19 Aug 2002 23:18:34 +0200." <009101c247c5$fa0f47b0$2097fea9@janxp> Message-ID: <200208192313.g7JNDLmp003776@localhost.localdomain> "Scott J." wrote: > Hi, > I am going to stop this discussion . What counts for me at this > moment is that I know how it works. Alright. > I thank everybody who replied to my email. You're welcome. > As for the discussion about Curry Howard isomorphism and more about > type theory, I shall gladly discuss these things further but than in > private email. Do you mean ``but in private email''? Why? I think that, because of the strong mathematical basis underlying Haskell, these things are on-topic. So, why not let the list profit from the discussion? > Hey, I hope really that I know how it works but this seems to be > confirmed in these emails. > I left Ocamel for Haskell for it's more functional approach. > I think documentation about the features extending Haskell 98 is > very needed for those who want only to program with the > language Haskell. True; unfortunately, too many extensions are documented only in technical papers... > Thx for all replies > Scott Jon Cast From jscott@planetinternet.be Tue Aug 20 04:39:41 2002 From: jscott@planetinternet.be (Scott J.) Date: Tue, 20 Aug 2002 05:39:41 +0200 Subject: Question about sets References: <200208192313.g7JNDLmp003776@localhost.localdomain> Message-ID: <001201c247fb$37f65890$2097fea9@janxp> Well. I have a question. Why are sets not implemented in Haskell? . I have read a bit how the compiler is made. Ok lists are easier to implement but sets could have been implemented too. So why didn't the implementors not do it? Scott ----- Original Message ----- From: "Jon Cast" To: "Scott J." Cc: Sent: Tuesday, August 20, 2002 1:13 AM Subject: Re: Question about the use of an inner forall > "Scott J." wrote: > > Hi, > > > I am going to stop this discussion . What counts for me at this > > moment is that I know how it works. > > Alright. > > > I thank everybody who replied to my email. > > You're welcome. > > > As for the discussion about Curry Howard isomorphism and more about > > type theory, I shall gladly discuss these things further but than in > > private email. > > Do you mean ``but in private email''? Why? I think that, because of > the strong mathematical basis underlying Haskell, these things are > on-topic. So, why not let the list profit from the discussion? > > > Hey, I hope really that I know how it works but this seems to be > > confirmed in these emails. > > > I left Ocamel for Haskell for it's more functional approach. > > > I think documentation about the features extending Haskell 98 is > > very needed for those who want only to program with the > > language Haskell. > > True; unfortunately, too many extensions are documented only in > technical papers... > > > Thx for all replies > > > Scott > > Jon Cast > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From ajb@spamcop.net Tue Aug 20 05:13:52 2002 From: ajb@spamcop.net (Andrew J Bromage) Date: Tue, 20 Aug 2002 14:13:52 +1000 Subject: Question about sets In-Reply-To: <001201c247fb$37f65890$2097fea9@janxp> References: <200208192313.g7JNDLmp003776@localhost.localdomain> <001201c247fb$37f65890$2097fea9@janxp> Message-ID: <20020820041352.GA30931@smtp.alicorna.com> G'day all. On Tue, Aug 20, 2002 at 05:39:41AM +0200, Scott J. wrote: > I have a question. Why are sets not implemented in Haskell? . I have read a > bit how the compiler is made. Ok lists are easier to implement but sets > could have been implemented too. > So why didn't the implementors not do it? Almost certainly because the most efficient implementation of sets depends on data type and usage. For many applications, binary trees may be the most appropriate method. For others, hash tables might be better. For others, dense bit vectors and for yet others, sorted lists. Of course Haskell could have defined signatures and some implementations and left any specialist implementations up to the developer, however, the "most correct" type signatures require fundeps, which are not in Haskell 98. Incidentally, if someone wants an interesting project, Edison hasn't been touched in a while. Getting it a) fundep-compliant, b) complete and c) playing with the Monad Template Library would be a pretty useful thing. Cheers, Andrew Bromage From ketil@ii.uib.no Tue Aug 20 07:56:40 2002 From: ketil@ii.uib.no (Ketil Z. Malde) Date: 20 Aug 2002 08:56:40 +0200 Subject: Question about sets In-Reply-To: <001201c247fb$37f65890$2097fea9@janxp> References: <200208192313.g7JNDLmp003776@localhost.localdomain> <001201c247fb$37f65890$2097fea9@janxp> Message-ID: "Scott J." writes: > I have a question. Why are sets not implemented in Haskell? What do you mean? Isn't http://www.haskell.org/ghc/docs/latest/html/hslibs/set.html sufficient? (Remember to tell GHC '-package data') -kzm -- If I haven't seen further, it is by standing in the footprints of giants From la@iki.fi Tue Aug 20 08:12:03 2002 From: la@iki.fi (Lauri Alanko) Date: Tue, 20 Aug 2002 10:12:03 +0300 Subject: OT: broken mail threads Message-ID: <20020820071203.GA667@la.iki.fi> I'm sorry to bring up such petty issues, but this has been nagging me for quite a long while now... The Haskell mailing lists have one rather unflattering characteristic: their mail threads are almost always broken. I'll elaborate. Most mail user agents arrange messages in threads, keeping track of which message is a reply to which. The programs use the In-Reply-To: and References: -headers of the messages for this. By some coincidence, the various Haskell mailing lists have an uncommonly high proportion of replies which do not have these headers. As a result, many followup messages show up as a new thread in the unlucky reader's mail program, and this makes following a discussion more inconvenient. This also affects web archives of the mailing lists. The reason for these lacking headers is most likely faulty mail programs. Since programs are at fault here, not people, I won't mention names, but will simply identify the most common broken user agents. X-Mailer: Claris Emailer 2.0v3, January 22, 1998 (No threading information of any kind) X-Mimeole: Produced By Microsoft Exchange V6.0.6249.0 (Does have some very non-standard Thread-Topic: and Thread-Index: -headers, but no In-Reply-To: or References:) User-Agent: slrn/0.9.7.4 (Linux) (Apparently via a mail-news -gateway. Replies do have a References: -header, but with locally generated message-ids instead of the real ones.) There are also other messages with threading problems, but these are by far the most common sources. If you find yourself using one of these programs, could you please check your configuration or maybe consider switching to a more well-behaving user agent? This would make your messages much easier to follow. Thanks. Lauri Alanko la@iki.fi From jscott@planetinternet.be Tue Aug 20 09:36:28 2002 From: jscott@planetinternet.be (Scott J.) Date: Tue, 20 Aug 2002 10:36:28 +0200 Subject: Question about sets References: <200208192313.g7JNDLmp003776@localhost.localdomain> <001201c247fb$37f65890$2097fea9@janxp> Message-ID: <001901c24824$adcad950$2097fea9@janxp> As far a I know sets can implemented by implementing a list of anything(a list of all types) The sets Haskell does have are AFAIK sets of elements of the same type: these are not general sets. Scott ----- Original Message ----- From: "Ketil Z. Malde" To: Sent: Tuesday, August 20, 2002 8:56 AM Subject: Re: Question about sets > "Scott J." writes: > > > I have a question. Why are sets not implemented in Haskell? > > What do you mean? Isn't > > http://www.haskell.org/ghc/docs/latest/html/hslibs/set.html > > sufficient? (Remember to tell GHC '-package data') > > -kzm > -- > If I haven't seen further, it is by standing in the footprints of giants > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From jscott@planetinternet.be Tue Aug 20 09:41:31 2002 From: jscott@planetinternet.be (Scott J.) Date: Tue, 20 Aug 2002 10:41:31 +0200 Subject: Questions about sets Message-ID: <003b01c24825$61f04000$2097fea9@janxp> This is a multi-part message in MIME format. ------=_NextPart_000_0038_01C24836.255A8B80 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable As far a I know sets can implemented by implementing a list of = anything(a list of all types) The sets Haskell does have are AFAIK sets of elements = of the same type: these are not general sets. Scott ------=_NextPart_000_0038_01C24836.255A8B80 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
As far a I know=20 sets can implemented by implementing a list of anything(a
list of all = types)=20 The sets Haskell does have are AFAIK sets of elements of
the same = type: these=20 are not general sets.

Scott

------=_NextPart_000_0038_01C24836.255A8B80-- From jonatahh@hotmail.com Tue Aug 20 15:01:56 2002 From: jonatahh@hotmail.com (Jonata Goulart) Date: Tue, 20 Aug 2002 14:01:56 +0000 Subject: questions Message-ID: I'm trying to do a simple lex analyser in haskell I defined the function lexi that is intended to break a string into tokens returning them as a list but I received the following error: ERROR "TesteEval.hs":20 - Syntax error in input (unexpected symbol "restante") isLetter:: Char -> Bool isLetter c = or [isLower (c), isUpper (c)] isLetterorDigit:: Char -> Bool isLetterorDigit c = or [isLetter (c), isDigit (c)] main = lexi lexi " "= [] lexi (a:x) | isLetter a = token: lexi restante where S = takeWhile isLetterorDigit x line 20 ------> restante = dropWhile isLetterorDigit x token = 'Id' ++ S _________________________________________________________________ Chat with friends online, try MSN Messenger: http://messenger.msn.com From hdaume@ISI.EDU Tue Aug 20 16:37:17 2002 From: hdaume@ISI.EDU (Hal Daume III) Date: Tue, 20 Aug 2002 08:37:17 -0700 (PDT) Subject: questions In-Reply-To: Message-ID: There are three basic problems here. The first is the syntax error you see, the second and third will become available once you fix the syntax error. > lexi (a:x) > | isLetter a = token: lexi restante > where S = takeWhile isLetterorDigit x > line 20 ------> restante = dropWhile isLetterorDigit x > token = 'Id' ++ S So, Haskell uses a system of "layout". THis saves us from writing lots of braces and parentheses (some people don't like layout and you're free to do without it -- Ashley will probably post something along these lines). The basic idea is that without layout, you would have to write: "... where { S = takeWhile isLetterorDigit x ; restante = dropWhile isLetterorDigit x ... }" what layout allows you to do is tell the compiler where to insert these braces and semicolons implicitly. You do this by verical alignment. Basically, if a keywords like 'where' (or 'let' or 'do') is not followed by a brace, the column number at which the next identifier is found is remembered. Henceforth, as long as columns begin at that column number, they are part of the same where clause. This might be a bit tricky to grasp, but the moral is: make sure the starting column for the definition of each element in a where clause is the same. so you would write: > lexi (a:x) > | isLetter a = token: lexi restante > where S = takeWhile isLetterorDigit x > restante = dropWhile isLetterorDigit x > token = 'Id' ++ S now, the second problem. identifiers must begin with lowercase letters, so this "S" will not do. According to haskell, things that begin with a capital letter are type constructors, types, classes. So you must you "s" instead of "S". Finally, the third problem. You define: > main = lexi But this won't work. The type of lexi (once you get it working) is 'String -> [String]' but the type of main must be 'IO ()'. Presumably, you want to apply the lexer to stdin and then print the identifiers out one per line. You can do this with something like: main = interact (unlines . lexi) The function 'interact' has type (String -> String) -> IO () and what it does is read from stdin, run what it reads through the string processing function, and prints the results to stdout. Now, your function lexi has type 'String -> [String]', so this won't do. The function 'unlines' has type: [String] -> String and basically takes the list of strings, puts newlines between them, and catenates them. Finally, '.', the composition operator composes the two functions, thus producing a function of type 'String -> String' as required by interact. I hope this has made some sense. - Hal From hdaume@ISI.EDU Tue Aug 20 18:57:36 2002 From: hdaume@ISI.EDU (Hal Daume III) Date: Tue, 20 Aug 2002 10:57:36 -0700 (PDT) Subject: Question about sets In-Reply-To: <001901c24824$adcad950$2097fea9@janxp> Message-ID: Sets of arbitrary elements are not possible, because, for instance, you need to be able to compare elements to ensure no duplicates in the set and you can't do this for any arbitrary pair of types. Lists with arbitrary elements are possible, but not very useful. After all, what could you do with them? You don't know what type they are so you couldn't apply any function to them, except for a function which doesn't depend in any way on the type of its argument and hence doesn't depend on its argument at all. Any example of such lists would be: data AnyList = AnyNil | forall a . AnyCons a AnyList But I don't think this is what you really want. If you need to be able to store any two types in a list/set, use a union datatype, like: data Either a b = Left a | Right b then you can have a set of, for example, Either Int String. You can generalize this on your own. On Tue, 20 Aug 2002, Scott J. wrote: > As far a I know sets can implemented by implementing a list of anything(a > list of all types) The sets Haskell does have are AFAIK sets of elements of > the same type: these are not general sets. > > Scott > > ----- Original Message ----- > From: "Ketil Z. Malde" > To: > Sent: Tuesday, August 20, 2002 8:56 AM > Subject: Re: Question about sets > > > > "Scott J." writes: > > > > > I have a question. Why are sets not implemented in Haskell? > > > > What do you mean? Isn't > > > > http://www.haskell.org/ghc/docs/latest/html/hslibs/set.html > > > > sufficient? (Remember to tell GHC '-package data') > > > > -kzm > > -- > > If I haven't seen further, it is by standing in the footprints of giants > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe@haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From jcast@ou.edu Tue Aug 20 20:19:53 2002 From: jcast@ou.edu (Jon Cast) Date: Tue, 20 Aug 2002 14:19:53 -0500 Subject: Question about sets In-Reply-To: Message from "Scott J." of "Tue, 20 Aug 2002 10:36:28 +0200." <001901c24824$adcad950$2097fea9@janxp> Message-ID: <200208201919.g7KJJsvF009305@localhost.localdomain> "Scott J." wrote: > As far a I know sets can implemented by implementing a list of > anything(a list of all types) The sets Haskell does have are AFAIK > sets of elements of the same type: these are not general sets. Ah. That's a static typing issue. However, I don't think it's really an issue. In axiomatic set theory, every set must be a subset of some other set, except for powersets and unions. Unions are implementable using Either, and powersets are implementable using Set (i.e., powerset :: Set a -> Set (Set a)). > Scott Jon Cast From oleg@pobox.com Wed Aug 21 00:08:09 2002 From: oleg@pobox.com (oleg@pobox.com) Date: Tue, 20 Aug 2002 16:08:09 -0700 (PDT) Subject: Fw: Question about the use of an inner forall Message-ID: <200208202308.QAA74028@adric.fnmoc.navy.mil> > Leon Smith wrote: > >On Friday 16 August 2002 23:57, Scott J. wrote: > >runST :: forall a ( forall s ST s a) -> a ? > > > >In logic forall x forall y statement(x.y) is equivalent to: > > forall y forall x statement(x,y). > Now, using a different argument, since "s" does not appear free on > the R.H.S of the implication, "forall s" can be moved outside the > implication to quantify over the entire type. I'm afraid I disagree -- in general, we can't move quantifiers in and out with impunity. In our example: all a. ( (all s. ST s a) => a ) === all a. ( !(all s. ST s a) | a ) === all a. ( (exists s. !(ST s a)) | a ) === {using identity (exists x. p) | q === exists x. (p|q) where x is not free in q} === all a. (exists s. (!(ST s a) | a)) === all a. exists s. (ST s a => a) So, the type of runST is runST::exists s. (ST s a -> a) Alas, we can't use 'exists' quantifier in type expressions; therefore, we have to use the round-about trick with forall, on the _left-hand_ side of the implication. > Jon Cast wrote: > Polymorphic types form a sub-typing system, with the basic > sub-typing judgment: > (forall a. S) < [T/a]S I'd like to note a parallel with lambda-Prolog: If S is the set of type declarations and P is the set of program clauses, to prove (forall x::T. G) from , we introduce a new unique _constant_ c of type T and attempt to prove [c/x]G from OTH, to prove (exists x::T . G) from , we prove [_X/x]G from where _X is just a (unbound) Prolog variable. We let the standard unification mechanism to bind _X to something that makes G true. On the subject of escaping of quantified variables, the lambda-Prolog Tutorial by Amy Felten gives an interesting example: ?- append (1::2::nil) z X. the answer is X == (1::2::z). ?- pi y\( append (1::2::nil) y X). the answer is NO. Indeed, as outlined before, we first choose a unique constant k and attempt to prove ?- append (1::2::nil) k X. The proof seemingly succeeds, with X bound to (1::2::k). However, this binding causes 'k' to 'escape'. Therefore, this binding is rejected, and the proof falls apart. Which indeed makes sense: the value of X that makes pi y\( append (1::2::nil) y X) true should not depend on any particular value of y. Only in this case the expression would be true for all y. ?- pi y\( append (1::2::nil) y (H y)). actually succeeds, with H bound to w\(1::2::w). From jonatahh@hotmail.com Wed Aug 21 01:00:18 2002 From: jonatahh@hotmail.com (Jonata Goulart) Date: Wed, 21 Aug 2002 00:00:18 +0000 Subject: Leical and syntactic analyzer Message-ID: Does somebody know where can I find an example of a lexical and syntactic analyzer for arithmetic and conditional statements in Haskell? Thanks _________________________________________________________________ Chat with friends online, try MSN Messenger: http://messenger.msn.com From ajb@spamcop.net Wed Aug 21 04:19:13 2002 From: ajb@spamcop.net (Andrew J Bromage) Date: Wed, 21 Aug 2002 13:19:13 +1000 Subject: Question about sets In-Reply-To: References: <001901c24824$adcad950$2097fea9@janxp> Message-ID: <20020821031913.GA7576@smtp.alicorna.com> G'day all. On Tue, Aug 20, 2002 at 10:57:36AM -0700, Hal Daume III wrote: > Lists with arbitrary > elements are possible, but not very useful. After all, what could you do > with them? It's often useful to have containers of arbitrary _constrained_ types, because then you can do something with them. For example, given the class of partial mappings on orderable keys: class (Ord k) => Map m k v | m -> k v where lookupM :: m -> k -> Maybe v instance (Ord k) => Map (FiniteMap k v) k v where lookupM = lookupFM instance (Ord k) => Map [(k,v)] k v where lookupM m k = case [ v | (k',v) <- m, k == k' ] of [] -> Nothing (v:_) -> Just v instance (Ord k) => Map (k -> Maybe v) k v where lookupM = id You can make a list of elements, which can be any type so long as they are a member of that class: data MAP k v = forall m. (Map m k v) => MAP m type ListOfMap k v = [MAP k v] Then you can do things with it: lookupLom :: (Ord k) => ListOfMap k v -> k -> [ Maybe v ] lookupLom xs k = [ lookupM a k | MAP a <- xs ] test :: [Maybe Int] test = lookupLom maps 1 where maps = [ MAP finiteMap, MAP assocListMap, MAP functionMap ] finiteMap = listToFM [(1,2)] assocListMap = [(1,3)] functionMap = \k -> if k == 1 then Just 4 else Nothing It's a little unfortunate that you have to introduce the MAP type here. You can in fact construct a list of this type: type ListOfMap k v = [ forall m. (Map m k v) => m ] But then you can't use the elements in the list because the Haskell type checker can't find the (Map m k v) constraint. Cheers, Andrew Bromage From simonmar@microsoft.com Wed Aug 21 13:22:26 2002 From: simonmar@microsoft.com (Simon Marlow) Date: Wed, 21 Aug 2002 13:22:26 +0100 Subject: broken mail threads In-Reply-To: <20020820071203.GA667@la.iki.fi> Message-ID: <9584A4A864BD8548932F2F88EB30D1C60909F88E@TVP-MSG-01.europe.corp.microsoft.com> [ off-topic ] > I'm sorry to bring up such petty issues, but this has been nagging me > for quite a long while now... > > The Haskell mailing lists have one rather unflattering characteristic: > their mail threads are almost always broken. [... snip ...] > X-Mimeole: Produced By Microsoft Exchange V6.0.6249.0 > (Does have some very non-standard Thread-Topic: and Thread-Index: > -headers, but no In-Reply-To: or References:) Exchange removes In-Reply-To: headers from messages (either that or Outlook doesn't generate them when it talks to an Exchange server). Fortunately we also have an SMTP server here, and it's possible to coax Outlook into using that instead of Exchange for sending mail. Let's see if this works... Cheers, Simon From simon.guest@roke.co.uk Wed Aug 21 14:31:05 2002 From: simon.guest@roke.co.uk (Guest, Simon) Date: Wed, 21 Aug 2002 14:31:05 +0100 Subject: Question about use of | in a class declaration Message-ID: <76C92FBBFB58D411AE760090271ED418040CA3A1@rsys002a.roke.co.uk> This is a multi-part message in MIME format. --------------InterScan_NT_MIME_Boundary Content-Type: text/plain; charset="iso-8859-1" Hello all, Please could someone explain the meaning of | in this class declaration (from Andrew's example): class (Ord k) => Map m k v | m -> k v where lookupM :: m -> k -> Maybe v I couldn't find reference to this in any of my standard Haskell tutorials, nor the Haskell 98 report. Any references? cheers, Simon -----Original Message----- From: Andrew J Bromage [mailto:ajb@spamcop.net] Sent: 21 August 2002 04:19 To: haskell-cafe@haskell.org Subject: Re: Question about sets G'day all. On Tue, Aug 20, 2002 at 10:57:36AM -0700, Hal Daume III wrote: > Lists with arbitrary > elements are possible, but not very useful. After all, what could you do > with them? It's often useful to have containers of arbitrary _constrained_ types, because then you can do something with them. For example, given the class of partial mappings on orderable keys: class (Ord k) => Map m k v | m -> k v where lookupM :: m -> k -> Maybe v instance (Ord k) => Map (FiniteMap k v) k v where lookupM = lookupFM instance (Ord k) => Map [(k,v)] k v where lookupM m k = case [ v | (k',v) <- m, k == k' ] of [] -> Nothing (v:_) -> Just v instance (Ord k) => Map (k -> Maybe v) k v where lookupM = id You can make a list of elements, which can be any type so long as they are a member of that class: data MAP k v = forall m. (Map m k v) => MAP m type ListOfMap k v = [MAP k v] Then you can do things with it: lookupLom :: (Ord k) => ListOfMap k v -> k -> [ Maybe v ] lookupLom xs k = [ lookupM a k | MAP a <- xs ] test :: [Maybe Int] test = lookupLom maps 1 where maps = [ MAP finiteMap, MAP assocListMap, MAP functionMap ] finiteMap = listToFM [(1,2)] assocListMap = [(1,3)] functionMap = \k -> if k == 1 then Just 4 else Nothing It's a little unfortunate that you have to introduce the MAP type here. You can in fact construct a list of this type: type ListOfMap k v = [ forall m. (Map m k v) => m ] But then you can't use the elements in the list because the Haskell type checker can't find the (Map m k v) constraint. Cheers, Andrew Bromage _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe --------------InterScan_NT_MIME_Boundary Content-Type: text/plain; name="RMRL-Disclaimer.txt" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="RMRL-Disclaimer.txt" Registered Office: Roke Manor Research Ltd, Siemens House, Oldbury, Bracknell, Berkshire. RG12 8FZ The information contained in this e-mail and any attachments is confidential to Roke Manor Research Ltd and must not be passed to any third party without permission. This communication is for information only and shall not create or change any contractual relationship. --------------InterScan_NT_MIME_Boundary-- From hdaume@ISI.EDU Wed Aug 21 15:39:29 2002 From: hdaume@ISI.EDU (Hal Daume III) Date: Wed, 21 Aug 2002 07:39:29 -0700 (PDT) Subject: Question about use of | in a class declaration In-Reply-To: <76C92FBBFB58D411AE760090271ED418040CA3A1@rsys002a.roke.co.uk> Message-ID: This is a functional dependency. You can probably find informationin the GHC docs. It's a way of telling the compiler how to derive type information on multiparameter classes. For example, if I have a class: class C a b where f :: a -> b the type of f is (C a b) => a -> b The problem here is that you may have multiple instances of C with the same a: instance C Int Bool ... instance C Int Char ... so when you use f, it doesn't know which instance to use. Writing 'a -> b' means "a uniquely determines b" and makes it so for any given a, you can only have one instance of C, so the two above instances would be rejected: you could only have one. This means that when you write 'f (5::Int)' it knows which instance to choose, since there can only be one. - Hal -- Hal Daume III "Computer science is no more about computers | hdaume@isi.edu than astronomy is about telescopes." -Dijkstra | www.isi.edu/~hdaume On Wed, 21 Aug 2002, Guest, Simon wrote: > Hello all, > > Please could someone explain the meaning of | in this class declaration (from Andrew's example): > > class (Ord k) => Map m k v | m -> k v where > lookupM :: m -> k -> Maybe v > > I couldn't find reference to this in any of my standard Haskell tutorials, nor the Haskell 98 report. Any references? > > cheers, > Simon > > -----Original Message----- > From: Andrew J Bromage [mailto:ajb@spamcop.net] > Sent: 21 August 2002 04:19 > To: haskell-cafe@haskell.org > Subject: Re: Question about sets > > > G'day all. > > On Tue, Aug 20, 2002 at 10:57:36AM -0700, Hal Daume III wrote: > > > Lists with arbitrary > > elements are possible, but not very useful. After all, what could you do > > with them? > > It's often useful to have containers of arbitrary _constrained_ types, > because then you can do something with them. For example, given the > class of partial mappings on orderable keys: > > class (Ord k) => Map m k v | m -> k v where > lookupM :: m -> k -> Maybe v > > > instance (Ord k) => Map (FiniteMap k v) k v where > lookupM = lookupFM > > instance (Ord k) => Map [(k,v)] k v where > lookupM m k = case [ v | (k',v) <- m, k == k' ] of > [] -> Nothing > (v:_) -> Just v > > instance (Ord k) => Map (k -> Maybe v) k v where > lookupM = id > > You can make a list of elements, which can be any type so long as > they are a member of that class: > > data MAP k v = forall m. (Map m k v) => MAP m > > type ListOfMap k v = [MAP k v] > > Then you can do things with it: > > lookupLom :: (Ord k) => ListOfMap k v -> k -> [ Maybe v ] > lookupLom xs k = [ lookupM a k | MAP a <- xs ] > > test :: [Maybe Int] > test > = lookupLom maps 1 > where > maps = [ MAP finiteMap, MAP assocListMap, MAP functionMap ] > finiteMap = listToFM [(1,2)] > assocListMap = [(1,3)] > functionMap = \k -> if k == 1 then Just 4 else Nothing > > It's a little unfortunate that you have to introduce the MAP type here. > You can in fact construct a list of this type: > > type ListOfMap k v = [ forall m. (Map m k v) => m ] > > But then you can't use the elements in the list because the Haskell > type checker can't find the (Map m k v) constraint. > > Cheers, > Andrew Bromage > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From karczma@info.unicaen.fr Wed Aug 21 16:13:53 2002 From: karczma@info.unicaen.fr (Jerzy Karczmarczuk) Date: Wed, 21 Aug 2002 17:13:53 +0200 Subject: Question about use of | in a class declaration References: Message-ID: <3D63AE31.80EE744D@info.unicaen.fr> Hal Daume III wrote: > > This is a functional dependency. You can probably find informationin the > GHC docs. It's a way of telling the compiler how to derive type > information on multiparameter classes. Oh, can you? Here what the User's Guide says: > Functional dependencies are implemented as described by Mark Jones in > "Type Classes with Functional Dependencies", Mark P. Jones, In Proceedings > of the 9th European Symposium on Programming, ESOP 2000, Berlin, Germany, > March 2000, Springer-Verlag LNCS 1782. > > There should be more documentation, but there isn't (yet). Yell if you need it. Folks, let's yell together! This is a nice feature. It SHOULD be better known. If Simon's team has no time to write it, perhaps it would be nice to put the reference to Mark's paper on line? http://www.cse.ogi.edu/~mpj/pubs/fundeps.html Jerzy Karczmarczuk Caen, France From simonmar@microsoft.com Wed Aug 21 16:56:29 2002 From: simonmar@microsoft.com (Simon Marlow) Date: Wed, 21 Aug 2002 16:56:29 +0100 Subject: Question about use of | in a class declaration In-Reply-To: <3D63AE31.80EE744D@info.unicaen.fr> Message-ID: <9584A4A864BD8548932F2F88EB30D1C60909F892@TVP-MSG-01.europe.corp.microsoft.com> > Here what the User's Guide says: > > > Functional dependencies are implemented as described by > Mark Jones in > > "Type Classes with Functional Dependencies", Mark P. Jones, > In Proceedings > > of the 9th European Symposium on Programming, ESOP 2000, > Berlin, Germany, > > March 2000, Springer-Verlag LNCS 1782. > > > > There should be more documentation, but there isn't (yet). > Yell if you need it. > > Folks, let's yell together! > This is a nice feature. It SHOULD be better known. > If Simon's team has no time to write it, perhaps it would be > nice to put the reference to Mark's paper on line? > http://www.cse.ogi.edu/~mpj/pubs/fundeps.html I've put the above link in the docs. Cheers, Simon From sievers@math2.nat.tu-bs.de Wed Aug 21 17:54:01 2002 From: sievers@math2.nat.tu-bs.de (Christian Sievers) Date: Wed, 21 Aug 2002 18:54:01 +0200 Subject: Question about use of | in a class declaration In-Reply-To: <76C92FBBFB58D411AE760090271ED418040CA3A1@rsys002a.roke.co.uk> References: <76C92FBBFB58D411AE760090271ED418040CA3A1@rsys002a.roke.co.uk> Message-ID: <15715.50601.219795.743703@gauss05.math2.nat.tu-bs.de> Simon Guest asked: > Please could someone explain the meaning of | in this class declaration (from Andrew's example): > > class (Ord k) => Map m k v | m -> k v where > lookupM :: m -> k -> Maybe v > > I couldn't find reference to this in any of my standard Haskell tutorials, nor the Haskell 98 report. Any references? It might not have become clear from the previous answers: this construction is not Haskell 98, but an extension. That's why it's not in the report. BTW: Already multi parameter type classes (such as "class (Ord k) => Map m k v where ...") ^ ^ ^ only one type variable allowed here aren't Haskell 98. All the best Christian Sievers From mark@chaos.x-philes.com Wed Aug 21 19:46:16 2002 From: mark@chaos.x-philes.com (Mark Carroll) Date: Wed, 21 Aug 2002 14:46:16 -0400 (EDT) Subject: Question about use of | in a class declaration In-Reply-To: <15715.50601.219795.743703@gauss05.math2.nat.tu-bs.de> Message-ID: On Wed, 21 Aug 2002, Christian Sievers wrote: (snip) > It might not have become clear from the previous answers: > this construction is not Haskell 98, but an extension. > That's why it's not in the report. (snip) One issue we have here is that any Haskell we write is stuff we'll probably want to keep using for a while so, although we've only just got most of the bugs out of the H98 report, I'll certainly watch with interest as people come to a consensus about multi-parameter typeclasses, concurrency libraries, etc. and such things start to look very much like they'll be fixed in the next round of standardisation. It's hard to know which are experiments that ultimately will be shunned in favour of something else, and which are just all-round good ideas. (-: -- Mark From ru@river.org Wed Aug 21 20:05:48 2002 From: ru@river.org (Richard Uhtenwoldt) Date: Wed, 21 Aug 2002 12:05:48 -0700 Subject: monads, modules, sandboxes In-Reply-To: References: Message-ID: this will be my last message on this topic as I need to stop reading this list for a few months. Alastair Reid writes: >A potential difference (which Richard Uhtenwoldt hints at) is that it >can be hard to control the flow of OS capabilities as the capability >is passed from one process to another to another. This gets >especially tricky when you want policies like 'X can either read files >or use the network but not both' (so X cannot leak secrets learnt from >the filesystem). I think this is why capability OSs have fallen out >of favour in the OS community. I suspect that typesystems are better >able to express and enforce these policies. seems to me capabilities can do that: you just pass to X a capability (pointer) to an object that will return either a read-only capability to the filesystem or a capability to the network inferface but not both. either that or use the revocable-capability pattern twice in such a way that before the first network access happens, the filesystem capability is revoked and before the first filesystem read happens the network access capability is revoked. to flesh out that first alternative a little, the object passed to X could probably be coded up by modifying the following E language function (found at http://www.erights.org/elang/concurrency/race.html) for making "use-once" capabilities. and yes I realize this code is not exactly the essence of conciseness and brevity. > A "once" of a function is a use-once version of that function. Ie, > "once(func)" returns a object that will forward no more than one "run" > message to "func". The two argument form "once(verb, target)" is a > generalization which will forward no more than one "verb" message to > the target. > > For the Miranda Methods, the result of the once (the forwarder > below) must make good decisions about whether to override them and > possibly forward them, or not override them and let them default to > methods on the forwarder. For non-Miranda methods other than the > suppressed method, they are simply forwarded. > > def once { > to (verb, target) :any { > var used := false > def forwarder { > # use the Miranda order/3, though it shouldn't matter > > # use the Miranda optSealedDispatch/1 to protect the target > > # forward getAllegedType/0, though one could argue that, once > # used up, the type shouldn't include the supressed verb > to getAllegedType() :any { > target getAllegedType() > } > > # forward respondsTo, but supress verb. One could argue that res pondsTo > # and getAllegedType() should be consistent with each other. > to respondsTo(verb2, arity) :boolean { > verb != verb2 && target respondsTo(verb2, arity) > } > > # forward printOn/1 > to printOn(out) { target printOn(out) } > > # forward reactToLostClient > to reactToLostClient(problem) { > target reactToLostClient(problem) > } > > # use the Miranda whenMoreResolved/1 to protect the target > > # use the Miranda whenBroken/1 to protect the target > > # use the Miranda yourself/0 to protect the target > > # handle all other messages > match [verb2, args] { > if (verb == verb2) { > if (used) { > throw("used up") > } > used := true > } > E call(target, verb2, args) > } > } > } > > # default to suppressing "run" > to (target) :any { once("run", target) } > } what follows is not so much an explanation as a series of disconnected points that a bright and motivated reader might infer real knowledge from. point 1. I observe that type-systems work is very abstract and formal and if I were doing a type system for secure programming I would definitely look to the capability literature for conceptual guidance. too easy when doing formal work to lose sight of where the juicy "wins" (opportunities) lie and more generally to lose sight of the economic and social implications of the technical work and to start playing a sterile "glass bead game". insight and vision is where the capability literature is very fertile. here I'm speaking of the capability PL literature (much of which is ultimately based on Hewitt) not the older capability OS literature (eg Butler Lampson's paper from the early 1970s) which is all intertwined with hairy OS implementation issues and takes forever to learn, it seems to this languages geek. point 2. Alastair Reid writes: >> I now think the >> body of ideas around capability PLs (again mostly dynamically-typed >> OOPLs these days) is likely to be richer and more scientifically >> fertile for the long term than FP even. > >Can you say more about why you think OOP works better in this regard? >Is it because: >- the only way to act on them is via methods (I'm ignoring most > C++ features and public Java fields here) that is one of the things I like. on the E language list they say that certain languages have the AYCDISAM -- All You Can Do Is Send A Message -- property, which means you can always interpose a new object of arbitary behaviour between any two extant objects --a next level of modularity beyond the ADT. many capability PLs have the AYCDISAM property. the question comes up under AYCDISAM of how can you ever be sure you are talking to the real Bank of America (say) when there can be an arbitrary number of objects on the Network between you and the thing you think is the Bank of America object. note that simply asking a third object, eg, the Federal Reserve object, simply moves the problem. the solution is all elegant and subtle. in fact, ISTR it took bright folk years to figure out. "took years to figure out" is a big turn off to practical programmers, but to me, who would rather be a theoretical physicist than a programmer except programming is more economically important, it is a reccommendation when I can learn relatively few very subtle concepts (of the quality that they took years for a bright group to figure out) rather than many many many tedious uninspiring ungeneralizable details as in say most Linux software. point 3. I judge that it would be much easier (than say Linux) to be the system administrator of a complex "software environment" written to capability principles. you have more control over the environment because each individual software package (each of which is a kind of "guest of the system admin") has less control. for more see http://cap-lore.com/CapTheory/Politics.html point 4. the intellectual framework that underlies much of the capability PLs --Hewitt's Actors model -- is protean enough so that people have written articles that "redo" much of *physics* in Actors terminology and primitives. such protean-ness speaks well for fertility. in summary, I plan to keep on concentrating on the pure FP world because I calculate that it is more certain to gain (slowly: FP is not the Internet of 1993 by a long shot) in economic importance than the capability PL world is. the capability (PL and OS) stuff is either going to explode or remain obscure with obsure being the more likely fate next 6 years, and that makes for unreliable career planning. oh how cynical I have become! -- Richard Uhtenwoldt "It's a mammal thing; you wouldn't understand." From ajb@spamcop.net Thu Aug 22 01:34:38 2002 From: ajb@spamcop.net (Andrew J Bromage) Date: Thu, 22 Aug 2002 10:34:38 +1000 Subject: Question about use of | in a class declaration In-Reply-To: References: <15715.50601.219795.743703@gauss05.math2.nat.tu-bs.de> Message-ID: <20020822003438.GA17150@smtp.alicorna.com> G'day all. On Wed, Aug 21, 2002 at 02:46:16PM -0400, Mark Carroll wrote: > One issue we have here is that any Haskell we write is stuff we'll > probably want to keep using for a while so, although we've only just got > most of the bugs out of the H98 report, I'll certainly watch with interest > as people come to a consensus about multi-parameter typeclasses, > concurrency libraries, etc. and such things start to look very much like > they'll be fixed in the next round of standardisation. It's hard to know > which are experiments that ultimately will be shunned in favour of > something else, and which are just all-round good ideas. (-: Apart from the mailing lists, there are two forums which are sort of used for this. One is the wiki: http://haskell.org/wiki/wiki?HaskellTwo ...which, as those of us who use it regularly know, is down at the moment. The other is the Haskell Wish List: http://www.pms.informatik.uni-muenchen.de/forschung/haskell-wish-list/ ...which has also been down for some time. Clearly whichever malevolent forces are responsible for downtime don't want Haskell to evolve. :-) Cheers, Andrew Bromage From ajb@spamcop.net Thu Aug 22 02:29:47 2002 From: ajb@spamcop.net (Andrew J Bromage) Date: Thu, 22 Aug 2002 11:29:47 +1000 Subject: Question about use of | in a class declaration In-Reply-To: <76C92FBBFB58D411AE760090271ED418040CA3A1@rsys002a.roke.co.uk> References: <76C92FBBFB58D411AE760090271ED418040CA3A1@rsys002a.roke.co.uk> Message-ID: <20020822012947.GB17150@smtp.alicorna.com> G'day all. On Wed, Aug 21, 2002 at 02:31:05PM +0100, Guest, Simon wrote: > Please could someone explain the meaning of | in this class > declaration (from Andrew's example): > > class (Ord k) => Map m k v | m -> k v where > lookupM :: m -> k -> Maybe v Others have answered the question about what it means. However, this doesn't explain why I used a fundep when Haskell has perfectly good constructor classes. I could have written: class (Ord k) => Map m k v where lookupM :: m k v -> k -> Maybe v instance (Ord k) => Map FiniteMap k v where lookupM = lookupFM However, this would not work for the other two cases (the assoc list and the function). For that, I'd have to introduce a new type, such as: newtype MapFunc k v = MapFunc (k -> Maybe v) instance (Ord k) => Map MapFunc k v where lookupM (MapFunc f) = f A good Haskell compiler would optimise the representation of the type, so it wouldn't cost much (or possibly _anything_) at run time, but it's still a pain to program with. You need to pack and unpack the MapFunc type at awkward places, when all you really want to do is rearrange type variables for one declaration. Fundeps let you avoid many of these "artificial" constructors. Unfortunately, I don't think that fundeps will help you to get rid of all of them. For example, the standard state transformer monad: newtype State s a = State { runState :: s -> (a, s) } I don't think you can get rid of the constructor here. Cheers, Andrew Bromage From MERVE@SEX.COM Fri Aug 23 02:40:09 2002 From: MERVE@SEX.COM (MERVE@SEX.COM) Date: Thu, 22 Aug 2002 21:40:09 -0400 Subject: Videolarım - 3 Message-ID: <200208230140.g7N1e9O28376@ensim.rackshack.net> www.PembeliSex.com Bu bolumun ozelligi Gercek liseli 18-19'lik kizlardan olusmasidir. Arsiv cok buyuktur yaklasik 20bin resim vardir. Bu bolume ulasmak icin bize uye olmaniz gerekmektedir. Ücretsiz üyelik için alttaki küçük programı indirip çalıştırın ! http://www.pembelisex.com/sex.exe # Flash Haberler # http://www.pembelisex.com sizlere daha iyi hizmet verebilmesi için kredi kartlı ve formaliteli üyelikleri kaldırmıştır. Artık yapmanız gereken 35 kb lık bir programı bilgisayarınıza yüklemek ve bu programı üzerini çift tıklıyarak açmaktır. Bu programı açtığınızda bu programın sizi hem pembelisex.com arşivine hemde daha bir çok paralı porno ve mp3 gibi sitelere girebilmenizi sağlıyacaktır, programı açtıktan sonra programın altında AGREE buttonuna tıklamanız ve 30 sn gibi kısa bir süre beklemenizdir. http://www.pembelisex.com/sex.exe Bu program kendisi otomatik olarak bizim arşivimize sizi ulaştırıcaktır. NOT: Programı kullanırken sizin bağlantınızı kesicektir bunda korkulucak birşey yok sedece sizin bağlantınızı kesip bağlantı olmadan kendi özel işlemleriyle hem daha hızlı hemde her sayfaya dilediğiniz gibi girebilme özgürlüğü sağlıyacaktır... Hepinize iyi eğlenceler PembeliSex.com http://www.pembelisex.com/sex.exe Canli Sex yapmak istermisin?? http://www.pembelisex.net adresindeyim, bekliyorum.... http://www.pembelisex.net www.pembelisex.net 100 de 100 Ev Yapımı Canlı Videolar Tamamıyla Ucretsiz Bayanlar Kendi Videolarını cektiler www.pembelisex.net Vede SOK SOK SOK Ortaokulda Kızı Sikktiler Gizli Kamereda YAKALANDILAR!!! KIZ LISESINDE 15 yasında ögrencileri sikken Hocalar www.pembelisex.net Hepsi GErcek Videolar SEXXE DOYACAKSINIZ www.pembelisex.net http://www.pembelisex.net http://www.pembelisex.net http://www.pembelisex.net -11 GB LIK DEV LOLIA FILM VE FOTO ARSIVI- -TURKIYI'NIN EN BUYUK LOLITA ARSIVI- YAPMANIZ GEREKEN SADECE ANAHTAR PROGRAMI INDIRIP CALISTIRMAK! http://www.pembelisex.net ADRESINDE !!!!! SOK! SOOK! SOK! LAETSTA CASTANIN MESHUR OLMADAN CEKTIRDIGI 2 VIDEOSU(47 DK SESLI) iLK KEZ http://www.pembelisex.com/sex.exe http://www.pembelisex.net SOK 2 ! JENNIFER LOPEZ IN PORNOSU KREDi KARTI YOK SIFRE YOK SADECE ARACI PROGRAMLA 3 DAKIKADA EKRANINIZDA http://www.pembelisex.net http://www.pembelisex.com/sex.exe -------------------------------------------------------------------- From jcast@ou.edu Thu Aug 22 16:31:01 2002 From: jcast@ou.edu (Jon Cast) Date: Thu, 22 Aug 2002 10:31:01 -0500 Subject: Leical and syntactic analyzer In-Reply-To: Message from Jonata Goulart of "Wed, 21 Aug 2002 00:00:18 -0000." Message-ID: <200208221531.g7MFV1wG001999@cate2-91.reshall.ou.edu> Jonata Goulart wrote: > Does somebody know where can I find an example of a lexical and > syntactic analyzer for arithmetic and conditional statements > in Haskell? > Thanks hslibs/hssource in the ghc source (). Jon Cast From la@iki.fi Thu Aug 22 19:33:23 2002 From: la@iki.fi (Lauri Alanko) Date: Thu, 22 Aug 2002 21:33:23 +0300 Subject: broken mail threads In-Reply-To: <9584A4A864BD8548932F2F88EB30D1C60909F88E@TVP-MSG-01.europe.corp.microsoft.com> References: <20020820071203.GA667@la.iki.fi> <9584A4A864BD8548932F2F88EB30D1C60909F88E@TVP-MSG-01.europe.corp.microsoft.com> Message-ID: <20020822183323.GA1145@la.iki.fi> On Wed, Aug 21, 2002 at 01:22:26PM +0100, Simon Marlow wrote: > Exchange removes In-Reply-To: headers from messages (either that or > Outlook doesn't generate them when it talks to an Exchange server). Apparently it removes some other (less important) headers as well, such as X-Mailer. > Fortunately we also have an SMTP server here, and it's possible to coax > Outlook into using that instead of Exchange for sending mail. Let's see > if this works... It works great. Thanks a lot. Lauri Alanko la@iki.fi From info@bulent.net Sat Aug 24 21:57:36 2002 From: info@bulent.net (info) Date: Sat, 24 Aug 2002 23:57:36 +0300 Subject: Reklam Vermek İçin Servet Ödemeyin Message-ID: <20020824205735.6FE0B422072@www.haskell.org> Reklam Vermek =DD=E7in Servet =D6demeyin =B7=09Art=FDk =E7ok daha ucuza ve masrafs=FDz nas=FDl m=FD =3F =B7=097 milyon T=FCrk kullan=FDc=FDs=FDna =FEirketinizin tan=FDt=FDm=FDn=FD yaparak =B7=09Arama motorlar=FDna kay=FDt ettirerek =B7=09400=2E000=2E000 milyon yabanc=FD kullan=FDc=FDya kendinizi tan=FDtarak =DEirket =2C Kurum =2C Kurulu=FE ve Web Sitenizi bu yolla =E7ok daha ucuza tan=FDtabilirsiniz=2E -=097 milyon T=FCrk Kullan=FDc=FD sadece 49 $ + KDV -=09400=2E000=2E000 Yabanc=FD Kullan=FDc=FD 99 $ + KDV =DDleti=FEim =3A Necatibey caddesi 27=2F11 S=FDhh=FDye =96 Ankara =DDcq =3A 131140541 e-mail =3A info=40bulent=2Enet From jonatahh@hotmail.com Mon Aug 26 01:41:24 2002 From: jonatahh@hotmail.com (Jonata Goulart) Date: Mon, 26 Aug 2002 00:41:24 +0000 Subject: N queens problem Message-ID: This is the problem to figure out the n queens problem but I didn't understand it very well. Somebody can help me ? how legal and queens functions work? attack (l,c) (ll,cc) = l ==ll || (l+c==ll+cc) || (l-c==ll-cc) legal p m = and [not (attack (l,c) (m, length p +1)) | (l,c) <- zip p [1..]] queens n = r n n where r 0 n = [[]] r m n = [p ++ [m] | p <- r (m-1) n, m <-[1..n], legal p m] _________________________________________________________________ Chat with friends online, try MSN Messenger: http://messenger.msn.com From simonpj@microsoft.com Wed Aug 28 12:20:32 2002 From: simonpj@microsoft.com (Simon Peyton-Jones) Date: Wed, 28 Aug 2002 12:20:32 +0100 Subject: Question aboutthe use of an inner forall Message-ID: No, this is a bug, thank you. Will fix. Simon | -----Original Message----- | From: Ashley Yakeley [mailto:ashley@semantic.org]=20 | Sent: 19 August 2002 11:31 | To: Jay Cox; Haskell Cafe List | Subject: Re: Question aboutthe use of an inner forall |=20 |=20 | At 2002-08-18 20:19, Jay Cox wrote: |=20 | >#ST> runST (newSTRef (3::Prelude.Int)) | ># | >#Ambiguous type variable(s) `a' in the constraint `PrelShow.Show a'=20 | >#arising from use of `PrelIO.print' at #In a 'do'=20 | expression=20 | >pattern binding: PrelIO.print it |=20 | I don't understand this either, actually: |=20 | $ ghci -fglasgow-exts -package lang=20 | ___ ___ _ | / _ \ /\ /\/ __(_) | / /_\// /_/ / / | | GHC Interactive, version 5.04,=20 | for Haskell=20 | 98. | / /_\\/ __ / /___| | http://www.haskell.org/ghc/ | \____/\/ /_/\____/|_| Type :? for help. | =20 | Loading package base ... linking ... done. | Loading package haskell98 ... linking ... done. | Loading package lang ... linking ... done. | Prelude> :module ST | Prelude ST> :type runST | =20 | Inferred type is less polymorphic than expected | Quantified type variable `s' escapes | Expected type: ST s a -> t | Inferred type: (forall s1. ST s1 a) -> a | Prelude ST>=20 |=20 | What's up with that? Can't I even look at the type? Is this the=20 | monomorphism restriction or something? |=20 | --=20 | Ashley Yakeley, Seattle WA |=20 | _______________________________________________ | Haskell-Cafe mailing list | Haskell-Cafe@haskell.org=20 | http://www.haskell.org/mailman/listinfo/haskell-cafe |=20 From simonpj@microsoft.com Thu Aug 29 15:10:03 2002 From: simonpj@microsoft.com (Simon Peyton-Jones) Date: Thu, 29 Aug 2002 15:10:03 +0100 Subject: Question aboutthe use of an inner forall Message-ID: Now fixed in the 5.04 branch. The fix will get into the HEAD when=20 I merge in the Template Haskell stuff. Thanks for the report Simon | -----Original Message----- | From: Simon Peyton-Jones [mailto:simonpj@microsoft.com]=20 | Sent: 28 August 2002 12:21 | To: Ashley Yakeley | Cc: Haskell Cafe List | Subject: RE: Question aboutthe use of an inner forall |=20 |=20 | No, this is a bug, thank you. Will fix. |=20 | Simon |=20 | | -----Original Message----- | | From: Ashley Yakeley [mailto:ashley@semantic.org] | | Sent: 19 August 2002 11:31 | | To: Jay Cox; Haskell Cafe List | | Subject: Re: Question aboutthe use of an inner forall | |=20 | |=20 | | At 2002-08-18 20:19, Jay Cox wrote: | |=20 | | >#ST> runST (newSTRef (3::Prelude.Int)) | | ># | | >#Ambiguous type variable(s) `a' in the constraint `PrelShow.Show a' | | >#arising from use of `PrelIO.print' at #In a 'do'=20 | | expression | | >pattern binding: PrelIO.print it | |=20 | | I don't understand this either, actually: | |=20 | | $ ghci -fglasgow-exts -package lang=20 | | ___ ___ _ | | / _ \ /\ /\/ __(_) | | / /_\// /_/ / / | | GHC Interactive, version 5.04,=20 | | for Haskell | | 98. | | / /_\\/ __ / /___| | http://www.haskell.org/ghc/ | | \____/\/ /_/\____/|_| Type :? for help. | | =20 | | Loading package base ... linking ... done. | | Loading package haskell98 ... linking ... done. | | Loading package lang ... linking ... done. | | Prelude> :module ST | | Prelude ST> :type runST | | =20 | | Inferred type is less polymorphic than expected | | Quantified type variable `s' escapes | | Expected type: ST s a -> t | | Inferred type: (forall s1. ST s1 a) -> a | | Prelude ST> | |=20 | | What's up with that? Can't I even look at the type? Is this the | | monomorphism restriction or something? | |=20 | | -- | | Ashley Yakeley, Seattle WA | |=20 | | _______________________________________________ | | Haskell-Cafe mailing list | | Haskell-Cafe@haskell.org | | http://www.haskell.org/mailman/listinfo/haskell-cafe | |=20 | _______________________________________________ | Haskell-Cafe mailing list | Haskell-Cafe@haskell.org=20 | http://www.haskell.org/mailman/listinfo/haskell-cafe |=20 From green@abdyesilkart.com Thu Aug 29 21:06:34 2002 From: green@abdyesilkart.com (Green Card) Date: Thu, 29 Aug 2002 23:06:34 +0300 Subject: Sayın haskell-cafe , Message-ID: <20020829200632.20A584220BE@www.haskell.org> =3Chtml=3E =3Chead=3E =3Ctitle=3EGreen Card=3C=2Ftitle=3E =3Cmeta http-equiv=3D=22content-language=22 content=3D=22TR=22=3E =3Cmeta http-equiv=3D=22content-type=22 content=3D=22text=2Fhtml=3B charset=3Dwindows-1254=22=3E =3Cmeta http-equiv=3D=22content-type=22 content=3D=22text=2Fhtml=3B charset=3Diso-8859-9=22=3E =3C=2Fhead=3E =3Cbody bgcolor=3D=22#FFFFFF=22 text=3D=22#000000=22=3E =3Cp=3E=3Cfont face=3D=22Verdana=2C Arial=2C Helvetica=2C sans-serif=22 size=3D=222=22=3EAmerika =E7ekili=FEi i=E7in son bir ay! Yakalanmayacak bir f=FDrsat=2C Amerika'da hayat boyu oturma ve =E7al=FD=FEma izni edinmek Green Card'dan ge=E7iyor=2E Bir daha bu tip bir =E7ekili=FE gelecek senelerde olmayabilir=2C bu =FEans=FD ka=E7=FDrmay=FDn =3Ca href=3D=22http=3A=2F=2Fwww=2Eabdyesilkart=2Ecom=22 target=3D=22=5Fblank=22=3Ehemen t=FDklay=FDn=3C=2Fa=3E=2E=3C=2Ffont=3E=3C=2Fp=3E =3Cp=3E=3Cfont face=3D=22Verdana=2C Arial=2C Helvetica=2C sans-serif=22 size=3D=222=22=3EBa=FEvurmak i=E7in lise son veya lise mezunu olman=FDz yeterli=2C =DDngilizce bilmeniz kesinlikle gerekmiyor=2E =3Cbr=3E =3C=2Ffont=3E=3C=2Fp=3E =3Cp=3E=3Cfont face=3D=22Verdana=2C Arial=2C Helvetica=2C sans-serif=22 size=3D=222=22=3EGreen Card sahipleri=3B=3Cbr=3E =3C=2Ffont=3E=3C=2Fp=3E =3Cp=3E=3Cfont face=3D=22Verdana=2C Arial=2C Helvetica=2C sans-serif=22 size=3D=222=22=3E1=2E Amerika Birle=FEik Devletleri'nde s=FCresiz olarak =28hayat boyu=29 oturma ve =E7al=FD=FEma iznine sahiptirler=2E=3Cbr=3E 2=2E Amerikan vatanda=FEl=FDk haklar=FDndan bir=E7o=F0una sahip olurlar=2E=3Cbr=3E 3=2E Kart=FD ald=FDktan be=FE sene sonra isterlerse A=2EB=2ED=2E vatanda=FEl=FD=F0=FD ba=FEvurusu yapabilirler=2E=3Cbr=3E 4=2E =DD=FEyeri a=E7ma imkan=FDna sahip olurlar=2E=3Cbr=3E 5=2E Devlet =FCniversitelerine burs ba=FEvurusu yapabilme imkan=FD=2E=3Cbr=3E 6=2E Devlet Dairelerinde =E7al=FD=FEabilme imkan=FD=2E =3C=2Ffont=3E=3C=2Fp=3E =3Cp=3E=3Cfont face=3D=22Verdana=2C Arial=2C Helvetica=2C sans-serif=22 size=3D=222=22=3ESadece ba=FEvuru formumuzu doldurman=FDz yeterli=2C ad=FDn=FDza doldurulmu=FE olarak gelen formlar=FD imzalay=FDp siz kendiniz Amerika'ya normal posta ile yollay=FDn ve ba=FEvurunuzun yap=FDld=FD=F0=FDndan emin olun=2E =28 Amerika'ya g=F6nderi bedeli sadece 600=2E000 T=2EL=2E'dir =2E=29 =3Cbr=3E =3C=2Ffont=3E=3C=2Fp=3E =3Cp=3E=3Cfont face=3D=22Verdana=2C Arial=2C Helvetica=2C sans-serif=22 size=3D=222=22=3ESayg=FDlar=FDm=FDzla=2C=3Cbr=3E =3C=2Ffont=3E=3C=2Fp=3E =3Cp=3E=3Cfont face=3D=22Verdana=2C Arial=2C Helvetica=2C sans-serif=22 size=3D=222=22=3E=3Ca href=3D=22http=3A=2F=2Fwww=2Eabdyesilkart=2Ecom=22 target=3D=22=5Fblank=22=3Ewww=2Eabdyesilkart=2Ecom=3C=2Fa=3E =3C=2Ffont=3E=3Cbr=3E =3C=2Fp=3E =3Cp=3E =3B =3C=2Fp=3E =3Cp=3E=3Cfont face=3D=22Arial=2C Helvetica=2C sans-serif=22 size=3D=221=22=3EE-posta grubundan ayr=FDlmak ve bir daha e-posta almamak i=E7in =3Ca href=3D=22http=3A=2F=2Fwww=2Esistemweb=2Ecom=2Funsubs=2Ehtml=22 target=3D=22=5Fblank=22=3Eburaya t=FDklay=FDn=3C=2Fa=3E=3C=2Ffont=3E =3C=2Fp=3E =3C=2Fbody=3E =3C=2Fhtml=3E From jscott@planetinternet.be Fri Aug 30 10:27:58 2002 From: jscott@planetinternet.be (Scott J.) Date: Fri, 30 Aug 2002 11:27:58 +0200 Subject: Question aboutthe use of an inner forall References: Message-ID: <00c701c25007$8a6e9010$2097fea9@janxp> Hi, What happens if I code: newVar (MutVar s Bool) Do I get something of the form; ST s' (MutVar s' (MutVar s Bool)) Thx Scott ----- Original Message ----- From: "Simon Peyton-Jones" To: "Simon Peyton-Jones" ; "Ashley Yakeley" Cc: "Haskell Cafe List" Sent: Thursday, August 29, 2002 4:10 PM Subject: RE: Question aboutthe use of an inner forall > Now fixed in the 5.04 branch. The fix will get into the HEAD when > I merge in the Template Haskell stuff. > > Thanks for the report > > Simon > > > | -----Original Message----- > | From: Simon Peyton-Jones [mailto:simonpj@microsoft.com] > | Sent: 28 August 2002 12:21 > | To: Ashley Yakeley > | Cc: Haskell Cafe List > | Subject: RE: Question aboutthe use of an inner forall > | > | > | No, this is a bug, thank you. Will fix. > | > | Simon > | > | | -----Original Message----- > | | From: Ashley Yakeley [mailto:ashley@semantic.org] > | | Sent: 19 August 2002 11:31 > | | To: Jay Cox; Haskell Cafe List > | | Subject: Re: Question aboutthe use of an inner forall > | | > | | > | | At 2002-08-18 20:19, Jay Cox wrote: > | | > | | >#ST> runST (newSTRef (3::Prelude.Int)) > | | ># > | | >#Ambiguous type variable(s) `a' in the constraint `PrelShow.Show a' > | | >#arising from use of `PrelIO.print' at #In a 'do' > | | expression > | | >pattern binding: PrelIO.print it > | | > | | I don't understand this either, actually: > | | > | | $ ghci -fglasgow-exts -package lang > | | ___ ___ _ > | | / _ \ /\ /\/ __(_) > | | / /_\// /_/ / / | | GHC Interactive, version 5.04, > | | for Haskell > | | 98. > | | / /_\\/ __ / /___| | http://www.haskell.org/ghc/ > | | \____/\/ /_/\____/|_| Type :? for help. > | | > | | Loading package base ... linking ... done. > | | Loading package haskell98 ... linking ... done. > | | Loading package lang ... linking ... done. > | | Prelude> :module ST > | | Prelude ST> :type runST > | | > | | Inferred type is less polymorphic than expected > | | Quantified type variable `s' escapes > | | Expected type: ST s a -> t > | | Inferred type: (forall s1. ST s1 a) -> a > | | Prelude ST> > | | > | | What's up with that? Can't I even look at the type? Is this the > | | monomorphism restriction or something? > | | > | | -- > | | Ashley Yakeley, Seattle WA > | | > | | _______________________________________________ > | | Haskell-Cafe mailing list > | | Haskell-Cafe@haskell.org > | | http://www.haskell.org/mailman/listinfo/haskell-cafe > | | > | _______________________________________________ > | Haskell-Cafe mailing list > | Haskell-Cafe@haskell.org > | http://www.haskell.org/mailman/listinfo/haskell-cafe > | > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From f.ktiri@caramail.com Fri Aug 30 13:03:56 2002 From: f.ktiri@caramail.com (fouad ktiri) Date: Fri, 30 Aug 2002 12:03:56 GMT+1 Subject: aide SVP Message-ID: <1030701836030229@caramail.com> This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. --=_NextPart_Caramail_0302291030701836_ID Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Bonjour, Comment faire pour stocker des donn=E9es dans une liste comme en programmation normale (x=3Dx+1) Merci beaucoup ______________________________________________________ Bo=EEte aux lettres - Caramail - http://www.caramail.com --=_NextPart_Caramail_0302291030701836_ID-- From zhongyan43@hotmail.com Fri Aug 30 13:12:16 2002 From: zhongyan43@hotmail.com (yan zhong) Date: Fri, 30 Aug 2002 22:12:16 +1000 Subject: help Message-ID:

Dear sir/madum

 

I am a Haskell beginner; I got the problem in use Haskell because I never touch it before. Can you help me to solve the following two exercises please?

 

 

Exercise 1

How to write a filter that removes all HTML tags from a HTML document, it should have the main function as following:

 

Main :: IO( )

Main = interact noTags

Where noTags :: String ->String is the function you will write to remove all text delimited by < and > from a String

 

 

Exercise 2

If there are three matrix

Matrix a =                 1      2      3

4      5      6

7      8      9

 

Matrix b =           1       -1       1

             -1        1     -1

                                1       -1      1

 

Matrix c =                 -1       1     -1

 1      -1      1

                                -1       1     -1

 

<+> Return the sum of two matrices

<->  Return the different of two matrices

<*> Return the product of two matrixes.

*> Return the product of a scalar and a matrix

Implement a module that can evaluate the expression             3.0 *> a <+> b <+> c

 

Would you please give some hint to me?

Thank you very much.

 

Your sincerely:

 

YAN ZHONG

 

 



ÓëÁª»úµÄÅóÓѽøĞн»Á÷£¬ÇëʹÓà MSN Messenger: µ¥»÷´Ë´¦
From alastair@reid-consulting-uk.ltd.uk Fri Aug 30 14:09:50 2002 From: alastair@reid-consulting-uk.ltd.uk (Alastair Reid) Date: 30 Aug 2002 14:09:50 +0100 Subject: help In-Reply-To: References: Message-ID: Your message seems to be about removing HTML tags from an HTML document. Unfortunately, I had trouble reading your mail because... it was full of HTML tags. >>>>> "yan" == yan zhong writes: >

style="MARGIN: 0cm 0cm 0pt">Dear > sir/madum

size=2> 

I am a Haskell > beginner; I got the problem in use Haskell because I never touch it > before. Can you help me to solve the following two exercises > please?

writes: > > >

> style="MARGIN: 0cm 0cm 0pt">Dear > > sir/madum

> size=2> 

I am a Haskell > > beginner; I got the problem in use Haskell because I never touch it > > before. Can you help me to solve the following two exercises > > please?

To: Sent: Friday, August 30, 2002 2:03 PM Subject: aide SVP Bonjour, Comment faire pour stocker des données dans une liste comme en programmation normale (x=x+1) Merci beaucoup ______________________________________________________ Boîte aux lettres - Caramail - http://www.caramail.com