Skip to content

Commit b70c1d2

Browse files
committed
simplify usage of other build tools
1 parent 382d72a commit b70c1d2

File tree

6 files changed

+129
-195
lines changed

6 files changed

+129
-195
lines changed

Foreign/Emacs/Internal.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{-# LANGUAGE FlexibleInstances #-}
22
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
3-
{-# LANGUAGE OverlappingInstances #-}
43
{-# LANGUAGE OverloadedStrings #-}
54
{-# LANGUAGE UndecidableInstances #-}
65

@@ -23,7 +22,7 @@ class ToEmacs a where
2322
instance ToLisp a => ToEmacs a where
2423
toEmacs = Right . toLisp
2524

26-
instance ToLisp a => ToEmacs (Emacs a) where
25+
instance {-# OVERLAPS #-} ToLisp a => ToEmacs (Emacs a) where
2726
toEmacs = Left . fmap toLisp
2827

2928
newtype Emacs a = EmacsInternal

HaskellEmacs.hs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
{-# LANGUAGE FlexibleInstances #-}
2-
{-# LANGUAGE OverlappingInstances #-}
32
{-# LANGUAGE OverloadedStrings #-}
43

4+
-- WARNING: Please note that this file is autogenerated.
5+
--
6+
-- If you want to change this file, you have to clone the github repo and apply the changes in a local repo.
7+
58
module Main where
69
{--<<import>>--}
710
import Control.Applicative (optional, (<$>), (<*>))
@@ -33,7 +36,7 @@ class Arity f where
3336
instance Arity x where
3437
arity _ = 0
3538

36-
instance Arity f => Arity ((->) a f) where
39+
instance {-# OVERLAPS #-} Arity f => Arity ((->) a f) where
3740
arity f = 1 + arity (f undefined)
3841

3942
data Instruction = EmacsToHaskell Lisp
@@ -212,7 +215,7 @@ fromName (S.Symbol str) = str
212215
fromName (S.Ident str) = str
213216

214217
exportFunction :: ExportSpec -> Maybe Name
215-
exportFunction (EVar qname) = unQualifiedName qname
218+
exportFunction (EVar qname) = unQualifiedName qname
216219
exportFunction (EModuleContents _) = Nothing
217220
exportFunction _ = Nothing
218221

README.org

Lines changed: 5 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,11 @@ which =haskell-emacs= cannot marshal to the correct type. Please keep in
7171
mind that Emacs Lisp Arrays will be translated (recursively) to
7272
Haskell Lists and Emacs Lisp Lists will be marshaled to either Haskell
7373
Lists or Haskell Tuples.
74-
74+
* Build tools
75+
You can use your favorite build tool. Nix, stack and cabal are
76+
supported out of the box. If you don't specify which one to use via
77+
=haskell-emacs-build-tool= it'll try to guess your build tool and ask
78+
you when initializing.
7579
* Performance
7680
There is a (very) small overhead calling Haskell functions, so for very
7781
trivial situations, elisp functions will be faster. On my laptop
@@ -421,64 +425,6 @@ has to transfer the whole buffer.
421425
Note that in such a trivial case a function written in elisp would be
422426
faster (albeit a lot unsafer). A sophisticated function could take
423427
the buffer-string, parMap it and replace the old buffer-string.
424-
* Modules
425-
If you want to distribute a Haskell library for =haskell-emacs=,
426-
just write an elisp file describing the package and the
427-
corresponding Haskell file in the same dir:
428-
#+BEGIN_SRC elisp
429-
;;;; haskell-emacs-pi/haskell-emacs-pi.el
430-
431-
;;; haskell-emacs-pi.el --- return pi
432-
433-
;; Version: 1.0.0
434-
;; Package-Requires: ((haskell-emacs "2.4.0"))
435-
436-
;;; Code:
437-
438-
(require 'haskell-emacs)
439-
(provide 'haskell-emacs-pi)
440-
441-
;;; haskell-emacs-pi.el ends here
442-
#+END_SRC
443-
444-
#+BEGIN_SRC haskell
445-
---- haskell-emacs-pi/Pi.hs
446-
447-
module Pi (piSquare) where
448-
449-
piSquare :: Double
450-
piSquare = pi^2
451-
#+END_SRC
452-
453-
That's all. You can distribute this package for example via
454-
melpa (don't forget to add the *.hs to the files of the recipe)
455-
or just point your =load-path= to this directory. If you call
456-
afterwards =haskell-emacs-init=, it will automatically find this
457-
module and provide the functions.
458-
459-
If you want to use such functions in your elisp library, do the following:
460-
461-
#+BEGIN_SRC elisp
462-
;;; my-nums.el --- add a number to the square of pi
463-
464-
;; Package-Requires: ((haskell-emacs-pi "1.0.0"))
465-
466-
;;; Code:
467-
468-
(require 'haskell-emacs-pi)
469-
(eval-when-compile (haskell-emacs-init))
470-
471-
;;;### autoload
472-
(defun my-nums (arg)
473-
(+ arg (Pi.piSquare)))
474-
475-
;;; my-nums.el ends here
476-
#+END_SRC
477-
* Nixos
478-
The integration with NixOS is handled by compiling in a =nix-shell=
479-
which is customizeable. You can for example add the --pure flag and
480-
list all the dependencies. Obviously, in this case, a cabal sandbox
481-
wouldn't make sense.
482428
* Shortcomings
483429
Not all types marshal across languages, if you write a function with
484430
an unknown type, =haskell-emacs-init= will signal an error with the

0 commit comments

Comments
 (0)