Commit Graph

385 Commits

Author SHA1 Message Date
stefan-hoeck
530e62a156 Eq, Ord, and Show instances for LazyList 2021-01-11 11:45:56 +01:00
André Videla
3478297557
Merge pull request #905 from alebahn/master
Add public export to types/functions in Data.Fin.Order
2021-01-07 13:46:23 +00:00
André Videla
e99a9b0c84
Merge pull request #901 from andrevidela/fold-count
Add count and foldMap to prelude
2021-01-06 19:29:50 +00:00
André Videla
28c4d1e3bb Add count and foldMap to prelude 2021-01-05 21:59:01 +00:00
André Videla
e4fcd4a089
Merge pull request #900 from andrevidela/vect-snoc
Add `snoc` to Data.Vect
2021-01-05 21:54:47 +00:00
Michael Messer
a1f3424ab8 Remove lamdaRequire 2021-01-05 16:30:11 +00:00
Aaron Lebahn
ce6465e279 Add public export to types/functions in Data.Fin.Order 2021-01-05 07:56:04 -06:00
André Videla
738c9d77d2 Add snoc to Data.Vect
Snoc add an element at the end of the vector. The main use case
for such a function is to get the expected type signature
Vect n a -> a -> Vect (S n) a instead of
Vect n a -> a -> Vect (n + 1) a which you get by using `++ [x]`

