30 January 2017

patching Network-NineP

System: Microsoft Windows XP Home Edition
CPUs: Intel(R) Atom(TM) CPU N270 @1.60GHz
Deps: HaskellPlatform-2014.2.0.0-i386-setup.exe

I am suspending further work on this project after initially
patching the hackage download to compile on GNU/Linux,
basically because I don't like the [MSYS2] toolchain that's
shipped with the current HaskellPlatform.

The GitHub network-ninep-0.0.1 download contains code using withSocketsDo,
purportedly needed to be able to use Winsock - I believe binary > might be
a dependency for that download, however withSocketsDo is not appearing in the
hackage Network-NineP downloads, of which incidentally, though I admit I have
not researched it thouroughly, if the GitHub release preceded those from hackage,
some of the former's code might appear to have been split off into separate NineP
downloads: https://github.com/Elemir/network-ninep

The Network-NineP-0.4.1 package compiled on Slackware-14.0 after
adding this line following the comments at the top of Error.hs. If you are
installing into '--prefix=/usr' you might want to change the executable's
name in the cabal file, so it does not conflict with Slackware's /bin/test,
/usr/bin contains a symbolic link to /bin/test.

{-# LANGUAGE DeriveDataTypeable #-}

On Windows XP the compile fails on the 8th of a total of 9 files,
the same occurs on HaskellPlatform-7.10.2-a-i386-setup.exe.

HaskellPlatform-7.10.3-i386-setup.exe installed on XP fails to
load time-

HaskellPlatform-8.0.2-full-i386-setup.exe requires at minimum
Windows 7, as that version's ghc.exe uses the procedure entry
point _wsplitpath_s, introduced in the Windows 7 msvcrt.dll.

After importing Network (from network- in ghci.exe
the 'Not in scope' error occurs.

Microsoft Windows XP [version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\Eric>ghci
GHCi, version 7.8.3: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
ghci> import Network
ghci> :t UnixSocket

<interactive>:1:1: Not in scope: data constructor `UnixSocket'
ghci> :q
Leaving GHCi.

C:\Documents and Settings\Eric>EXIT

This however doesn't occur on Slackware-14.0 using network-

sh-4.2$ ghci
GHCi, version 7.8.4: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
ghci> import Network
ghci> :t UnixSocket
UnixSocket :: String -> PortID
ghci> :q
Leaving GHCi.

sh-4.2$ exit


The parsec version (accompanying the above download) and convertible-
need to use the identical version of the text package.

C:\Documents and Settings\Eric>CD \

C:\>cabal update
Config file path source is default config file.
Config file C:\Documents and Settings\Eric\Application Data\cabal\config not
Writing default configuration to C:\Documents and Settings\Eric\Application
Downloading the latest package list from hackage.haskell.org
Note: there is a new version of cabal-install available.
To upgrade, run: cabal install cabal-install

C:\>cabal install NineP- transformers-compat-
Resolving dependencies...
Downloading NineP-
Downloading transformers-compat-
Configuring NineP-
Configuring transformers-compat-
Building NineP-
Building transformers-compat-
Installed transformers-compat-
Installed NineP-

C:\>cabal install exceptions- hslogger-1.2.10 monad-loops-0.4.3
Resolving dependencies...
Downloading exceptions-
Downloading monad-loops-0.4.3...
Downloading hslogger-1.2.10...
Configuring monad-loops-0.4.3...
Configuring exceptions-
Building monad-loops-0.4.3...
Building exceptions-
Installed monad-loops-0.4.3
Configuring hslogger-1.2.10...
Installed exceptions-
Building hslogger-1.2.10...
Installed hslogger-1.2.10

C:\>cabal install convertible- extensible-exceptions-
Resolving dependencies...
Downloading convertible-
Downloading extensible-exceptions-
Configuring extensible-exceptions-
Configuring convertible-
Building extensible-exceptions-
Building convertible-
Installed extensible-exceptions-
Installed convertible-

C:\>cabal install monad-peel- mstate-0.2.7 stateref-0.3
Resolving dependencies...
Downloading monad-peel-
Downloading stateref-0.3...
Configuring stateref-0.3...
Configuring monad-peel-
Building stateref-0.3...
Building monad-peel-
Installed monad-peel-
Downloading mstate-0.2.7...
Configuring mstate-0.2.7...
Installed stateref-0.3
Building mstate-0.2.7...
Installed mstate-0.2.7



Download and extract Network-NineP-0.4.1.tar.gz, adding
this line following the comments at the top of Error.hs.

{-# LANGUAGE DeriveDataTypeable #-}

Then run the commands.

C:\Network-NineP-0.4.1>runhaskell Setup configure --user
Configuring Network-NineP-0.4.1...

C:\Network-NineP-0.4.1>runhaskell Setup build
Building Network-NineP-0.4.1...
Preprocessing library Network-NineP-0.4.1...
[1 of 9] Compiling Network.NineP.Error ( Network\NineP\Error.hs, dist\build\Netw
ork\NineP\Error.o )
[2 of 9] Compiling Control.Monad.EmbedIO ( Control\Monad\EmbedIO.hs, dist\build\
Control\Monad\EmbedIO.o )
[3 of 9] Compiling Network.NineP.Internal.File ( Network\NineP\Internal\File.hs,
 dist\build\Network\NineP\Internal\File.o )
[4 of 9] Compiling Network.NineP.File ( Network\NineP\File.hs, dist\build\Networ
k\NineP\File.o )
[5 of 9] Compiling Network.NineP.File.Instances ( Network\NineP\File\Instances.h
s, dist\build\Network\NineP\File\Instances.o )
[6 of 9] Compiling Network.NineP.Internal.State ( Network\NineP\Internal\State.h
s, dist\build\Network\NineP\Internal\State.o )
[7 of 9] Compiling Network.NineP.Internal.Msg ( Network\NineP\Internal\Msg.hs, d
ist\build\Network\NineP\Internal\Msg.o )
[8 of 9] Compiling Network.NineP.Server ( Network\NineP\Server.hs, dist\build\Ne
twork\NineP\Server.o )

    Not in scope: data constructor `UnixSocket'


Here's the code block in Server.hs where the compile failed.

connection :: String -> IO Socket
connection s = let pat = "tcp!(.*)!([0-9]*)|unix!(.*)" :: ByteString
wrongAddr = ioError $ userError $ "wrong 9p connection address: " ++ s
(bef, _, aft, grps) = s =~ pat :: (String, String, String, [String])
in if (bef /= "" || aft /= "" || grps == [])
then wrongAddr
else case grps of
[addr, port, ""] -> listen' addr $ toEnum $ (fromMaybe 2358 $ maybeRead port :: Int)
["", "", addr]  -> listenOn $ UnixSocket addr
_ -> wrongAddr

NB: The package version numbers above were selected so one could install yi-0.10.1 on
top of this without breaking any packages.

29 January 2017

patching sexpr

System: Slackware Linux (version 14.0)
CPUs: Intel(R) Atom(TM) CPU N270 @1.60GHz
Deps: ghc-7.8.4-i386-unknown-linux-deb7.tar.xz

This entry is not finished yet.

Looking at /sexpr-0.2.1/Codec/Sexpr/Internal.hs it appears feasible to patch
sexpr-0.2.1.tar.gz to use QuickCheck2, to run on a bootstrapped ghc and/or
on HaskellPlatform.




With the QuckCheck version I have installed being 2.7.6,
running a SlackBuild script I authored for the above sexpr
version outputs the following, owing to the sexpr version
being written for QuickCheck <2.1.

bash-4.2# ./haskell-sexpr.SlackBuild
Configuring sexpr-0.2.1...
Building sexpr-0.2.1...
Preprocessing library sexpr-0.2.1...
[1 of 4] Compiling Codec.Sexpr.Internal ( Codec/Sexpr/Internal.hs, dist/build/Codec/Sexpr/Internal.o )

    `coarbitrary' is not a (visible) method of class `Arbitrary'

The file /sexpr-0.2.1/Codec/Sexpr/Tests.hs also imports Test.QuickCheck.

See also:

12 January 2017

patching ESS

System: Slackware Linux (version 14.0)
CPUs: Intel(R) Atom(TM) CPU N270 @1.60GHz
Deps: ess-16.10.zip, cl-lib-0.6.1.el,

The development version with the below patches and
others committed is available as a github clone and/
or download, the latter as ESS-master.zip. 

Looking at the release notes for emacs-24.3 it appears feasible to patch ess-16.10 to
run on Slackware 14.0 (or other Un*x distros) with emacs-24.2.


" ...An update for the Common Lisp emulation library."
" ...the changes in Emacs 24.3 are relatively minor."


Read about the update.

bash-4.2# cd /tmp
bash-4.2# tar xf emacs-24.3.tar.gz
bash-4.2# grep -n "Common Lisp emulation" emacs-24.3/etc/NEWS
247:** Common Lisp emulation (CL)

bash-4.2# head -n 258 emacs-24.3/etc/NEWS | tail -12
** Common Lisp emulation (CL)

*** CL's main entry is now (require 'cl-lib).
`cl-lib' is like the old `cl' except that it uses the namespace cleanly;
i.e., all its definitions have the "cl-" prefix (and internal definitions
use the "cl--" prefix).

If `cl' provided a feature under the name `foo', then `cl-lib'
provides it under the name `cl-foo' instead; with the exceptions of the
few `cl' definitions that had to use `foo*' to avoid conflicts with
pre-existing Elisp entities.  These have been renamed to `cl-foo'
rather than `cl-foo*'.

Check for any new macros.

bash-4.2# grep "New macros" emacs-24.3/etc/NEWS
** New macros `setq-local' and `defvar-local'.


Download ess-16.10.zip, extract it, and move the directory.

bash-4.2# unzip ess-16.10.zip


bash-4.2# mv ess-16.10 /usr/share/emacs/site-lisp/ess

Check if ess-16.10 used cl-lib and the new macros.

bash-4.2# grep -r cl-lib /usr/share/emacs/site-lisp/ess/lisp
lisp/ess-r-syntax.el:(require 'cl-lib)

bash-4.2# grep -r defvar-local /usr/share/emacs/site-lisp/ess/lisp
lisp/ess-generics.el:      (defvar-local ,funname nil ,(format "When defined this function
 is called by `%s'." name))
lisp/ess-r-d.el:(defvar-local ess-r-evaluation-env nil
lisp/ess-r-d.el:(defvar-local ess-r--evaluation-env-mode-line
lisp/ess-r-package.el:(defvar-local ess-r-package-info nil
lisp/ess-tracebug.el:(defvar-local ess--dbg-mode-line-debug
lisp/ess-tracebug.el:(defvar-local ess--dbg-mode-line-error-action
lisp/ess-utils.el:(defvar-local ess-buffer-has-chunks nil

bash-4.2# grep -r setq-local /usr/share/emacs/site-lisp/ess/lisp
lisp/ess-help.el:  (if ess-mode-syntax-table ;;set in advance by ess-setq-local
lisp/ess-help.el:  (setq-local show-trailing-whitespace nil)
lisp/ess-inf.el:      (setq-local jit-lock-chunk-size inferior-ess-jit-lock-chunk-size))
lisp/ess-roxy.el:          (setq-local ess-buffer-has-chunks t)
lisp/ess-roxy.el:          (setq-local syntax-propertize-function #'ess-roxy-syntax-propertize)
lisp/ess-roxy.el:          (setq-local font-lock-fontify-region-function #'ess-roxy-fontify-region)
lisp/ess-roxy.el:          (setq-local font-lock-unfontify-region-function #'ess-roxy-unfontify-region)))
lisp/ess-roxy.el:    (setq-local syntax-propertize-function nil)
lisp/ess-roxy.el:    (setq-local font-lock-fontify-region-function nil)
lisp/ess-roxy.el:    (setq-local font-lock-unfontify-region-function nil)
lisp/ess-roxy.el:  (setq-local paragraph-start (concat "\\(" ess-roxy-re "\\)*"paragraph-start))
lisp/ess-roxy.el:  (setq-local paragraph-separate (concat "\\(" ess-roxy-re "\\)*" paragraph-separate))
lisp/ess-roxy.el:  (setq-local adaptive-fill-function 'ess-roxy-adaptive-fill-function))

bash-4.2# grep -r setq-local /usr/share/emacs/site-lisp/ess/test
test/ess-literate-tests.el:      (setq-local file-local-variables-alist (copy-alist local-variables))
test/literate/code-fill.R:##! (setq-local fill-column 40)
test/literate/code-fill.R:##! (setq-local fill-column 40)
test/literate/code-fill.R:##! (setq-local fill-column 42)


Download cl-lib-0.6.1.el, rename it to cl-lib.el, create a byte-compiled version,
gzip cl-lib.el, and move the two files to /usr/share/emacs/24.2/lisp/emacs-lisp.

bash-4.2# mv cl-lib-0.6.1.el cl-lib.el
bash-4.2# emacs -batch -f batch-byte-compile cl-lib.el

In toplevel form:
cl-lib.el:74:1:Warning: cl package required at runtime
Wrote /tmp/cl-lib.elc
bash-4.2# gzip -n -9 cl-lib.el
bash-4.2# file cl-lib.el.gz
cl-lib.el.gz: gzip compressed data, from Unix, max compression
bash-4.2# mv cl-lib.el.gz /usr/share/emacs/24.2/lisp/emacs-lisp
bash-4.2# mv cl-lib.elc /usr/share/emacs/24.2/lisp/emacs-lisp


Download julia-emacs-master.zip, extract it, and move
julia-mode.el to /usr/share/emacs/site-lisp/ess/lisp.

bash-4.2# unzip julia-emacs-master.zip


bash-4.2# mv julia-emacs-master/julia-mode.el \
> /usr/share/emacs/site-lisp/ess/lisp

Patches committed on 10, 14, and 18 January 2017, respectively for a backwards
compatibility definition for defvar-local, allocation for pcase.el (emacs-24.2/24.1)
specifications, and a backward compatibility definition for setq-local; the macro
defines based on those found in the file emacs-24.3/lisp/subr.el.

10. jan. 2017 09.57 CET

diff --git a/lisp/ess-compat.el b/lisp/ess-compat.el
index 6910877..d706a34 100644
--- a/lisp/ess-compat.el
+++ b/lisp/ess-compat.el
@@ -1,6 +1,6 @@
 ;;; ess-compat.el --- simple determination of Emacs/XEmacs and version #.

-;; Copyright (C) 2000--2005 A.J. Rossini, Richard M. Heiberger, Martin
+;; Copyright (C) 2000--2017 A.J. Rossini, Richard M. Heiberger, Martin
 ;;      Maechler, Kurt Hornik, Rodney Sparapani, and Stephen Eglen.

 ;; Author: A.J. Rossini <rossini@biostat.washington.edu>
 @@ -278,6 +278,18 @@ mode is enabled.  Usually, such commands should use
 also checks the value of `use-empty-active-region'."
     (and transient-mark-mode mark-active)))

+;; for emacs <= 24.2 :
+(unless (fboundp 'defvar-local)
+  (defmacro defvar-local (var val &optional docstring)
+    "Define VAR as a buffer-local variable with default value VAL.
+Like `defvar' but additionally marks the variable as being automatically
+buffer-local wherever it is set."
+    (declare (debug defvar) (doc-string 3))
+    ;; Can't use backquote here, it's too early in the bootstrap.
+    (list 'progn (list 'defvar var val docstring)
+          (list 'make-variable-buffer-local (list 'quote var)))))
 (provide 'ess-compat)

   ; Local variables section

14. jan. 2017 20.37 CET

diff --git a/lisp/ess-r-syntax.el b/lisp/ess-r-syntax.el
index 4ac34f30..26ff7d18 100644
--- a/lisp/ess-r-syntax.el
+++ b/lisp/ess-r-syntax.el
@@ -189,7 +189,7 @@ Cons cell containing the token type and string representation."
 ;; backward
 (defun ess-climb-token--operator ()
   (when (pcase (char-before)
-          ((or ?+ ?/ ?^ ?~ ?? ?!)
+          ((or `?+ `?/ `?^ `?~ `?? `?!)
            (prog1 (ess-backward-char)
 @@ -198,7 +198,7 @@ Cons cell containing the token type and string representation."
                  (ess-climb-token--char ?:)
                  (ess-climb-token--char ?>)
                  (ess-climb-token--char ?<))))
-          ((or ?& ?| ?* ?@ ?$)
+          ((or `?& `?| `?* `?@ `?$)
            (prog1 (ess-backward-char)
              (ess-climb-token--char (char-after))))
 @@ -364,7 +364,7 @@ reached."
   (let ((refined-type
          (pcase (ess-token-type token)
            ;; Parameter assignment
-           ("="
+           (`"="
               (goto-char (ess-token-start token))
               (let ((containing-sexp (ess-containing-sexp-position)))
 @@ -377,14 +377,14 @@ reached."
                                   (ess-token-before= '("," "(")))))
            ;; Quoted identifiers
-           ("string"
+           (`"string"
             (when (or
                    ;; Quoted parameter names
                    (ess-refined-token= (ess-token-after) "param-assign")
                    ;; Quoted call names
                    (ess-token-after= "("))
-           ((or "(" ")")
+           ((or `"(" `")")
             (or (save-excursion
                   (if (ess-token-close-delimiter-p token)
                       (ess-climb-paired-delims nil token)
 @@ -397,7 +397,7 @@ reached."
                     (ess-climb-paired-delims ")" token)
                     (when (ess-token-before= '("identifier" "string" ")" "]" "]]" "}"))
-           ((or "{" "}")
+           ((or `"{" `"}")
               (unless (ess-climb-paired-delims "}" token)
                 (goto-char (ess-token-start token)))

18. jan. 2017 11.32 CET

diff --git a/lisp/ess-compat.el b/lisp/ess-compat.el
index d706a34..175f8f2 100644
--- a/lisp/ess-compat.el
+++ b/lisp/ess-compat.el
@@ -289,6 +289,12 @@ buffer-local wherever it is set."
     (list 'progn (list 'defvar var val docstring)
           (list 'make-variable-buffer-local (list 'quote var)))))

+(unless (fboundp 'setq-local)
+  (defmacro setq-local (var val)
+    "Set variable VAR to value VAL in current buffer."
+    ;; Can't use backquote here, it's too early in the bootstrap.
+    (list 'set (list 'make-local-variable (list 'quote var)) val)))

 (provide 'ess-compat)

Cd'ing to the ess directory and running 'make' byte-compiled on the
patched ess-16.10 all relevent .el files, and 'make test' passed the 17

bash-4.2# cd /usr/share/emacs
bash-4.2# CWD=$(pwd)
bash-4.2# mkdir logs
bash-4.2# cd site-lisp/ess
bash-4.2# make >$CWD/logs/make_2017-01-19.log 2>&1
bash-4.2# make test>$CWD/logs/make_test_2017-01-19.log 2>&1
bash-4.2# tail -n3 $CWD/logs/make_test_2017-01-19.log

Ran 17 tests, 17 results as expected (2017-01-19 02:42:38+0100)

bash-4.2# exit

NB: If you have a network connection julia-mode.el will be automatically downloaded.

06 January 2017


System: Microsoft Windows 2K, XP, Vista, 7, 8.0
CPUs: Intel(R) Atom(TM) CPU N270 @1.60GHz.

Installation of es-0.9.1 in SFU/SUA Interix.


In the SUA Interix 6.0 download for MS® Vista (Ultimate and Enterprise Editions) there's a file
'gcc_fullbuild' - found after extracting gcc4.2.tgz - which contains these prerequisite programs
with version numbers, for compiling gcc-4.2.0; this file is available in the sidebar as the down-
load is 473 MB; I've added indent (a flex dependency) and omitted gettext-0.16 in the below.


These compile favourably utilising CFLAGS="-O2 -march=i586", and the configure script
arguments as '--prefix=/usr --build=i586-pc-interix3 --host=i586-pc-interix3'.

The following command run in the source directories - if one builds within the source tree -
will strip to external PDB the compiled executables and libraries.

$ find . | xargs file | grep "executable" | grep PE | cut -f 1 -d : | \
> xargs strip --strip-unneeded 2> /dev/null

Remove or rename /bin/make and move GNU make to /bin, then add a symbolic link as
gmake, remove or rename /bin/m4 and move GNU m4 to /bin, remove or rename /bin/sed
and move GNU sed to /bin, before running 'gmake install' on bison-2.3 rename or remove
/bin/yacc and rename or remove /usr/lib/liby.a, which can be replaced by the bison version,
and before running 'gmake install' on flex rename or remove /bin/lex; the file /usr/lib/libl.a
(the lex library) can likewise be removed or renamed.

The shell es-0.9.1.tar.gz will then compile on gcc-3.3 after deleting
the '-Wno-missing-field-initializers' and '-Wno-clobbered' CFLAGS
from the configure script's generated Makefile.

$ echo $CC
$ cd es-0.9.1
$ CFLAGS="-O2 -march=i586" \
> ./configure --prefix=/usr \
> --build=i586-pc-interix3 \
> --host=i586-pc-interix3



Edit your Makefile (as above).

$ gmake


$ find . | xargs file | grep "executable" | grep PE | cut -f 1 -d : | \
> xargs strip --strip-unneeded 2> /dev/null

$ mv es /bin
$ exit

NB: These installation instructions don't allocate for a line-editing library;
for some reason compiling with readline-6.1 results in dead Æ, Ø and Å
keys. Haahr's .esrc in the examples directory in part pertains to a NeXT
machine, and Jamesh's .esrc file likely won't work without a line-editing
library. However, starting SFU/SUA's Korn shell inside GNU emacs and
then switching to es is satisfactory.

(setq explicit-shell-file-name "C:\\WINDOWS\\system32\\posix.exe")
(setq explicit-posix.exe-args '("/u" "/c" "/bin/ksh" "-l"))

The es(1) and xs(1) man pages are similar.