Commit Graph

210 Commits

Author SHA1 Message Date
Edwin Brady
6c007fc046 Use full names for constructors in case split
Fixes #184
2020-06-27 15:47:38 +01:00
Rui Barreiro
08823658cd node tests pass 2020-06-26 20:42:40 +01:00
Niklas Larsson
8d75d70fac
Merge pull request #342 from csabahruska/master
add unit test for constructor duplicate
2020-06-25 10:39:25 +02:00
Edwin Brady
908742c2a8 Update tests
Seemed I hadn't cleaned thoroughly enough...
2020-06-24 23:53:42 +01:00
Edwin Brady
ebc413ede5 Postpone elaborating lambdas
It's worth delaying in case doing some more work (and some more
interface resolution) can make the type more concrete. This makes
test linear011 work more smoothly, and will help with this sort of
program in general.

A better way, later, would be to try elaborating and delay only if the
type is not yet known. We have the facilities, but it's too fiddly for
me to want to implement it right now...
2020-06-24 23:27:45 +01:00
Edwin Brady
854804dbfb Determining argument check below top level
We need to check below top level too, since there could be holes that
we're happy to resolve by searching. The linearity test added
illustrates a place where this is needed.
2020-06-24 22:07:52 +01:00
Edwin Brady
d8abf3b74e
Merge pull request #337 from MarcelineVQ/unelab-name
change how unelabBinder shows names
2020-06-24 17:52:57 +01:00
Edwin Brady
8540d2fb9a Add experimental library for linear computations
In Control.Linear.LIO - allows wrapping anything that supports chaining
of linear computations (most usefully, IO).
2020-06-23 23:11:48 +01:00
Rui Barreiro
7c7f7efe04 test node019 runs 2020-06-22 20:57:25 +01:00
Stiopa Koltsov
c140605a0f Extract Prelude.Basics, Prelude.Uninhabited from Prelude 2020-06-22 18:10:06 +01:00
Edwin Brady
1e6314c4cc
Merge pull request #345 from edwinb/hasio
HasIO interface for IO actions
2020-06-21 20:24:29 +01:00
MarcelineVQ
d94b86e62c change namespace parser to have minimum indentation
The namespace parser was not requiring a minimum indentation and instead
based its indentation on the following line, which meant that a line like:

namespace Foo
foodef : Int

placed foodef into namespace Foo instead of the module's top level.
And so made it unclear when a namespace ends.
2020-06-21 20:17:00 +01:00
Edwin Brady
dbdf7dab3d Back to HasIO, remove MonadIO
Following a fairly detailed discussion on slack, the feeling is
generally that it's better to have a single interface. While precision
is nice, it doesn't appear to buy us anything here. If that turns out to
be wrong, or limiting somehow, we can revisit it later. Also:

- it's easier for backend authors if the type of IO operations is
  slightly less restrictive. For example, if it's in HasIO, that limits
  alternative implementations, which might be awkward for some
  alternative back ends.
- it's one less extra detail to learn. This is minor, but there needs to
  be a clear advantage if there's more detail to learn.
- It is difficult to think of an underlying type that can't have a Monad
  instance (I have personally never encountered one - if they turns out
  to exist, again, we can revisit!)
2020-06-21 19:21:22 +01:00
Rui Barreiro
ca0c8f9d42 node018 passes 2020-06-21 17:54:50 +01:00
Edwin Brady
1b15463746 Update libraries and docs with HasIO/MonadIO 2020-06-21 15:25:40 +01:00
Edwin Brady
28855088c2 Split HasIO into HasIO and MonadIO
For things which don't require (>>=), HasIO is fine, otherwise MonadIO
gives access to the monad interface.
2020-06-21 14:46:14 +01:00
MarcelineVQ
6f77c06e3e reduce sugar in confusing error messages
This addresses the case where you'd see an error of:

Ambiguous elaboration at:
	r <- pure []
Possible correct results:
	[]
	[]
	[]
By changing it to:

Possible correct results:
	Main.Nil
	PrimIO.Nil
	Prelude.Nil