Snoc gets is name from `cons` by reversin each letter, indicating
tacking on the element at the end rather than the begining.
`append` would also be a suitable name.
2021-01-03 21:48:31 +00:00
Felix Springer
54d400dad4
Add countExactly to Text.Parser in libs/contrib to return a Vect (#875) 2021-01-01 10:01:42 +00:00
Joey Eremondi
0eef8e58f9
Some utilities for Fin, relations and decidability (#857) 2020-12-28 21:41:12 +00:00
alissa42
02e12a82cf Adding default implementation of Foldable.null 2020-12-24 08:49:32 +00:00
André Videla
9c400a185e Add Traversable to List1 2020-12-21 15:10:00 +00:00
Denis Buzdalov
60e9cf44b0 Add List, LazyList and Stream unfolds and some LazyList's functions 2020-12-18 22:54:03 +00:00
Denis Buzdalov
bff74807fd
Some functions, mostly for lazy lists (#854)
Co-authored-by: G. Allais <guillaume.allais@ens-lyon.org>
2020-12-18 10:33:56 +00:00
tensorknower69
aa940c3d18 change runState's signature 2020-12-17 10:10:18 +00:00
tensorknower69
c48b1e090e add execStateT and evalStateT 2020-12-17 10:10:18 +00:00
Edwin Brady
c1f58d963f
Merge branch 'master' into interfaces 2020-12-14 13:34:31 +00:00
Wen Kokke
daff1f2fb8
Added assert_linear. (#844)
Co-authored-by: Guillaume ALLAIS <guillaume.allais@ens-lyon.org>
2020-12-13 16:06:18 +00:00
G. Allais
3f6b99e979
[ fix #657 ] RigCount for interface parameters (#808) 2020-12-11 11:58:26 +00:00
Dong Tsing-hsuen
88aa55e875
[ new ] null method in Foldable (#832)
Co-authored-by: Guillaume ALLAIS <guillaume.allais@ens-lyon.org>
2020-12-10 18:04:23 +00:00
Edwin Brady
63a46722ef Force/Delay need to be inlined in Builtins
Otherwise (especially in the case of delay) the argument might be
evaluated prematurely.
2020-12-06 20:00:48 +00:00
Andy Lok
9e22a6e07b
Add javascript FFI for fastUnpack (#816) 2020-12-06 09:54:58 +00:00
Denis Buzdalov
13cc27da1f An alternative (Fin-based) indexing function was added for lists. 2020-12-04 19:09:05 +00:00
Denis Buzdalov
4364793484 Type definition from Decidable.Equality was moved to a separate module
This is done to make able for `Data.*` modules of datatypes declared in
prelude to import modules that have their own definitions of `DecEq`
inside them (i.e. modules of datatypes declared in the `base`).
2020-12-04 19:09:05 +00:00
Edwin Brady
778d6026e5
Merge pull request #607 from Russoul/record-init
New syntax for named applications and "record" updates
2020-12-04 11:35:05 +00:00
Denis Buzdalov
f2596318e5 Proof of list bounds was made to be not present at runtime when indexing 2020-12-04 11:26:11 +00:00
Fabián Heredia Montiel
57a8ef4609
Implement Futures as a Parallelism Primitive (#753)
Co-authored-by: Christian Rasmussen <christian.rasmussen@me.com>
2020-12-04 10:58:26 +00:00
russoul
46519237cd Merge 2020-12-03 15:28:20 +03:00
Mathew Polzin
6ca03acd71
Add replaceWhen for lists. (#755) 2020-11-27 19:10:08 +00:00
G. Allais
502f544d73
[ fix #775 ] integerToNat is not, in fact, id (#799) 2020-11-27 18:48:19 +00:00
G. Allais
5e799563fa
[ contrib ] adding Data.Container (#781) 2020-11-27 15:29:19 +00:00
Alex Humphreys
71a638ef28 Add extra parsers
This also changes the return type of `char` and `string`. They
previously returned `()`, they now return `Char` and `String`
repectively.

Signed-off-by: Alex Humphreys <alex.humphreys@here.com>
2020-11-27 11:54:12 +00:00
Guillaume ALLAIS
a9ff13c663 [ new ] proof that evaluation is Domain-independent 2020-10-29 23:05:41 +00:00
Alex Gryzlov
f79b86ae41
contrib.Data.String.Parser updates (#713) 2020-10-24 12:33:15 +01:00
Jan de Muijnck-Hughes
de58c66ab2
Make Idris2 test harness available for the many and not the few. (#719)
Co-authored-by: Guillaume ALLAIS <guillaume.allais@ens-lyon.org>
2020-10-19 09:26:23 +01:00
Guillaume ALLAIS
14d0141ca2 [ fix #735 ] Make sure type constructors are fully applied 2020-10-16 14:44:11 +01:00
Guillaume ALLAIS
482527063c [ new ] Variant with a runtime irrelevant Domain
Rather than translating the constraints to a Dybjer-Setzer IR code
we can produce an ad-hoc definition of a `Domain` that we will be
able to make runtime irrelevant.

This means that compiled code will never need to construct a proof
that a value is in the domain of the function: it will simply run
the function!
2020-10-15 17:03:32 +01:00
Guillaume ALLAIS
864be2c9dc [ contrib ] add McBride's General monad 2020-10-15 17:03:32 +01:00
russoul
fd90141ed9 Merge branch 'master' of https://github.com/idris-lang/Idris2 into master 2020-10-12 17:36:45 +03:00
Matúš Tejiščák
1a58075a54
Merge pull request #716 from sysvinit/fix-network-constants
Retrieve network address family preprocessor constants from C runtime code
2020-10-11 08:37:44 +02:00
Matus Tejiscak
f64163de1f Merge branch 'unscheme' into master 2020-10-11 08:20:01 +02:00
Matus Tejiscak
668762e693 Merge branch 'revert-projections' into master 2020-10-11 08:12:00 +02:00
Ohad Kammar
ef730c7eb1
preorder reasoning: introduce a Step datatype (#734)
Refactor the DIY equational reasoning library to be a bit more like
the generic pre-order reasoning library:

Change the `...` notation into a constructor for a new `Step` datatype.

This seems to help idris disambiguate between the two kinds of
reasoning when they're used in the same file (e.g., frex).

Co-authored-by: Ohad Kammar <ohad.kammar@ed.ac.uk>
2020-10-07 17:44:18 +01:00
Ohad Kammar
0c1a124704
Division theorem (#695)
Division Theorem. For every natural number `x` and positive natural
number `n`, there is a unique decomposition:
`x = q*n + r`
with `q`,`r` natural and `r` < `n`.

`q` is the quotient when dividing `x` by `n`
`r` is the remainder when dividing `x` by `n`.

This commit adds a proof for this fact, in case
we want to reason about modular arithmetic (for example, when dealing
with binary representations). A future, more systematic, development could
perhaps follow: @clayrat 's (idris1) port of Coq's binary arithmetics:

    https://github.com/sbp/idris-bi/blob/master/src/Data/Bin/DivMod.idr
    https://github.com/sbp/idris-bi/blob/master/src/Data/Biz/DivMod.idr
    https://github.com/sbp/idris-bi/blob/master/src/Data/BizMod2/DivMod.idr

In the process, it bulks up the stdlib with:
+ a generic PreorderReasoning module for arbitrary preorders,
analogous for the equational reasoning module
+ some missing facts about Nat operations.
+ Refactor some Nat order properties using a 'reflect' function

Co-authored-by: Ohad Kammar <ohad.kammar@ed.ac.uk>
Co-authored-by: G. Allais <guillaume.allais@ens-lyon.org>
2020-10-06 13:09:02 +01:00
Ruslan Feizerahmanov
2e627ad16e
Remove invalid implicit in PreorderReasoning (#727) 2020-10-03 14:53:14 +01:00
russoul
98bfff4a27 Merge branch 'master' of https://github.com/idris-lang/Idris2 into master 2020-10-03 11:51:48 +03:00
Ohad Kammar
c02481fb55
[contrib] Add a Reflects datatype (#722)
* [contrib] Add a `Reflects` datatype

as discussed in PR #695
2020-10-02 17:41:36 +01:00
G. Allais
4a61146ba0
[ fix #705 ] Normalise primitives in mkPat (#718)
[ log ] prettier log for pats & clauses
[ re #650 ] Even lazier
[ fix #705 ] normalise primitives in mkPat
[ refactor ] introduce getPrimitiveNames
2020-10-02 12:22:57 +01:00
Molly Miller
7d5ec53b53 Add a (>>) operator, implemented in terms of (>>=).
This mirrors the (>>) found in Haskell, which is the same as (>>=), except the
second computation (on the right hand side) takes no arguments, and the result
of the first computation is discarded. This is a trivial implementation written
in terms of (>>=).
2020-10-01 13:16:58 +01:00
Molly Miller
dff0f1da43 network: Retrieve AF_* magic constants from C support code.
The Network.Socket.Data code previously used hardcoded constants manually read
from auto-generated C source code, however these constants are specific to
Linux. The original code looked like this:

    export
    ToCode SocketFamily where
      -- Don't know how to read a constant value from C code in idris2...
      -- gotta to hardcode those for now
      toCode AF_UNSPEC = 0 -- unsafePerformIO (cMacro "#AF_UNSPEC" Int)
      toCode AF_UNIX   = 1
      toCode AF_INET   = 2
      toCode AF_INET6  = 10

The AF_INET6 constant is correct on my Debian 10 laptop:

    molly on flywheel ~> grep -rE '^#define AF_INET6' /usr/include
    /usr/include/x86_64-linux-gnu/bits/socket.h:#define AF_INET6	PF_INET6
    molly on flywheel ~> grep -rE '^#define PF_INET6' /usr/include
    /usr/include/x86_64-linux-gnu/bits/socket.h:#define PF_INET6    10  /* IP version 6.  */

However, this is not the case on an OpenBSD machine:

    spanner# grep -rE '^#define[[:space:]]+AF_INET6' /usr/include
    /usr/include/sys/socket.h:#define	AF_INET6	24		/* IPv6 */

This commit adds accessor functions to the C runtime support library for
retrieving the values of these macros as they appear in the system libc header
files, which can then be invoked using the normal C FFI machinery.
2020-10-01 12:05:42 +01:00