Commit Graph

181 Commits

Author SHA1 Message Date
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
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
Denis Buzdalov
c121181776
Function mapping Not (x=True) to x=False was added for Bools (#322) 2020-06-19 11:13:13 +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
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
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
Edwin Brady
e6f6c105d1 Reflection primitives for querying names/types
See reflection003 test for some examples
2020-06-01 14:26:37 +01:00
Edwin Brady
e2aabd6602 Add syntax for quoting names
`{{ n }} gives a value of type Name. No name resolution is attempted (so
no namespaces added etc)
2020-06-01 13:39:18 +01:00
Edwin Brady
2eb2ce6097 Add Bits primitives
Including appropriate casts, and Num/Eq/Ord/Show implementations.
Also includes new primitives in Data.Buffer, and calls to foreign
functions in C as 'unsigned'.
2020-06-01 11:48:03 +01:00
Edwin Brady
106235c165 Allow scripts to inspect goal
If available (sometimes, say a top level expression, it might need
inferring so there'll be no goal available). Also add the ability to log
the current goal, or indeed any term.
2020-05-31 14:33:34 +01:00
Edwin Brady
85c002c771 Progress on elaborator reflection
Add %runElab and start on scripts, although all they can do so far is
check a term. This does gives us, sort of, "template Idris" (as
demonstrated in test reflection002)
2020-05-31 01:36:54 +01:00
Edwin Brady
26e6e1ed82 Calculate compile time references even in case
If we don't do this, we don't look inside case blocks to check they
cover, and so we might miss coverage errors in nested case blocks.
Fixes #202
2020-05-30 21:53:29 +01:00
Edwin Brady
ecaa73bad5 Update test result
Not sure why this didn't fail for me locally... possibly libraries out
of sync.
2020-05-30 17:30:31 +01:00
Edwin Brady
3f914889b8 Add visibility rules on types
Can't export a type which refers to a private name. This has caught a
couple of visibility errors in the libraries, code and tests, so they've
been updated too.
2020-05-30 17:03:15 +01:00
Edwin Brady
e1dbcad2fc Make a start on reflection
Don't get too excited yet - I want this in so that it doesn't get too
out of sync, but I still have to think about exactly how it's going to
work in practice.
2020-05-29 22:40:29 +01:00
Edwin Brady
d869eb666c Experiment %syntactic flag on with
This means it abstracts over the value syntactically, rather than by
value, and can significantly speed up elaboration where large types are
involved, at a cost of being less general. Try it if "with" is slow.

There are more flags we want on with (well, at least one: "proof")
2020-05-29 16:39:11 +01:00
Edwin Brady
aad56c723f
Merge pull request #191 from edwinb/totality
Totality checking
2020-05-28 16:28:06 +01:00
Edwin Brady
8c5d5055fa Update scheme
Changing the prelude totality default means we need to update the scheme
to be able to cope with its new meaning
2020-05-28 16:05:08 +01:00
Tim Süberkrüb
42a1522a3b Try to make Windows happy with backslashes 2020-05-28 16:42:56 +02:00
Edwin Brady
2223d50c3a Skip totality check on case blocks and MNs
These are checked as part of checking the top level names
2020-05-28 15:32:46 +01:00
Tim Süberkrüb
c2dfe7de7f Add popen and pclose from Idris 1 2020-05-28 12:58:03 +02:00
Niklas Larsson
696db7f58f
Merge pull request #169 from andylokandy/pathcom
Use Path in the compiler
2020-05-27 21:23:29 +02:00
Edwin Brady
c88bf7af8d Fix import loading
This was taking too long, and adding too many things, because it was
going too deep in the name of having everything accessible at the REPL
and for the compiler. So, it's done a bit differently now, only chasing
everything on a "full" load (i.e., final load at the REPL)

This has some effects:
+ As systems get bigger, load time gets better (on my machine, checking
  Idris.Main now takes 52s from scratch, down from 76s)
+ You might find import errors that you didn't previously get, because
  things were being imported that shouldn't have been. The new way is
  correct!

An unfortunate effect is that sometimes you end up getting "undefined
name" errors even if you didn't explicitly use the name, because
sometimes a module uses a name from another module in a type, which then
gets exported, and eventually needs to be reduced. This mostly happens
because there is a compile time check that should be done which I
haven't implemented yet. That is, public export definitions should only
be allowed to use names that are also public export. I'll get to this
soon.
2020-05-27 15:49:03 +01:00
Jan de Muijnck-Hughes
8b062f47cc Allow cli given option overriding for ipkg cmds.
As it was in Idris1 being able to override some, or introduce new, options to an Idris IPKG is beneficial. For example, generate code for multiple codegens from a single source.

Overridable options are:

+ `--quiet`
+ `--verbose`
+ `--timing`
+ `--dumpcases <file>`
+ `--dumplifted <file>`
+ `--dumpvmcode <file>`
+ `--debug-elab-check`
2020-05-26 14:41:09 +01:00
Jan de Muijnck-Hughes
54fd78a956 Fixed fragility of ipkg file parsing.
+ Explicitly check if an IPKG has the correct suffix.
+ Add missing case that could return a malformed error message.
2020-05-26 14:41:09 +01:00
Jan de Muijnck-Hughes
68a4ad2e1c New test for detecting overridable options for IPKG commands. 2020-05-26 14:41:09 +01:00
andylokandy
712a4df140 Gather the straw isWindowss 2020-05-26 17:59:14 +08:00
Jinwoo Lee
4a52a84113 update golden files 2020-05-25 10:06:52 -07:00
Edwin Brady
81e9214c6f Fix build
Showing a hole should show normalised types for the locals
2020-05-25 16:45:33 +01:00
Edwin Brady
bbd3986cfc
Merge pull request #153 from ohad/ide-protocol-holes
Ide protocol holes
2020-05-25 15:43:52 +01:00
Edwin Brady
3120fcb84a Allow _ for names in pi binders
This is mostly to make it easier to write linear function types without
having to invent names for everything, which might be noisy. Also it
improves the display of linear function types when the name isn't used
in the scope.
2020-05-25 13:14:51 +01:00
Ohad Kammar
f4797be529 Merge branch 'master' of github.com:idris-lang/Idris2 into ide-protocol-holes 2020-05-25 11:51:39 +01:00
Ohad Kammar
92eaa247a6 Refactor FoundHoles : REPLResult to carry more structured information about holes 2020-05-25 10:38:22 +01:00
Edwin Brady
227bd3b457
Merge pull request #119 from idris-lang/idemode
[ refactor ] Idris.IDEMode.CaseSplit
2020-05-25 09:09:37 +01:00
Edwin Brady
9970c66417 Warn on detecting unreachable patterns
I don't know how complete this is, but it certainly detects some of the
most obvious cases which are most likely to be bugs.

While I'm at it, this is as good a time as any to add a general way of
reporting warnings, similar to the way of reporting errors.
2020-05-25 00:16:49 +01:00