2020-06-21 11:46:08 +01:00
Edwin Brady
d12487f529 HasIO interface for IO actions
Also updates the Prelude and some base libraries to use HasIO rather
than using IO directly.
2020-06-21 01:18:43 +01:00
Csaba Hruska
6de225e4be add unit test for constructor duplicate 2020-06-20 23:39:03 +02:00
Niklas Larsson
d31e59bacf
Merge pull request #327 from chrrasmussen/add-builddir-and-output-dir
Allow overriding build and output directory
2020-06-20 20:52:33 +02:00
Niklas Larsson
0d2871db3c
Merge pull request #315 from ShinKage/repl-import-module
Module command to import module in REPL
2020-06-20 20:51:17 +02:00
Christian Rasmussen
3cbcdec4a0 Add test for builddir and outputdir fields 2020-06-20 17:24:05 +02:00
Christian Rasmussen
1f0ca85678 Allow overriding the build directory and the output directory
The output directory was previously called the executable directory, but I changed it because the output is not always an executable (depending on the code generator).

The code generators can now distinguish between where to place the (temporary) build files and the resulting output files.
2020-06-20 17:23:51 +02:00
Rui Barreiro
1d2f3d8883 Merge branch 'master' of github.com:idris-lang/Idris2 into javascript 2020-06-20 15:11:08 +01:00
Edwin Brady
8c556d0c26
Merge pull request #340 from edwinb/strefs
Control.Monad.ST and Refs interface
2020-06-20 13:16:27 +01:00
MarcelineVQ
a44c8ddd5a change how unelabBinder shows names
unelabBinder was losing information for the purpose of displaying names
nicely. This is typically wanted but when working with elabortation it's
useful to have all the information you can get. Things like record field
names would be lost when querying with GetType but are now retained.
2020-06-19 22:54:05 -07:00
Edwin Brady
ab03249d49 Add Data.STRef and a generic Ref interface 2020-06-20 00:46:20 +01:00
Rui Barreiro
525011eaff test node006 2020-06-19 17:00:59 +01:00
Denis Buzdalov
c121181776
Function mapping Not (x=True) to x=False was added for Bools (#322) 2020-06-19 11:13:13 +01:00
Rui Barreiro
f8f09858e8 Merge branch 'master' of github.com:idris-lang/Idris2 into javascript 2020-06-17 23:48:39 +01:00
Rui Barreiro
cb7dc7bffc test node004 passes 2020-06-17 23:29:54 +01:00
Kamil Shakirov
4f0c262ddc Add support for OpenBSD
and probably for other *BSD operating systems with minor tweaks
2020-06-17 15:14:54 +06:00
Giuseppe Lomurno
cd1730f0ab Add module REPL command 2020-06-16 17:29:10 +02:00
Niklas Larsson
2e8f618f00 Apparently overwrite should report success 2020-06-16 14:02:04 +02:00
Niklas Larsson
24715a8fd0 Overwrite should be true in the first call
In case anybody has that defined in their environment.
2020-06-16 13:48:31 +02:00
Niklas Larsson
8540728202 Handle overwrite on windows
Expand test to test overwrite
2020-06-16 13:44:10 +02:00
Niklas Larsson
6974b318a3 Add test for setenv and unsetenv 2020-06-16 12:36:39 +02:00
Niklas Larsson
e32700cff8 Add test
It takes a long time to run, but it is basically all
the testing we need of the API, if this works it's
unlikely to be broken. It requires  a change in the build
system, so don't enable it for now.
2020-06-15 16:11:08 +02:00
Giuseppe Lomurno
788ae023e3 Merge remote-tracking branch 'upstream/master' into code-in-errors 2020-06-15 15:12:49 +02:00
Niklas Larsson
4dc151086c
Merge pull request #283 from timsueberkrueb/more-file-io
Extend Control.App.FileIO
2020-06-15 14:13:17 +02:00
Alex Gryzlov
2912b194d5 fix coverage010 2020-06-15 13:22:04 +02:00
Alex Gryzlov
2ee42e777a Merge remote-tracking branch 'upstream/master' 2020-06-15 03:01:57 +02:00
Giuseppe Lomurno
c995fe4a01 Merge remote-tracking branch 'upstream/master' into code-in-errors 2020-06-13 18:20:12 +02:00
Giuseppe Lomurno
778d930f95 Updated tests 2020-06-13 16:51:05 +02:00
Rui Barreiro
184dce2312 fixed my tests messup 2020-06-13 11:45:53 +01:00
Rui Barreiro
c015aa82b0 test node003 passes 2020-06-13 11:42:28 +01:00
Rui Barreiro
fa7b6f12d2 Merge branch 'master' of github.com:idris-lang/Idris2 into javascript 2020-06-12 21:43:09 +01:00
Rui Barreiro
33014403eb tests everywhere 2020-06-12 21:35:08 +01:00
Niklas Larsson
a33fc1ec16
Merge pull request #256 from vilunov/repl-package
"--repl" command for opening a REPL in a package
2020-06-12 17:50:50 +02:00
Tim Süberkrüb
e9a80891b7 Extend Control.App.FileIO 2020-06-12 17:30:54 +02:00
Alex Gryzlov
4fffdec6e8 Merge remote-tracking branch 'upstream/master' 2020-06-12 16:39:37 +02:00
Edwin Brady
c3c556f192 Merge https://github.com/idris-lang/Idris2 into linear-things 2020-06-12 14:16:01 +01:00
Niklas Larsson
4b7fbb0371 Fix overly nitpicky reflection test
See #287
2020-06-12 12:46:19 +02:00
Edwin Brady
c9b20911e1 Add linear pair/dependent pair to the prelude
I'm playing with some linear structures and finding these useful a lot,
so good to have a consistent syntax for it. '#' is chosen because it's
short, looks a bit like a cross if you look at it from the right angle
(!) and so as not to clash with '@@' in preorder reasoning syntax.
2020-06-12 11:18:12 +01:00
Alex Gryzlov
cd443f24f6 various stdlib updates 2020-06-11 23:14:11 +02:00
Giuseppe Lomurno
e9d46a2650 Fixed tests 2020-06-11 22:46:36 +02:00
Kevin Boulain
c148003265 Fix MkRecord signature
Otherwise we'd get:
  When unifying Name and Maybe Name
  Mismatch between:
          Name
  and
          Maybe Name
  Can't reify as Decl
2020-06-11 21:54:40 +02:00
Edwin Brady
361d2e4d88
Merge pull request #275 from idris-lang/issue-270
[ re #270 ] Mention the target type of the auto search
2020-06-11 16:14:16 +01:00
Guillaume ALLAIS
43738c172d [ re #270 ] Mention the target type of the auto search 2020-06-11 14:28:34 +01:00
Guillaume ALLAIS
f3c0e89ae8 [ re #238 ] Adding --no-index and --word-diff=color
Without --no-index, git compares the files with their state in HEAD.
But we want to compare them to each other! This explain why we were
getting no output whatsoever.

With --word-diff=color, we can easily spot the small changes anywhere in
a line.
2020-06-11 14:23:47 +01:00
Niklas Larsson
015f195b87
Merge pull request #272 from melted/fix_primitive_bootstrap
Use 2^64 constant instead of calculation
2020-06-11 15:13:40 +02:00
Niklas Larsson
b5f67b94ae Use constants instead of calculation for upper bounds
Add wrapping to 8-bit adding.

This is a workaround to fix the bootstrap
Fixes #268
2020-06-11 14:23:41 +02:00
Jan de Muijnck-Hughes
63e127094e Improved parsing for literate modes.
The tokenizer for literate modes was incorretly detecting code lines in text.
This PR fixes that, and allows for empty code lines.
2020-06-11 12:51:47 +01:00
Rui Barreiro
c2d994ad5c first test 2020-06-11 10:52:54 +01:00
Edwin Brady
df3449f44b Fix the other clashing test output
I don't understand the difference here - there's probably a commit I
hadn't merged earlier that affected the name generation.
2020-06-10 13:08:50 +01:00
Edwin Brady
c07876d1a3 Fix clashing test output 2020-06-10 12:53:18 +01:00
Edwin Brady
004b41a3d8 Merge https://github.com/idris-lang/Idris2 into vis-case-with 2020-06-10 12:50:30 +01:00
Edwin Brady
42676d2504
Merge pull request #265 from edwinb/find-ipkg-ide
In IDE mode, look for a ipkg file before loading
2020-06-10 12:42:59 +01:00
Edwin Brady
0cc54ff145 Propagate visibility appropriately to case/with
If a function is public export, the local definitions also need to be
public export for it to reduce properly. But if they're not, we don't
want them exported or they might affect the module hash and cause
unnecessary rebuilds.
2020-06-10 12:41:02 +01:00
Jan de Muijnck-Hughes
90fb901c8f Fix test reporting when in interactive mode.
When runing in interactive mode, the diff between expected and output is not being show,
Supposedly, Git-diff returns 0 on successful run and a non-zero for error.
However, this is not being picked up by the test suite.

We change git-diff's error reporting to be more diff like in which:

+ +ve indicates that there is a diff.
+ 0 indicates the files are the same.
+ -ve program error.

This should make diff reporting more robust.
2020-06-10 09:30:02 +01:00
Edwin Brady
cf23bae7d6 In IDE mode, look for a ipkg file before loading
This takes the responsibilty of finding the ipkg away from IDE mode,
which seems sensible given that we can do it ourselves. If there isn't
one, it'll load from the local directory as always.
2020-06-09 23:31:30 +01:00
Edwin Brady
ca28dab1d7 Add finalisers for Racket back end
Like Chez, we also need an explicit call to the garbage collector at the
end to ensure that all the finalisers get run on exit.
2020-06-08 22:13:24 +01:00
Edwin Brady
e32f039227 Fix includes in chez022 test 2020-06-08 20:46:25 +01:00
Edwin Brady
d60feaace0 Add finalisers to Chez back end
This involves new primitives GCPtr and GCAnyPtr which are pointer types
that have finalisers attached. The finalisers are run when the
associated pointer goes out of scope.

In the test, I am assuming that the GC will only be called once, right
at the end. Otherwise, the output isn't guaranteed to be deterministic!
Let's see how this assumption holds...

This is currently Chez only. I think it'll be easy enough to add to
the Racket and Gambit back ends too.
2020-06-08 20:34:23 +01:00
Nikita Vilunov
560d472502 add a test for --repl 2020-06-08 19:21:22 +03:00
Edwin Brady
85bd751283 Update reflection test again 2020-06-08 13:22:18 +01:00
Edwin Brady
abcb1b417f
Merge pull request #248 from vilunov/repl-let
":let" command for REPL
2020-06-08 12:00:15 +01:00
Edwin Brady
73de552776
Merge pull request #239 from MarcelineVQ/elab-changes
add parens for some TTImp Shows
2020-06-08 11:54:19 +01:00
Edwin Brady
4834f2f78c Update test output
Clash in a reflection test due to conflicting merges. I'd like to find a
way to make the internally generated numbers not matter here (and
elsewhere) but I don't see an obvious way.
2020-06-08 10:39:58 +01:00
Edwin Brady
e033609310
Merge pull request #207 from mb64/assert_smaller-linear
Make assert_smaller and assert_total linear
2020-06-08 10:19:33 +01:00
Edwin Brady
d47d495744 Free standing case blocks return ()
Fixes #116. This is the solution Idris 1 took, and while it is a special
case, the syntax does make it explicit (in a way) that the result of the
case is unused - if you mean something other than (), you must now say
so!
2020-06-07 22:49:19 +01:00
Nikita Vilunov
018c17b69a Add :let test 2020-06-07 16:40:45 +03:00
MarcelineVQ
6993c6df6b add parens for some TTImp Shows
helps with readability since these, especially named-IPi, come up a lot
didn't change everything that could need it like PiInfo or BindMode
PiInfo rarely has DefImplicit (so far) and BindMode hasn't come up a lot (so far)
reduced indentation for TTImp Show implementation
2020-06-06 17:16:43 -07:00
Edwin Brady
93022af74e More explicitness in evaluator return type
Another one from the "stop trying to be clever" files :). Instead of a
continuation for fallthrough in the evaluator, be explicit about whether
there's a result, no match, or evaluation is stuck.
Fixes #70
2020-06-06 22:20:25 +01:00
Edwin Brady
252e07833b Fix case trees at multiplicity zero
Can't ignore a constructor a multiplicity zero if the whole function is
multiplicity zero
2020-06-06 20:45:20 +01:00
Edwin Brady
c17d4ff0a5 Look inside case blocks in conversion check
This is quite fiddly as it the blocks might be in different contexts so
we need to keep track of which variables correspond in the scrutinees of
the blocks. Once that's done, check the terms at the leaves convert,
then check the corresponding variables convert.

This may not be perfect yet, because we only look at case scrutinees to
find correspondence. It might also be a bit slower than it could be, but
at least these checks are quite rare.

Fixes #208 and maybe some others?
2020-06-04 18:21:44 +01:00
Edwin Brady
946e1b3a51 Slightly neater reflection008 test 2020-06-03 09:25:09 +01:00
Edwin Brady
3a7aedf0f4 Add reflection under (explicit) binders
This allows writing a staged well typed interpreter, for example (see
reflection008 test)
2020-06-03 09:17:37 +01:00
Edwin Brady
c682ded9c4 Reduce amount of normalisation in elab scripts
We don't want to unfold definitions in 'pure' or 'check' or 'bind' since
we want the exact expression that the script author has used.
2020-06-03 00:22:03 +01:00
Edwin Brady
d8d13d912e Add alternative example to reflection002
A bit more typesafe...
2020-06-02 23:56:30 +01:00
Edwin Brady
08b56e9e75 Add quote operation to Elab
Allows quoting a term back to a TTImp. Test reflection007 shows one
possible use for this, building a reflected, type safe, representation
of an expression.
2020-06-02 23:36:20 +01:00
Edwin Brady
2a75731916 In reflection, check now takes a concrete type
So the type of Elab now gives the expected type that's being elaborated
to, meaning that we can run 'check' in the middle of scripts and use the
result.
2020-06-02 22:41:37 +01:00
Edwin Brady
9fab367f0f Reflect differently on LHS
On the LHS, we want to match against the reflected thing, so FC and
implicits need to turn into match anything patterns, or we won't match
anything at all. This means we can put quoted terms on the LHS, with
pattern variables under ~().
2020-06-02 19:21:46 +01:00
Edwin Brady
c3ee2a3fac Change genSym behaviour
Instead of merely generating a locally unique name, use the existing
code for generating a new unique variable name in the unifier, which is
therefore globally unique.
2020-06-02 12:13:38 +01:00
Mark Barbone
c4cdebb578
Fix tests 2020-06-01 19:13:46 -04:00
Edwin Brady
1c18fe589b Forgot to add the new test again, didn't I... 2020-06-01 19:13:46 +01:00
Edwin Brady
3d2765e930 Add top level %runElab
This invokes a script of type Elab (). %runElan in a term invokes a
script of type Elab TT. The elaborator now pushes in that type, so that
it'll report an appropriate error if you give it a script of the wrong
type.
2020-06-01 19:06:10 +01:00
Edwin Brady
d5b5af91d1 Implement %macro flag
A %macro must always be fully applied. Whenever the elaborator
encounters a %macro application (except in a function LHS) it evaluates
the application and sends the result to %runElab. So:

%macro
foo : args -> Elab TT
...
def = foo a b c

is equivalent to

foo : args -> Elab TT
...
def = %runElab foo a b c
2020-06-01 17:55:54 +01:00
Edwin Brady
d45f92fd97 Add some reflected name manipulation
genSym, for generating a unique global name, and inCurrentNS for putting
a name in the current namespace.
2020-06-01 15:13:42 +01:00
Edwin Brady
02d371a94b Add reflection operation for adding declarations
Declarations can be quoted with `[ decl ]. See reflection004 for an
example.
2020-06-01 15:01:52 +01:00