"Can't unify" and "Can't convert" are terrible error messages for
programmers, and particularly confusing to explain to beginners, because
programmers don't need to know that implementation detail.
Changed to "type mismatch" and updated docs accordingly.
Type class methods references were previously elaborated using the
ordinary function call elaboration, but their class isn't yet available
when the method lookup function is elaborated. This leads to a "can't
resolve type class" error on the type class definition.
Now, they have an explicit dictionary argument inserted, pointing at the
dictionary that's used for the type of the method whose signature they
appear in.
Fixes#2302.
Instead of checking there's exactly one result, they must check that one
of the (possibly many) results is the exact name they were looking for,
since some things may be unqualified and will be returned anyway.
Fixes#2271 (again; test for disambig001 and disambig002 added)
If disambiguation fails, then instead of reporting an error immediately,
defer the elaboration until later. Fixes#2285.
In the process, PAlternative now has a more descriptive argument than
merely a Bool to say whether it's a proof search, or a disambiguation,
and whether it's allowed to be delayed or not. IBCs need rebuilding.
This used to be needed because the elaborator wasn't good at going back
and patching up things that didn't work right, but now it just gets in
the way and causes all sorts of other problems. This tidies up
elaboration/unification a bit more.
We need to get exactly what's in the file or strange things might happen
and assumptions get broken.
Change getLine to strip newlines itself rather than have the RTS do it,
for consistency with the REPL behaviour.
It's only a type to be inferred if there are metavariables left over.
Even then, the solved type needs to be rechecked.
Also fix the Hangman test which shouldn't have compiled.
Fixes#2196
Now, conditionals are implemented by the compiler rather than a
library. This gives better error messages and more readable output, at
the cost of more Haskell and less Idris.
Also, boolElim is renamed to ifThenElse for consistency with other
languages that support overloading of conditional expressions (GHC
Haskell and scala-virtualized) and to reflect that things other than
Booleans will be eliminated by overloadings.
Fixes#2217 by demanding that global names in TT terms be
unambiguous. The elaborator will always produce them that way, but user
elab scripts might not, which led to confusion.
Also, disentagle 'apply' and 'fill'.
(Type* now deprecated and replaced with AnyType). If an AnyType is a
parameter of a type, the type itself must be an AnyType otherwise we
might be able to duplicate a unique thing by mistake.
Changes:
- Eff has become EffM, parameterised over (m : Type -> Type), which will
allow us to introduce new effects later, though not currently used
- Eff itself is now a collection of type synonyms which build an EffM.
It can take either one list of effects, a list of input and output
effects, or a list of effects and a function to compute output
effects; disambiguated by context
- EffT is as Eff, but takes the underlying 'm'
- Added 'sig' function for giving effect signatures.
All of the above mean we no longer need the {} syntactic sugar, though
it's still there. Old effect programs (should!) work with no or minimal
changes.
This compiles the expression and evaluates it. It will either print the
expression (if its type is an instance of Show) or run it (if its type
is IO ()), or give an error otherwise.
This causes Idris to not emit messages about "Type checking ...." while
in quiet mode, which improves the portability of tests to Windows (due
to the slash facing the other way there). It also makes tests a bit more
robust with regards to their source files changing names.
This allows extra hints, as well as constructors, to guide proof search
for auto implicit arguments.
Added test proof010 which shows how this works to simulate type classes
with overlapping instances (and consequently no injectivity restriction
or assumption)
%hint only works on functions which return an instance of a data type.
Proof search exhaustively searches hints and constructors, so use with
care especially when adding lots of recursive or overlapping hints.
Primitives for head/tail/index/cons/reverse/length now all assume the
char* is UTF8 encoded. Also updated generation of literals to encode as
UTF8. Primitives are probably not as efficient as they could be (though
some of the will be used rarely)
ASCII strings will work exactly as before.
Everything I know about UTF8 encoding has been learned in the past few
hours. Therefore, this is unlikely to be the best way to do this. Please
educate me, ideally in the form of annotated Pull Requests :).
We weren't shadowing names correctly when a class was parameterised on a
single variable and one of the methods bound the same name. This almost
never happens, but leads to very odd error messages when it does.
Fixes#2026
This means we get better error messages if there are scoping issues,
particularly as caused by 'where' clauses with missing types that can't
be inferred.
Fixes#1978
Need to expand implicits for methods in the dictionary declarataion, but
not quite the same way as for the top level function of the same name
(i.e. need to leave out the dictionary itself).
Fixes#1975
Also fix resolution rules so that determining parameters, in *all cases*
except Num instances (for defaulting to Integer), must not be
metavariables.
Syntax is:
class Foo a b c | a, b
the optional | a, b lists the determining parameters. When resolving
Foo, a and b must not be metavariables. c can be a metavariable (and
hence solved by type class resolution).
The overlapping instance check now only looks at determining parameters,
so, for example, for Foo the following instances would be considered
overlapping:
instance Foo Int Nat Bool
instance Foo Int Nat String
It now offers different errors when it couldn't prove the lemma due to
having a variable for the Integer, or when it couldn't prove it due to
having concrete values that are directly incorrect.
The changes are as follows:
+ `print` is for putting showable things to STDOUT.
+ `printLn` is for putting showable things to STDOUT with a new line
+ `putCharLn` for putting a single character to STDOUT, with a new line.
Effects has been updated accordingly.
This works only if the elaborator is in a context where it is expecting
a unique type (or a Type*) rather than a normal type. This is
EXPERIMENTAL but should(!) not cause any issues in code which uses no
unique types or Type*
This commit introduces:
* A new tactic "claim N TY" that introduces a new hole named N with
type TY
* A new tactic "unfocus" that moves the current hole to the bottom of
the hole stack
In the process of this and some other work, I also added comments and
docs to more of the core.
If after an application there are more implicit arguments expected, add
those arguments then re-elaborate the application - we often don't know
what these arguments will be until after elaborating the application
because the application itself may compute a type.
Fixes#1899
This means we can make primitives for reading/writing file handles which
are given the world state, so can be written more safely. Also, a
minimal back end can implement these rather than implementing an entire
FFI.
Updated primitive LReadStr (which can now reasonably be total, like any
foreign function, because it has a world state) and added primitive
LWriteStr.
More documentation to follow, but in brief:
- IO is now a synonym of IO' FFI_C
- IO' is parameterised over an ffi description, which explains which
types are allowed in foreign calls, and what a foreign call target is
(in C, that's a String giving the function name, for example)
- New function "foreign" for building a foreign call, given an ffi
description, call target, and the type of the call. The type is enough
to build a structure which the compiler uses to generate the call.
The type of main now needs to be IO' x (), where x can be any FFI
description.
There is currently only an ffi description for C; Javascript will
follow. FFI_C should also work for the llvm backend (it's really about
the calling convention, not the backend specifically). Small changes
will be needed to the various code generators.
Limitation: the type class constraint must be under a scoped implicit
(this is purely for parsing reasons, although I also can't immediately
think of a reason you'd want this except under an implicit...)
The syntax is the same as for other documentation, right before the
"module" declaration. For an example, see the "idrisdoc009" test. Terms
in module documentation are elaborated in a context including all of its
imports and definitions, so the documentation can provide examples and
descriptions.
The :doc command now also shows documentation for modules.
Like so:
foo : (c : Show a) => List a -> String
This means that type classes can be used as indices/parameteres of data
types (e.g. to ensure a dictionary is unchanging across a structure).
Fixes#646
They can be imported from the modules Data.Fin, Data.Vect, and Data.So
respectively.
The general thinking here is that not every program is going to need
these, and they are often used especially by newcomers in place of
something more appropriate. Also, all of them are useful for teaching,
which means it is instructive for tutorials to introduce them and have
people implement them themselves.
Add reflection-based error message improvements for Fin literals. Now,
instead of a collection of internal implementation details, a friendly
and descriptive message is returned.
See test/error005 for a demo.
Only allow matching on polymorphic arguments if they have been refined
to something concrete due to some other argument by the time they're
elaborated.
Any term which is not matchable, i.e. a function application or a
repeated variable on the left hand side, is automatically put in a
PHidden. The effect of elaborating PHidden t is to:
1. Delay the elaboration of 't' to the end of elaboration
2. When elaborating t, ensure that its value is already known due to
solving some other unification problem.
If something is PHidden, but not solvable by unification, elaboration
fails.
This finally fixes#323, and probably several other things.
Except under quasiquotation. This is to prevent any arguments being
specialised to a more specific type than the function type suggests (one
place where typecase can arise).
By popular request. Fixes#1706.
It's not the most efficient desugaring, merely translating the @s on the
left to lets on the right, so the case tree builder won't be aware of
it. Still, it provides the notation and it works nicely with showing
what is in scope and what is available in the prover and so on.
Fixes#111
Previously, if a module B imports a module A, then a module C imports B,
the public names in A would also be visible to C (i.e. B would
automatically reexport everything from A). This seems to be a bad
default.
This patch changes the default behaviour so that the only names exported
from a module are those defined in that module. If B imports A and wants
to reexport everything in A, then A should be imported with the "public"
modifier (i.e. "import public A").
Several changes have been made to the prelude, since several prelude
modules were taking advantage of the old broken behaviour.
This may cause lots of things to break. Sorry. The fix is typically just
to import the module you should have imported anyway :).