Commit Graph

23 Commits

Author SHA1 Message Date
Inari Listenmaa
b914a25de3 define return in terms of pure, >> as *>, mappend as <>
In preparation for deprecation, see https://gitlab.haskell.org/ghc/ghc/-/wikis/proposal/semigroup-monoid and https://gitlab.haskell.org/ghc/ghc/-/wikis/proposal/monad-of-no-return
2025-08-02 16:39:31 +02:00
Inari Listenmaa
1037b209ae add whitespace on list comprehensions, applications etc.
text editor interprets these things as errors (e.g. unterminated qq for list comprehension) and underlines red, even though there is no real error.
2025-08-02 16:39:31 +02:00
Andreas Källberg
7268253f5a MonadFail: Make backwards-compatible 2020-09-05 20:23:07 +02:00
Andreas Källberg
0581d6827e Fix most build errors 2020-08-05 18:48:24 +02:00
krangelov
30eef61f0a more dead code 2019-09-20 16:15:28 +02:00
meng wong
8a14912ee3 GF_LIB_PATH can now be path1:path2:path3, not just path1
Traditionally, GF_LIB_PATH points to something like
`.../share/ghc-8.0.2-x86_64/gf-3.9/lib`

and if you want prelude and alltenses and present, you add a
`--# -path=.:present`
compiler pragma to the top of your .gf file

But if you are developing some kind of application grammar
library or contrib of your own, you might find yourself
repeating your library path at the top of all your .gf files.

After painstakingly maintaining the same library path at the
top of all your .gf files, you might say, let's factor this
out into GF_LIB_PATH.

Then you might then find to your surprise that GF_LIB_PATH
doesn't accept the usual colon:separated:path notation
familiar from, say, unix PATH and MANPATH.

This patch allows you to define
`GF_LIB_PATH=gf-3.9.lib:$HOME/gf-contrib/whatever/lib`
in a more natural way.

If you are an RGL hacker and have your own version of the
RGL tree sitting somewhere, you should be able to have both
paths in the GF_LIB_PATH, for added convenience. This minor
convenience will probably lead to obscure bugs and great
frustration when you find that your changes are mysteriously
not being picked up by GF; so keep this in mind and use it
cautiously.

This caution should probably sit in the documentation
somewhere. A subsequent commit will do that.

If you use zsh, you can do this to quickly build up a big
GF_LIB_PATH:

% gf_lib_path=( $HOME/src/GF/lib/src/{api,abstract,common,english,api/libraryBrowser,prelude,..} )

% typeset -xT GF_LIB_PATH gf_lib_path
2018-07-22 00:04:07 -07:00
Thomas Hallgren
820d2d503f Fixes for GHC 8.4.1 compatibility
* In GHC 8.4.1, the operator <> has become a method of the Semigroup class
  and is exported from the Prelude. This is unfortunate, since <> is also
  exported from the standard library module Text.PrettyPrint, so in any
  module that defines a pretty printer, there is likely to be an ambiguity.

  This affects ~18 modules in GF. Solution:

    import Prelude hiding (<>)

  This works also in older versions of GHC, since GHC does't complain if
  you hide something that doesn't exists.

* In GHC 8.4.1, Semigroup has become a superclass of Monoid. This means
  that anywhere you define an instance of the Monoid class you also have to
  define an instance in the Semigroup class.

  This affects Data.Binary.Builder in GF. Solution: conditionally define
  a Semigroup instance if compiling with base>=4.11 (ghc>=8.4.1)
2018-04-18 19:18:10 +02:00
hallgren
9556cf453f Parallel compilation: "gf -make -j" and "gf -make -j=n" now work as expected
* "gf -make -j=n" uses n parallel threads.
  * "gf -make -j" adapts to the number of processors in the system.

This mimics how "cabal build -j" and "ghc --make -j" works.

Support for this is implemented in the new module GF.System.Concurrency and
it depends on the function Control.Concurrent.setNumCapabilities, which is
only available in GHC>=7.6 (base>=4.6). GF can still be compiled with
GHC<7.6, but then you have to use +RTS -N -RTS to take advantage of
multicore processors.

To detect the number of processors in the system, the code depends on a
foreign import of a C function in the GHC run-time system.
2015-09-11 14:18:01 +00:00
hallgren
22ba8d34ff Bump version of .gfo and .pgf files, improve error messages on version mismatch
Becacuse of the new special tokens added to the Symbol type, .gfo and .pgf
files produced with the current version of GF can not always be used with
older versions of GF and the PGF run-time system.

The PGF version number was increased from (2,0) to (2,1). GF can still
read version (2,0) and (1,0), so old PGF files continue to work.

