Commit Graph

368 Commits

Author SHA1 Message Date
Matus Tejiscak
e73c6ae3c6 Add comments to fastUnpack and fastConcat. 2020-09-19 19:19:09 +02:00
Matus Tejiscak
7b2d1190a1 Make the comments more explicit. 2020-09-19 15:22:29 +02:00
Matus Tejiscak
63c3ebf124 Remove ambiguities. 2020-09-19 14:46:12 +02:00
Matus Tejiscak
5f9c94a4e1 Fix access modifiers of fastUnpack and fastConcat. 2020-09-19 14:43:08 +02:00
Matus Tejiscak
5360adcc23 String-related stdlib tweaks. 2020-09-19 14:22:54 +02:00
MarcelineVQ
ea0df039fe change runReader's to take state first to allow easier use
following up on the change made in 5c76053cf3
to encourage people to do it in this manner going forward
2020-09-15 22:46:07 +01:00
MarcelineVQ
19bad79847 change runState's to take state first to allow easier use 2020-09-15 09:23:41 +01:00
MarcelineVQ
5c76053cf3 change StateT, swap result parameters
Nipping this historical artifact in the bud before it roots. It's often
useful to be able to `map` directly to the result of a StateT computation
and due to how Functor works this is made harder when the tuple is
(a,state) vs (state,a)
2020-09-15 09:23:41 +01:00
Guillaume ALLAIS
65e194e9bb [ re #660 ] Positivity checking for empty types 2020-09-14 18:37:47 +01:00
Ohad Kammar
2ae330785b
[contrib] Add misc libraries to contrib (#667)
* [contrib] Add misc libraries to contrib

Expose some `private` function in libs/base that I needed, and seem like
their visibility was forgotten

I'd appreciate a code review, especially to tell me I'm
re-implementing something that's already elsewhere in the library

Mostly extending existing functionality:
* `Data/Void.idr`: add some utility functions for manipulating absurdity.
* `Decidable/Decidable/Extra.idr`: add support for double negation elimination in decidable relations
* `Data/Fun/Extra.idr`:
  + add `application` (total and partil) for n-ary functions
  + add (slightly) dependent versions of these operations
* `Decidable/Order/Strict.idr`: a strict preorder is what you get when
  you remove the diagonal from a pre-order. For example, `<` is the
  associated preorder for `<=` over `Nat`.
  Analogous to `Decidable.Order`. The proof search mechanism struggled
  a bit, so I had to hack it --- sorry.

Eventually we should move `Data.Fun.Extra.Pointwise` to `Data.Vect.Quantifiers` in base
but we don't have any interesting uses for it at the moment so it's not
urgent.

Co-authored by @gallais
2020-09-14 16:22:46 +01:00
Matus Tejiscak
aebe3c19d9 Revert postfix dotted application. 2020-09-10 19:00:48 +02:00
Shay Lewis
53c2bf5885 make constructor injectivity proofs use arguments at 0 multiplicity 2020-09-09 19:57:12 +01:00
G. Allais
937aa8fc43
[ refactor ] introducing Namespace (#638)
Until now namespaces were stored as (reversed) lists of strings.
It led to:

* confusing code where we work on the underlying representation of
  namespaces rather than say what we mean (using `isSuffixOf` to mean
  `isParentOf`)

* potentially introducing errors by not respecting the invariant cf.
  bug report #616 (but also name generation in the scheme backend
  although that did not lead to bugs as it was self-consistent AFAICT)

* ad-hoc code to circumvent overlapping interface implementation when
  showing / pretty-printing namespaces

This PR introduces a `Namespace` newtype containing a list of strings.
Nested namespaces are still stored in reverse order but the exposed
interface aims to support programming by saying what we mean
(`isParentOf`, `isApproximationOf`, `X <.> Y` computes to `X.Y`, etc.)
irrespective of the underlying representation.
2020-09-05 09:41:31 +01:00
Guillaume ALLAIS
529944267b Revert "[ refactor ] Introducing Namespace and ModuleIdent (#631)"
This reverts commit 481dc431e7.
2020-09-04 09:16:06 +01:00
G. Allais
481dc431e7
[ refactor ] Introducing Namespace and ModuleIdent (#631)
Until now namespaces were stored as (reversed) lists of strings.
It led to:

* confusing code where we work on the representation rather than say
  what we mean (e.g. using `isSuffixOf` to mean `isParentOf`)

* potentially introducing errors by not respecting the invariant cf.
  bug report #616 (but also name generation in the scheme backend
  although that did not lead to bugs as it was self-consistent AFAICT)

* ad-hoc code to circumvent overlapping interface implementations when
  showing / pretty-printing namespaces

This introduces a Namespace newtype containing non-empty lists of
strings. Nested namespaces are still stored in reverse order but the
exposed interface aims to support programming by saying what we mean
(`isParentOf`, `isApproximationOf`, `X <.> Y` computes to `X.Y`, etc.)
irrespective of the underlying representation.
2020-09-02 20:05:33 +01:00
MarcelineVQ
3e4e33110b add semigroup/monoid instances for Unit/()
quite useful to have for more complex libraries and types
2020-09-02 08:42:00 +01:00
0xd34df00d
7dbafae052 Port Idris 1's Data.Vect.Quantifiers 2020-08-31 12:34:13 +01:00
foss-mc
d56b090c4c Add missing Data.Stream.Extra module to contrib.ipkg
I forgot to add it
2020-08-28 14:26:11 +01:00
foss-mc
4b7dc38e62 Add Data.Stream.Extra.startWith 2020-08-28 13:16:31 +01:00
russoul
5d156167d3 Add dup 2020-08-27 18:30:31 +01:00
Alex Gryzlov
969f5443a9 additional refactor of Data.String.Parser 2020-08-27 15:27:52 +01:00
Guillaume ALLAIS
1d4c84171d [ refactor ] suggested during SPLV
Main change
===========

The main change is to the type of function dealing with an untouched
segment of the local scope. e.g.

```
weak : {outer, vars : _} -> (ns : List Name) ->
       tm (outer ++ inner) -> tm (outer ++ ns ++ inner)
```

Instead we now write

```
weak : SizeOf ns -> tm (outer ++ inner) -> tm (outer ++ ns ++ inner)
```

meaning that we do not need the values of `outer`, `inner` and `ns`
at runtime. Instead we only demand a `SizeOf ns` which is a `Nat`
together with an (erased) proof that `ns` is of that length.

Other modifications
===================

Quadratic behaviour
-------------------

A side effect of this refactor is the removal of two sources of
quadratic behaviour. They typically arise in a situation where
work is done on a scope of the form

```
outer ++ done ++ ns ++ inner
```

When `ns` is non-empty, some work is performed and then the variable
is moved to the pile of things we are `done` with. This leads to
recursive calls of the form `f done` -> `f (done ++ [v])` leading
to a cost quadratic in the size of `ns`.

Now that we only care about `SizeOf done`, the recursive call is
(once all the runtime irrelevant content is erased) for the form
`f n` -> `f (S n)`!

More runtime irrelevance
------------------------

In some places we used to rely on a list of names `vars` being
available. However once we only care about the length of `vars`,
the fact it is not available is not a limitation.

For instance a `SizeOf vars` can be reconstructed from an environment
assigning values to `vars` even if `vars` is irrelevant. Indeed the
size of the environment is the same as that of `vars`.
2020-08-27 10:14:55 +01:00
Guillaume ALLAIS
d9c0e5938e [ fix ] succInjective does not use its arguments 2020-08-27 10:14:55 +01:00
Thomas Dziedzic
a7ff5aa71f
implement HVect (#563) 2020-08-26 15:48:19 +01:00
russoul
3a9b1ac656 Add supporting code 2020-08-25 14:30:57 +03:00
russoul
50ac934747 Merge branch 'master' of https://github.com/idris-lang/Idris2 into master 2020-08-25 13:57:26 +03:00
MarcelineVQ
209de36ba0
add EitherT transformer (#590)
Co-authored-by: Guillaume ALLAIS <guillaume.allais@ens-lyon.org>
2020-08-25 11:14:09 +01:00
Matus Tejiscak
f69443985b Revert addition to ES preamble. 2020-08-25 10:25:45 +02:00
Matus Tejiscak
e9e5ef3d6a Fix FFI specifier. 2020-08-25 10:23:07 +02:00
Matus Tejiscak
1eaecc5d66 Implement stringConcat in Node. 2020-08-25 09:46:35 +02:00
Matus Tejiscak
969a6e1a45 Make fastAppend a deprecated alias of fastConcat. 2020-08-24 19:51:23 +02:00
Matus Tejiscak
362d2204ab Make fastAppend a foreign call. 2020-08-24 19:51:22 +02:00
russoul
594105d5ac Eliminate schemeCall from the library 2020-08-24 19:38:29 +03:00
Alex Gryzlov
ef5299733a
refactor Data.String.Parser (#579) 2020-08-22 08:13:34 +01:00
G. Allais
da78ac4783
[ new ] topics for logging levels (#569) 2020-08-20 18:45:34 +01:00
Cole Brown
f227735cec Add local to MonadReader interface 2020-08-20 16:33:50 +01:00
Cole Brown
6c3ab219bc Implement MonadReader and related types/instances
This includes:
- ReaderT transformer
- Instances for Functor, Applicative, Monad, MonadTrans, HasIO,
  Alternative
- asks helper function
- Reader alias
2020-08-20 16:33:50 +01:00
karroffel
7d046652d8
add support for more casts from and to BitsN types (#548)
Co-authored-by: Guillaume ALLAIS <guillaume.allais@ens-lyon.org>
2020-08-20 15:01:09 +01:00
Thomas Dziedzic
5d1b937035
add prim__getNullAnyPtr and prim__castPtr (#525) 2020-08-20 11:52:51 +01:00
Ohad Kammar
310b7a007c Move cong2 from contrib to Prelude.Basics 2020-08-20 07:53:45 +01:00
Ohad Kammar
080fbab20d Insert linearity annotations for cong2
following review by @gallais
2020-08-20 07:53:45 +01:00
Kamil Shakirov
8544e80076 Use the same naming convention for foreign primitives 2020-08-19 14:05:28 +01:00
Arnaud Bailly
8ecf664ff6
Port Decidable.Order from Idris1 (#543) 2020-08-18 22:26:56 +01:00
Giuseppe Lomurno
df4f990b3c PTerm and error intial prettyprinting 2020-08-18 19:25:36 +01:00
Niklas Larsson
76ee7a3b34
Merge pull request #351 from petithug/fixity-precedence-master
Restore Bool operators precedence
2020-08-18 14:08:20 +02:00
Niklas Larsson
84ae9d7c6e
Merge pull request #523 from mb64/hasio-statet
Implement HasIO for StateT
2020-08-18 14:02:02 +02:00
Niklas Larsson
93ecb72012
Merge pull request #526 from alexhumphreys/feat/buildExpressionParser
Add BuildExpressionParser to contrib
2020-08-18 14:01:20 +02:00
Ohad Kammar
10b8698843 Remove forgotten linearity annotation on cong2 2020-08-16 08:20:31 +01:00
Ohad Kammar
d82a3e0e42 contrib: Add a 2-holed congruence function
For lack of a better place, I've put it in `Syntax.PreorderReasoning`

These equations are natural in equational reasoning, but less so when
rewriting, so that's why it's there
2020-08-16 08:20:31 +01:00
Alex Humphreys
f47d9cfef2 Add integer paser and extra test
Signed-off-by: Alex Humphreys <alex.humphreys@here.com>
2020-08-10 13:26:20 +02:00
Alex Humphreys
f020fd29e8 Use overloaded Fin literals
Signed-off-by: Alex Humphreys <alex.humphreys@here.com>
2020-08-10 13:26:20 +02:00
Thomas Dziedzic
a1739a69a0
Update app docs (#537) 2020-08-10 10:05:23 +01:00
Ohad Kammar
7f960ed938 Remove bindning to y as no longer necessary 2020-08-09 10:18:34 +01:00
Ohad Kammar
ff76dee6c7 Try a fix for the preorder reasoning error
Correct the dependency in `FastDerivation` to use the RHS in `step`
Try to avoid shadowing `y` in the LHS of `Calc`
2020-08-09 10:18:34 +01:00
russoul
d387c76e9b update stdio docs 2020-08-08 12:49:33 +01:00
Alex Humphreys
d4cbb8a620 Move natural and digit combinators
Signed-off-by: Alex Humphreys <alex.humphreys@here.com>
2020-08-07 19:20:32 +02:00
Alex Humphreys
40427bd527 Move combinators to Data.String.Parser 2020-08-06 13:16:47 +02:00
Alex Humphreys
97b41d1ad9 Rename BuildExpressionParser to Parser.Expression
Signed-off-by: Alex Humphreys <alex.humphreys@here.com>
2020-08-06 12:42:38 +02:00
Alex Humphreys
22915d23ca Remove LO function
Signed-off-by: Alex Humphreys <alex.humphreys@here.com>
2020-08-06 12:27:42 +02:00
Alex Humphreys
eca083cdcc Add License comment to BuildExpressionParser
Signed-off-by: Alex Humphreys <alex.humphreys@here.com>
2020-08-06 08:59:57 +02:00
Alex Humphreys
29e49a74c5 Add BuildExpressionParser to contrib
Signed-off-by: Alex Humphreys <alex.humphreys@here.com>
2020-08-06 08:59:57 +02:00
Giuseppe Lomurno
723457fd6c Remove public export 2020-08-05 13:42:04 +02:00
Giuseppe Lomurno
c28133b7d9 Renamed IsString to FromString
- Renaming of the string overload interface
- Added test cases for both string and integer literals overload
2020-08-05 02:33:05 +02:00
Giuseppe Lomurno
b7ba5e88eb Overloaded strings interface
As for integer literals, adds an interface for overloaded string
literals, and the implementation for the prettyprinter library in
contrib.
2020-08-05 02:00:05 +02:00
Mark Barbone
10d28efd52
Implement HasIO for StateT 2020-08-04 17:19:45 -04:00
G. Allais
0a7ea69df5
[ refactor ] introduce List1 to remove impossible case (#520) 2020-08-04 20:03:18 +01:00
Edwin Brady
2761a27357
Merge pull request #476 from nickdrozd/algebra-implementations
Add some algebra implementations
2020-08-04 13:21:12 +01:00
Mark Barbone
cef248e5a7 Make showParens public 2020-08-04 10:58:00 +01:00
Ohad Kammar
5cfbac4a51 Add irrelevance annotations to Data.List functions taking NonEmpty 2020-07-30 06:01:42 +01:00
Alex Gryzlov
69612bf6bf
Add list lemmas (#491) 2020-07-29 10:51:07 +01:00
Ohad Kammar
915b7bea38 Add various instances from stdlib interfaces (Eq, Ord, DecEq)
For Void and Either

This is because I ended up using them elsewhere, so why not include them in the stdlib.

Also expose left/rightInjective functions, as are used in the DecEq proofs.
2020-07-26 10:47:38 +01:00
Giuseppe Lomurno
39f23ffd9b Prec version of pretty interface 2020-07-24 15:19:17 +01:00
Giuseppe Lomurno
ab1f383912 Laziness annotations for performance 2020-07-24 15:19:17 +01:00
Giuseppe Lomurno
62524e8462 Tree representation for prettyprinting 2020-07-24 15:19:17 +01:00
Giuseppe Lomurno
3d51af46c2 Namespace change 2020-07-24 15:19:17 +01:00
Giuseppe Lomurno
eb659ba907 Added prettyprinting library 2020-07-24 15:19:17 +01:00
Niklas Larsson
8a210d536e
Merge pull request #408 from melted/buffer_api
Add concatBuffers and splitBuffer to Data.Buffer
2020-07-21 10:43:17 +02:00
Jonathan Chan
dab2b0d146 Export (~>) publicly.
If `(~>)` isn't publicly exported, the type checker doesn't know that `Mor` constructs something of type `~>`.
2020-07-20 15:55:24 +01:00
Marc Petit-Huguenin
bc21299c51
Restore Bool operators precedence
(&&) traditionally has higher precedence than (||).

Note that this commit requires to bootstrap again.
2020-07-18 05:49:35 -07:00
Edwin Brady
f303e469fb Improve elaborator reflection performance
In a 'Bind', normalise the result of the first action, rather than
quoting the HNF. This improves performance since the HNF could be quite
big when quoted back.

Ideally, we wouldn't have to quote and unquote here, and we can probably
achieve this by tinkering with the evaluator.

This has an unfortunate effect on the reflection002 test, in that the
"typed template Idris" example now evaluates too much. But, I think the
overall performance is too important for the primary motivation
behind elaborator reflection. I will return to this!
2020-07-17 15:18:23 +01:00
Nick Drozd
a2bdf8e6d7 Add some algebra implementations 2020-07-17 08:25:20 -05:00
Mark Barbone
acda3b44a9
Make Text.Parser.between lazy (#385) 2020-07-14 14:33:22 +01:00
G. Allais
0908e76515
[ fix #346 ] Pull List.length into prelude (#450) 2020-07-14 12:15:57 +01:00
Nicolas Biri
aba76206c9 Remove dependency to Vector length in deleteAt 2020-07-14 09:45:33 +01:00
Nick Drozd
e14a589e90 Consolidate boolean expressions 2020-07-12 21:00:33 -05:00
Nick Drozd
6519b5608d Further simplify List 2020-07-12 21:00:33 -05:00
Nick Drozd
718da3d7e6 Simplify Vect 2020-07-12 20:59:00 -05:00
Edwin Brady
6a53e0177c Reorganise prelude into multiple files
This is partly to tidy things up, but also a good test for 'import as'.
Requires some internal changes since there are parts of reflection,
unelaboration and a compiler hack that rely on where things are in the
Prelude.
2020-07-12 16:55:48 +01:00
Edwin Brady
b3bb73cfd6
Merge pull request #455 from edwinb/export-nat-prfs
Data.Nat proofs should be exported
2020-07-10 23:30:09 +01:00
Edwin Brady
58e28170ac Data.Nat proofs should be exported
I assumed these were copied directly from the Idris 1 libraries, where
there was an %access directive that we don't have any more.
2020-07-10 22:59:46 +01:00
Jan de Muijnck-Hughes
5774a9c6ae If we know the types of a & b start searching.
This is helpful when defining auto-implicits of the form:

    pairEqF : DecEq a
           => (thisX, x, y : a)
           -> {prfRefl : Equal x thisX}
           -> (prfEq   : decEq x thisX = Yes prfRefl)
           => Pair a a
    pairEqF thisX x y {prfRefl} {prfEq} = MkPair x y

before auto-implicit search would fail to find `Refl` for `prfRefl`.
With this fix the solution is found.

This fix means we can avoid having to write the following.

    pairEqF' : DecEq a
            => (thisX, x, y : a)
            -> (prfEq   : decEq x thisX = Yes (the (Equal x x) Refl))
            => Pair a a
    pairEqF' thisX x y {prfEq} = MkPair x y
2020-07-10 21:00:38 +01:00
Jan de Muijnck-Hughes
fcbfcf6fe2 Added take to Vect. 2020-07-10 21:00:38 +01:00
Ohad Kammar
eceaf98007 Generalise cons-specialised linear zipWith to linear zipWith (lzipWith) 2020-07-10 17:17:19 +01:00
Ohad Kammar
8f09ef9b93 Include a (non-linear) definition for transpose that uses zipWith,
as it might be easier to reason about, since users may already have proved
stuff about zipWith that they want to reuse
2020-07-10 12:47:05 +01:00
Matthew Ess
6452cdbbd4
Add Ord implementation for Either (#439) 2020-07-09 19:28:59 +01:00
Edwin Brady
23cbc28b1d
Merge pull request #415 from rbarreiro/javascript
Javascript
2020-07-08 22:27:58 +01:00
Niklas Larsson
fc6b184106 Remove prim__cCall
It's not used anymore and %foreign is preferred.
2020-07-08 11:45:41 +02:00
Matus Tejiscak
3484510f5a Implement postfix dotted application. 2020-07-07 21:06:35 +01:00
Rui Barreiro
2feb4b8299 Merge branch 'master' of github.com:idris-lang/Idris2 into javascript 2020-07-07 14:18:00 +01:00
Markus Pfeiffer
63ddd149ed Remove a superflousy declared argument to idris2_openFile
This didn't cause a problem before as it was likely just ignored by the C
function. According to Edwin the extra argument is a leftover from when this
was a pure scheme call.
2020-07-07 11:44:37 +01:00