Commit Graph

754 Commits

Author SHA1 Message Date
stefan-hoeck
ed9a21f6bc [ new ] support prim__putStr in browser 2021-08-24 03:44:57 +00:00
Daniel Kröni
370a273b35 Inline Neg implementations 2021-08-17 19:34:52 +01:00
stefan-hoeck
1e8f9b3c36 [ fix ] export Show instance for Bounds 2021-08-15 08:49:19 +01:00
Denis Buzdalov
dd7d77d416 [ visibility ] Make Monad of Vect to the visible from outside 2021-08-13 18:59:54 +01:00
Denis Buzdalov
c29dc73c62 [ base ] Add semigroup and monoid instances for Vect 2021-08-13 18:59:54 +01:00
Denis Buzdalov
23bb381f0f [ cleanup ] Small code cleanup, less mutual block and one \case use 2021-08-12 12:38:06 +01:00
Denis Buzdalov
940f588890 [ ttimp ] Add a utility function returning an FC by TTImp 2021-08-11 14:18:41 +01:00
Denis Buzdalov
c3398274d5 [ elab ] Add an ability to fail elab script with a custom FC 2021-08-11 14:18:41 +01:00
Denis Buzdalov
8fb18e24a1 [ fix ] Make standard monad transformer's Alternative be lazy on 2nd arg 2021-08-11 11:33:46 +01:00
Denis Buzdalov
99f1e11ddb [ cleanup ] Slightly improve readability 2021-08-11 11:33:46 +01:00
Denis Buzdalov
9357d777f6 [ base ] Relax requirement of Alternative implementation for ReaderT 2021-08-11 11:33:46 +01:00
G. Allais
21c6f4fb79
[ breaking ] remove parsing of dangling binders (#1711)
* [ breaking ] remove parsing of dangling binders

It used to be the case that

```
ID : Type -> Type
ID a = a

test : ID (a : Type) -> a -> a
test = \ a, x => x
```

and

```
head : List $ a -> Maybe a
head [] = Nothing
head (x :: _) = Just x
```

were accepted but these are now rejected because:

* `ID (a : Type) -> a -> a` is parsed as `(ID (a : Type)) -> a -> a`
* `List $ a -> Maybe a` is parsed as `List (a -> Maybe a)`

Similarly if you want to use a lambda / rewrite / let expression as
part of the last argument of an application, the use of `$` or parens
is now mandatory.

This should hopefully allow us to make progress on #1703
2021-08-10 19:24:32 +01:00
Tim Engler
be37e5b458 Added "lookupBetween" "leftMost" and "rightMost" to Data.SortedMap 2021-08-10 09:42:53 +01:00
Denis Buzdalov
15ccebbcf2 [ contrib ] Implementation of Zippable was added for Validated 2021-08-09 10:06:20 +01:00
Alex Humphreys
f3855d7100
Update contrib Text.Parser to match Library.Text.Parser (#1808)
Co-authored-by: Guillaume ALLAIS <guillaume.allais@ens-lyon.org>
2021-08-06 10:03:13 +01:00
Zoe Stafford
1669fc351b
Refactor %builtin (#1803)
* Stub for future 'identity' optimisation
I plan to add this later, but I'm using for now for
NaturalToInteger and IntegerToNatural

* Refactor `%builtin`
fixes #1799

- automatically optimise all Natural shaped things
- NaturalToInteger and IntegerToNatural now use
  new `Identity` flag (internal use only for now)
  which signals the function is identity at runtime

* Use NaturalToInteger and IntegerToNatural for Nat and Fin
Also define show fin in terms of finToInteger, for speed

* Fix name handling for %builtin

* [ tests ] fixes + #1799

* remove %builtin from libs
Add back after next version

* Use resolved names where convenient
2021-08-03 14:19:17 +01:00
Sventimir
4920601fe9
Add tests for Nat ranges and fix bad range [1,2..1] behaviour. (#1794)
Co-authored-by: Marcin Pastudzki <marcin.pastudzki@gmail.com>
2021-07-28 06:52:59 +01:00
Guillaume ALLAIS
c48fe486fa [ cleanup ] on is meant to be used with 2 arguments
The previous definition means it won't reduce until it's applied to
4 arguments which may have detrimental effects: ``f `on` fst`` would
for instance stay blocked, with some implicit arguments of the form
`DPair a b`. This means that `b` appears in a negative position in
the expression which may lead to positivity checking rejecting a
datatype defined using `on`!

I have decided to leave `g` and `f` on the LHS because I expect `on`
to be used either:
  1. partially applied to two arguments
  2. in a section if only applied to 1 and sections get eta-expanded
     by the parser so that's fine.
2021-07-27 13:58:41 +01:00
Guillaume ALLAIS
31ffb4e5c7 [ cleanup ] various public export & cleanup
Turns out that `Smaller` and `LT` won't unify because
1. the instance Sized Nat is not publicly exported
2. Smaller, and LT are stuck until fully applied

The given changes make that go away.
2021-07-27 09:06:20 +01:00
Guillaume ALLAIS
13ef8ba707 [ fix #1782 ] remove the case-specific code
I can't make sense of this code, it seems to try to convert the
case function corresponding to `let (a, b) = f n in ...` into a
different case function where `f n` and `(a, b)` have been unified.
But if `f n` is a bona fide stuck computation, there's no chance of
this happening.

Just turning this off solves the #1782 and only breaks one function
in the whole of the idris2 repo (I would have expected our current
termination oracle to be too weak to detect it as valid anyway!)
and one in frex (which, again, should not have been seen as terminating).

Also fixes #1460
2021-07-26 17:03:16 +01:00
Guillaume ALLAIS
230f42b697 [ re #1771 ] Do not use Erased to go under binders
In the `MkFix : f (Fix f) -> Fix f` example, using `Erased` for `f`
makes the type reduce to `[__] (Fix [__]) -> Fix [__]` and because
`[__] e1 ... en` computes to `[__]`, we end up with `[__] -> Fix [__]`
which does not reference `Fix` anymore.
2021-07-23 13:30:24 +01:00
André Videla
5576d30c27
Merge pull request #1736 from stepancheg/test-discovery
Implement test discovery
2021-07-22 08:56:02 +00:00
Ben Hormann
74db7714d4
[fix] Loading libidris2_support.dll with Racket (#1583) 2021-07-21 14:35:21 +01:00
Mathew Polzin
5f34801200 Make drop and drop' public exported from the vect module. 2021-07-20 14:27:43 +01:00
Nick Drozd
ab36ad71cf Simplify a few Factor proofs
A few proofs have been rewritten, a few unnecessary cases cut, and
lots of unnecessary "explicit implicits" have been cut. Probably these
implicits were required when the code was initially written, and
inference has improved since then.
2021-07-19 08:30:47 +01:00
Stiopa Koltsov
7325002dec Implement test discovery
`testInDir dir ...` lists all directories in `dir` which contains
`run` files, and such directories are considered tests.

This is done to make test addition/maintenance cheaper.

Convert some test directories to `testInDir`, but not all of them
because
* some directories are listed in several test groups
* other directories are have some tests disabled
2021-07-17 16:53:43 +01:00
Stiopa Koltsov
4eff6ac916 System.Directory.listDir
This function is what users want 99.9% of time.
2021-07-17 14:58:57 +01:00
Stiopa Koltsov
c7629e20fe Skip dot and dot-dot in nextDirEntry
These entries returned by `readdir` are legacy of Unix API, we don't
really need them. Most APIs do not return them (for example Java
`Files.newDirectoryStream` or Python `os.listdir`).
2021-07-17 14:58:28 +01:00
Stiopa Koltsov
0ecf74e434 System.Directory.nextDirEntry
* add `nextDirEntry` which returns `Maybe String`, so `Nothing` on
  the end of directory unlike `dirEntry` which returns unspecified error
  on the end of directory
* `dirEntry` is deprecated now, but not removed because compiler depends on it
* native implementation of `dirEntry` is patched to explicitly reset `errno`
  before the `readdir` call: without it end of directory and error were
  indistinguishable
* test added
2021-07-17 14:57:27 +01:00
Stepan Koltsov
ce44d3b50a
Change semantics of lines and unlines function to match Haskell and other languages (#1585)
* Add trailing newline on non-empty list in unlines

There are several reasons to do that:
* a line in a text file is something which ends with newline,
  and the last line is not special
* `unlines []` should be different from `unlines [""]`
* `unlines (a ++ b) = unlines a ++ unlines b`
* Haskell does it

* Change lines function behaviour
2021-07-17 14:54:23 +01:00
Stiopa Koltsov
5a351f4e7e Accept HasIO in onCollect functions
Since most functions work with `HasIO`, it is more convenient to
accept `HasIO` in `onCollect` and `onCollectAny`.
2021-07-17 14:42:34 +01:00
Alex Humphreys
f195aed2cd [ Test ] allow 'N' as an acceptable response
Situation I just ran into that I found confusing:
```
Golden value differs from actual value.
Accept actual value as new golden value? [y/N]
N
Invalid answer.
```
2021-07-17 13:29:13 +01:00
Zoe Stafford
0fec867583 [ fix ] Name in Language.Reflection.TT
This was different to `Name` in `Core.Name`
Specifically `CaseBlock` and `WithBlock` had an `Int` instead of a `String`
2021-07-16 20:05:49 +01:00
Edwin Brady
d2af6e5027 Export throw and catch again in App
Fixes #1706
2021-07-16 11:42:24 +01:00
Edwin Brady
66217b6fa6
Merge branch 'master' into refc-buffer 2021-07-16 09:44:40 +01:00
Edwin Brady
050abe663e
Merge pull request #1638 from stepancheg/idris2-time
Use C idris2_time for all C-based backends
2021-07-16 09:40:08 +01:00
Edwin Brady
a20aba63ee
Merge pull request #1448 from mattpolzin/case-tree-experiments-merge-upstream
Case tree heuristics
2021-07-16 08:47:19 +01:00
Giuseppe Lomurno
07c62e9eef Fixed wrong reflection of records and parameters 2021-07-16 04:28:52 +02:00
Mathew Polzin
89125e96dd merge w/ upstream 2021-07-15 17:21:08 -07:00
Edwin Brady
a880b9884c
Merge pull request #1670 from stepancheg/buffer-names
Add parameter names to Buffer builtins parameter names
2021-07-16 00:53:42 +01:00
Edwin Brady
f4cc2f1ea8
Merge pull request #1721 from edwinb/AliasQli-master
Updated: add doublePow to primitives
2021-07-15 23:17:53 +01:00
Stiopa Koltsov
c80a502627 Return Bool from IOArray.writeArray
As suggested in #1677.

Crashing on out-of-bounds might be more practical, but we can
reconsider it later.
2021-07-15 22:16:22 +01:00
Edwin Brady
4079ae0e25 Merge branch 'master' of https://github.com/AliasQli/Idris2 into AliasQli-master 2021-07-15 21:44:26 +01:00
Edwin Brady
9b0ebcd08b Merge branch 'elab-name-changes' of https://github.com/MarcelineVQ/Idris2 into MarcelineVQ-elab-name-changes 2021-07-15 13:16:47 +01:00
Stiopa Koltsov
291823c752 Remove prim__getErrno from Prelude.IO
The function is not used, and it is defined incorrectly.
2021-07-14 03:15:49 +01:00
Stiopa Koltsov
f81c37ea3a Pass Buffer as char* when using C functions in RefC
To be able to use `C` functions for both Scheme and RefC: it was
not possible for `Buffer` before this PR.

As an example, `writeBufferData` and `readBufferData` functions are
removed: generic C backend implementations are used instead.
2021-07-13 23:04:36 +01:00
Nick Drozd
9cca3a7d35
Use Not instead of -> Void (#1667) 2021-07-13 15:32:01 +01:00
Johann Rudloff
d5abff4e46
[ fix #1260 ] Use blodwen-stringbytelen instead of C's strlen (#1261) 2021-07-13 11:52:15 +01:00
Stiopa Koltsov
1617d95961 System.Errno.strerror
* add `strerror` function
* move `getErrno` to `System.Errno`
* use `strerror` in `Show FileError`
* on node there's no access to `strerror`, so `strerror` just converts the number to string
2021-07-13 10:34:04 +01:00
Stiopa Koltsov
d676ea6ab4 Expose malloc and free from System.FFI
* Move `malloc`/`free` from `Network.FFI` to `System.FFI`
* Might be useful by other code
2021-07-13 10:24:26 +01:00