The GFO version was increased from "GF03" to "GF04".
2015-06-23 12:58:14 +00:00
hallgren
6e81383231 GF.CompileInParallel: get rid of the cryptic 'thread blocked indefinitely in an MVar operation' message after compilation errors
Instead show a message saying how many modules were affected by the compilation
errors.
2015-03-31 13:26:51 +00:00
hallgren
421bdf3903 GF.CompileInParallel: fix a Win32 problem
Recognize \ in addition to / when extracting path components.
2015-03-13 13:48:14 +00:00
hallgren
c707575bd7 Documentation improvements and cleanup relating to the IOE monad
Renamed appIOE to tryIOE (it is analogous to 'try' in the standard libraries).
Removed unused IOE operations & documented the remaining ones.
Removed/simplified superfluous uses of IOE operations.
2014-11-10 16:20:01 +00:00
hallgren
0519493ca9 Use terminfo to highlight warnings and errors in blue and red
This replaces the hardwired ANSI escape codes that were accidentally included
in a previous patch.

This adds a dependency on terminfo, but this should be unproblematic, since
haskeline already depends on the same underlying C library.

The color highlighting is omitted on Windows.
2014-10-28 19:04:48 +00:00
hallgren
f085b807eb A couple of haddock documentation improvements 2014-10-28 14:58:43 +00:00
hallgren
391b301881 ModuleName and Ident are now distinct types
This makes the documentation clearer, and can potentially catch more
programming mistakes.
2014-10-21 19:20:31 +00:00
hallgren
3bfcfa157d Renaming SourceGrammar to Grammar and similarly for some related types
Included renamings:

	SourceGrammar -> Grammar
	SourceModule -> Module
	SourceModInfo -> ModuleInfo
	emptySourceGrammar -> emptyGrammar

Also introduces a type synonym (which might be good to turn into a newtype):

	type ModuleName = Ident

The reason is to make types like the following more self documenting:

	type Module = (ModuleName,ModuleInfo)
	type QIdent = (ModuleName,Ident)
2014-10-21 14:42:31 +00:00
hallgren
8337a19b40 type IOE a = IO a
IOE used to be a monad with extra error handling built on top of the IO monad,
But the IO monad already supports error handling, so this construction was a
superfluous.

The new 'instance ErrorMonad IOE' is defined to preserve the previous error
handling behaviour, i.e. the function 'handle' only catches errors thrown with
'raise' (or 'fail') and not other errors in the IO monad.
2014-10-20 19:32:46 +00:00
hallgren
55aebadd5a Remove some dead code
* The following modules are no longer used and have been removed completely:

	GF.Compile.Compute.ConcreteLazy
	GF.Compile.Compute.ConcreteStrict
	GF.Compile.Refresh

* The STM monad has been commented out. It was only used in
  GF.Compile.SubExpOpt, where could be replaced with a plain State monad,
  since no error handling was needed. One of the functions was hardwired to
  the Err monad, but did in fact not use error handling, so it was turned
  into a pure function.

* The function errVal has been renamed to fromErr (since it is analogous to
  fromMaybe).

* Replaced 'fail' with 'raise' and 'return ()' with 'done' in a few places.

* Some additional old code that was already commented out has been removed.
2014-10-20 15:05:43 +00:00
hallgren
c924491289 More haddock documentation improvements 2014-10-16 14:03:57 +00:00
hallgren
393dde2eb9 Fixes for the haddock documentation 2014-10-15 20:42:36 +00:00
hallgren
4eb6b55e98 (1) Refactor concurrency, (2) write to .gfo.tmp then rename to .gfo
(1) introduces the module GF.Infra.Concurreny with lifted concurrency
    operators (to reduce uses of liftIO) and some additional concurrency
    utilities, e.g. a function for sequential logging that is used in
    both GF.CompileInParallel and GFServer.
(2) avoids leaving broken .gfo files behind if compilation is aborted.
2014-09-08 15:43:20 +00:00
hallgren
fdf7d06f9a Fix GHC 7.4 compatibility issue caused by previous patch 2014-08-25 11:26:58 +00:00
hallgren
d84c5ef171 Experimental: parallel batch compilation of grammars
On my laptop these changes speed up the full build of the RGL and example
grammars with 'cabal build' from ~95s to ~43s and the zero build from ~18s
to ~5s.

The main change is the introduction of the module GF.CompileInParallel that
replaces GF.Compile and the function GF.Compile.ReadFiles.getAllFiles. At
present, it is activated with the new -j flag, and it is only used when
combined with --make or --batch. In addition, to get parallel computations,
you need to add GHC run-time flags, e.g., +RTS -N -A20M -RTS, to the command
line.

The Setup.hs script has been modified to pass the appropriate flags to GF
for parallel compilation when compiling the RGL and example grammars, but you
need a recent version of Cabal for this to work (probably >=1.20).

Some additonal refactoring were made during this work. A new monad is used to
avoid warnings/error messages from different modules to be intertwined when
compiling in parallel, so some functios that were hardiwred to the IO or IOE
monads have been lifted to work in arbitrary monads that are instances in
the appropriate classes.
2014-08-25 09:56:00 +00:00