on master help sign in
file modes extended
commit6112570e497dc2bfe8227f41eed4d3d72b60ac8b authorAistis Raulinaitis <sheganinans@gmail.com> dateSat 30 Jan 2016, 17:47 (11 years ago) parent6203dc7fbd940c
406 files changed+1878−1309
.gitignore+1 CHANGELOG+26−2 CONTRIBUTORS+1 INSTALL.md+8−3 Makefile+3−14 Setup.hs+20−1 config.mk+4−12 docs/conf.py+4−4 docs/effects/depeff.rst+1−1 docs/effects/hangman.rst+1−1 docs/effects/impleff.rst+13−13 docs/effects/simpleeff.rst+12−12 docs/effects/state.rst+6−6 docs/effects/summary.rst+14−14 docs/faq/faq.rst+1−1 docs/proofs/patterns.rst+2−2 docs/proofs/pluscomm.rst+1−1 docs/reference/language-features.rst+2−2 docs/reference/repl.rst+3 docs/tutorial/index.rst+1−1 docs/tutorial/classes.rst → docs/tutorial/interfaces.rst+154−92 docs/tutorial/interp.rst+3−3 docs/tutorial/modules.rst+4−4 docs/tutorial/provisional.rst+2−2 docs/tutorial/syntax.rst+2−2 docs/tutorial/typesfuns.rst+22−22 icons/idris_icon.rc+1 idris-tutorial.pdf idris.cabal+15−8 libs/base/Control/Arrow.idr+1−1 libs/base/Control/Catchable.idr+2 libs/base/Control/Category.idr+1−1 libs/base/Control/IOExcept.idr+13−8 libs/base/Control/Isomorphism.idr+1 libs/base/Control/Monad/Identity.idr+3−1 libs/base/Control/Monad/RWS.idr+1−1 libs/base/Control/Monad/Reader.idr+1−1 libs/base/Control/Monad/State.idr+1−1 libs/base/Control/Monad/Trans.idr+2 libs/base/Control/Monad/Writer.idr+1−1 libs/base/Data/Bits.idr+51−29 libs/base/Data/Complex.idr+2 libs/base/Data/Erased.idr+1−1 libs/base/Data/Fin.idr+2−2 libs/base/Data/HVect.idr+1−1 libs/base/Data/List.idr+1−1 libs/base/Data/List/Quantifiers.idr+2 libs/base/Data/Mod2.idr+5−4 libs/base/Data/Morphisms.idr+1−1 libs/base/Data/So.idr+1 libs/base/Data/String.idr+1−1 libs/base/Data/Vect.idr+1−1 libs/base/Data/Vect/Quantifiers.idr+2 libs/base/Debug/Error.idr+1−1 libs/base/Debug/Trace.idr+1 libs/base/Language/Reflection/Utils.idr+2 libs/base/Syntax/PreorderReasoning.idr+2 libs/base/System.idr+1−1 libs/base/System/Concurrency/Raw.idr+2 libs/base/System/Info.idr+3 libs/contrib/Classes/Verified.idr+9 libs/contrib/Control/Algebra.idr+1 libs/contrib/Control/Algebra/Lattice.idr+1 libs/contrib/Control/Algebra/NumericInstances.idr+1 libs/contrib/Control/Algebra/VectorSpace.idr+2 libs/contrib/Control/Isomorphism/Primitives.idr+1−1 libs/contrib/Control/Partial.idr+1−1 libs/contrib/Control/WellFounded.idr+1−1 libs/contrib/Data/BoundedList.idr+1−1 libs/contrib/Data/CoList.idr+1−1 libs/contrib/Data/Fun.idr+1 libs/contrib/Data/Hash.idr+1−1 libs/contrib/Data/Heap.idr+2−2 libs/contrib/Data/Matrix.idr+1 libs/contrib/Data/Matrix/Algebraic.idr+1−1 libs/contrib/Data/Matrix/Numeric.idr+1 libs/contrib/Data/Nat/DivMod.idr+1 libs/contrib/Data/Nat/DivMod/IteratedSubtraction.idr+1−1 libs/contrib/Data/Rel.idr+1 libs/contrib/Data/Sign.idr+2 libs/contrib/Data/SortedMap.idr+7−8 libs/contrib/Data/SortedSet.idr+7−7 libs/contrib/Data/ZZ.idr+1−1 libs/contrib/Decidable/Decidable.idr+1−1 libs/contrib/Decidable/Order.idr+1−1 libs/contrib/Network/Cgi.idr+11−11 libs/contrib/Network/Socket.idr+7−8 libs/contrib/System/Concurrency/Process.idr+10−2 libs/contrib/contrib.ipkg+2 libs/effects/Effect/Default.idr+2 libs/effects/Effect/Exception.idr+2 libs/effects/Effect/File.idr+1 libs/effects/Effect/Logging/Category.idr+1−1 libs/effects/Effect/Logging/Default.idr+1−1 libs/effects/Effect/Logging/Level.idr+1−1 libs/effects/Effect/Memory.idr+9−3 libs/effects/Effect/Monad.idr+2 libs/effects/Effect/Perf.idr+1−1 libs/effects/Effect/Random.idr+2 libs/effects/Effect/Select.idr+2 libs/effects/Effect/State.idr+1−1 libs/effects/Effect/StdIO.idr+2 libs/effects/Effect/System.idr+2 libs/effects/Effect/Trans.idr+1−1 libs/effects/Effects.idr+25−1 libs/prelude/Builtins.idr+5−5 libs/prelude/Decidable/Equality.idr+4−5 libs/prelude/IO.idr+22−9 libs/prelude/Language/Reflection.idr+3−3 libs/prelude/Language/Reflection/Elab.idr+54−2 libs/prelude/Language/Reflection/Errors.idr+2 libs/prelude/Prelude.idr+7−7 libs/prelude/Prelude/Algebra.idr+1−1 libs/prelude/Prelude/Applicative.idr+3−1 libs/prelude/Prelude/Basics.idr+6−4 libs/prelude/Prelude/Bits.idr+2−2 libs/prelude/Prelude/Bool.idr+2 libs/prelude/Prelude/Cast.idr+2 libs/prelude/Prelude/Chars.idr+3−3 libs/prelude/Prelude/Doubles.idr+4−6 libs/prelude/Prelude/Either.idr+3−1 libs/prelude/Prelude/File.idr+35−8 libs/prelude/Prelude/Foldable.idr+4−5 libs/prelude/Prelude/Functor.idr+7−5 libs/prelude/Prelude/Interactive.idr+18−19 libs/prelude/Prelude/Classes.idr → libs/prelude/Prelude/Interfaces.idr+11−11 libs/prelude/Prelude/List.idr+5−6 libs/prelude/Prelude/Maybe.idr+2−2 libs/prelude/Prelude/Monad.idr+1−1 libs/prelude/Prelude/Nat.idr+18−19 libs/prelude/Prelude/Pairs.idr+1−1 libs/prelude/Prelude/Providers.idr+3−1 libs/prelude/Prelude/Show.idr+3−2 libs/prelude/Prelude/Stream.idr+1−1 libs/prelude/Prelude/Strings.idr+4−3 libs/prelude/Prelude/Traversable.idr+2 libs/prelude/Prelude/Uninhabited.idr+2 libs/prelude/prelude.ipkg+1−2 libs/pruviloj/Pruviloj/Core.idr+2 libs/pruviloj/Pruviloj/Derive/DecEq.idr+1−1 libs/pruviloj/Pruviloj/Derive/Eliminators.idr+1−1 libs/pruviloj/Pruviloj/Disjoint.idr+1−1 libs/pruviloj/Pruviloj/Induction.idr+1−1 libs/pruviloj/Pruviloj/Injective.idr+1−1 libs/pruviloj/Pruviloj/Internals.idr+2 libs/pruviloj/Pruviloj/Internals/TyConInfo.idr+1−1 libs/pruviloj/Pruviloj/Renamers.idr+2 samples/tutorial/interp.idr+1−1 src/IRTS/Compiler.hs+1−1 src/IRTS/System.hs+3−7 src/Idris/ASTUtils.hs+1−4 src/Idris/AbsSyntax.hs+47−11 src/Idris/AbsSyntaxTree.hs+21−18 src/Idris/Core/CaseTree.hs+2−2 src/Idris/Core/Evaluate.hs+13−10 src/Idris/Core/TT.hs+1−1 src/Idris/Coverage.hs+3−1 src/Idris/DeepSeq.hs+6−6 src/Idris/Delaborate.hs+2−2 src/Idris/Docs.hs+3−3 src/Idris/Elab/Class.hs+2−2 src/Idris/Elab/Clause.hs+32−18 src/Idris/Elab/Instance.hs+8−4 src/Idris/Elab/Term.hs+6−8 src/Idris/Elab/Type.hs+13 src/Idris/Elab/Utils.hs+16 src/Idris/ElabDecls.hs+2−2 src/Idris/IBC.hs+88−62 src/Idris/IdrisDoc.hs+1−1 src/Idris/Interactive.hs+28−11 src/Idris/ParseData.hs+8−8 src/Idris/ParseExpr.hs+6−6 src/Idris/ParseHelpers.hs+45−12 src/Idris/Parser.hs+40−41 src/Idris/ProofSearch.hs+32−35 src/Idris/REPL.hs+67−41 src/Idris/REPLParser.hs+2−1 src/Idris/Reflection.hs+4−4 src/Pkg/PParser.hs+2−2 src/Pkg/Package.hs+1−1 stack.yaml+4−1 test/Makefile+22−13 test/basic001/run+2−2 test/basic002/run+1−1 test/basic003/run+1−1 test/basic004/run+1−1 test/basic005/run+1−1 test/basic006/run+2−2 test/basic007/run+1−1 test/basic008/run+1−1 test/basic009/A.idr+1 test/basic009/B/C.idr+1 test/basic009/run+3−3 test/basic011/run+1−1 test/basic012/run+1−1 test/basic013/run+1−1 test/basic014/run+1−1 test/basic015/run+1−1 test/basic016/run+1−1 test/bignum001/run+1−1 test/bignum002/run+1−1 test/bounded001/run+1−1 test/classes001/run+1−1 test/corecords001/run+1−1 test/corecords002/run+1−1 test/delab001/run+1−1 test/disambig002/run+1−1 test/docs001/run+1−1 test/docs002/run+1−1 test/docs003/expected+1−1 test/docs003/run+1−1 test/docs004/run+1−1 test/dsl001/run+1−1 test/dsl001/test001.idr+1−1 test/dsl002/Resimp.idr+3−1 test/dsl002/run+1−1 test/dsl003/run+1−1 test/dsl004/run+3−3 test/effects001/run+2−2 test/effects002/run+1−1 test/effects003/VectMissing.idr+1 test/effects003/run+1−1 test/effects004/run+1−1 test/effects005/run+2−2 test/error001/run+1−1 test/error002/run+1−1 test/error003/run+1−1 test/error004/run+1−1 test/error005/run+1−1 test/error006/run+1−1 test/ffi001/run+1−1 test/ffi002/run+1−1 test/ffi003/run+1−1 test/ffi004/run+1−1 test/ffi005/run+1−1 test/ffi006/run+1−1 test/folding001/run+1−1 test/idrisdoc001/run+1−1 test/idrisdoc002/TestFunctions.idr+2−1 test/idrisdoc002/run+1−1 test/idrisdoc003/TestDatatypes.idr+2−1 test/idrisdoc003/run+1−1 test/idrisdoc004/TestTypeclasses.idr+1 test/idrisdoc004/run+1−1 test/idrisdoc005/TestTracing.idr+2−1 test/idrisdoc005/run+1−1 test/idrisdoc006/A/fully/Qualified/NAME.idr+2−2 test/idrisdoc006/B.idr+2−1 test/idrisdoc006/run+2−2 test/idrisdoc007/run+1−1 test/idrisdoc008/Abstract.idr+2−2 test/idrisdoc008/Visible.idr+2−2 test/idrisdoc008/run+1−1 test/idrisdoc009/Test.idr+2 test/idrisdoc009/run+1−1 test/interactive001/run+1−1 test/interactive002/expected+1−1 test/interactive002/run+1−1 test/interactive003/run+1−1 test/interactive004/expected+1−1 test/interactive004/run+1−1 test/interactive005/run+1−1 test/interactive006/run+1−1 test/interactive007/run+1−1 test/interactive008/run+1−1 test/interactive009/expected+1−1 test/interactive009/run+1−1 test/interactive010/expected+4−4 test/interactive010/run+1−1 test/interactive011/run+1−1 test/interactive012/run+1−1 test/io001/run+1−1 test/io002/run+1−1 test/io003/run+2−2 test/literate001/Lit.lidr+2−2 test/literate001/run+2−2 test/meta001/run+1−1 test/meta002/run+2−2 test/meta003/run+1−1 test/meta004/run+1−1 test/mktest.pl+1−1 test/pkg001/run+1−1 test/pkg002/run+1−1 test/pkg003/run+1−1 test/pkg004/expected+3−3 test/pkg004/run+1−1 test/pkg004/test.ipkg−1 test/primitives001/run+2−2 test/primitives003/run+1−1 test/primitives004-disabled/run+1−1 test/proof001/run+1−1 test/proof002/Reflect.idr+1 test/proof002/expected+3−3 test/proof002/run+2−2 test/proof003/Parity.idr+2 test/proof003/expected+2−2 test/proof003/run+1−1 test/proof004/run+1−1 test/proof005/run+1−1 test/proof006/run+1−1 test/proof007/run+1−1 test/proof008/run+1−1 test/proof009/run+1−1 test/proof010/run+1−1 test/proofsearch001/run+1−1 test/proofsearch002/Process.idr+1−1 test/proofsearch002/run+1−1 test/proofsearch003/run+1−1 test/pruviloj001/run+1−1 test/quasiquote001/run+1−1 test/quasiquote002/run+1−1 test/quasiquote003/run+1−1 test/quasiquote004/run+1−1 test/quasiquote005/run+1−1 test/quasiquote006/run+1−1 test/records001/run+1−1 test/records002/run+1−1 test/records003/run+1−1 test/records004/run+1−1 test/reg001/run+1−1 test/reg002/run+1−1 test/reg003/run+2−2 test/reg004/run+1−1 test/reg005/expected+3 test/reg005/reg005.idr+9 test/reg005/run+4 test/reg006/run+1−1 test/reg007/A.lidr+1−1 test/reg007/run+1−1 test/reg010/run+1−1 test/reg013/run+1−1 test/reg016/run+1−1 test/reg017/run+1−1 test/reg018/run+4−4 test/reg020/run+1−1 test/reg023/run+1−1 test/reg024/run+1−1 test/reg025/run+1−1 test/reg027/run+2−2 test/reg028/run+2−2 test/reg029/run+2−2 test/reg031/run+1−1 test/reg032/run+1−1 test/reg034/run+1−1 test/reg035/run+3−3 test/reg036/run+1−1 test/reg037/run+1−1 test/reg038/run+1−1 test/reg040/run+1−1 test/reg041/run+2−2 test/reg042/run+1−1 test/reg044/run+1−1 test/reg045/run+1−1 test/reg046/run+1−1 test/reg047/run+2−2 test/reg048/run+1−1 test/reg049/run+1−1 test/reg050/run+3−3 test/reg051-disabled/run+1−1 test/reg052/run+1−1 test/reg053/run+1−1 test/reg054/run+1−1 test/reg055/run+2−2 test/reg056/run+1−1 test/reg057/run+1−1 test/reg058/run+2−2 test/reg059/run+1−1 test/reg060/run+1−1 test/reg061/run+1−1 test/reg062/run+2−2 test/reg063/run+1−1 test/reg064/run+1−1 test/reg065/run+1−1 test/reg066/run+1−1 test/reg067/run+1−1 test/runtest.hs+218 test/runtest.pl−214 test/sourceLocation001/run+1−1 test/sugar001/run+1−1 test/sugar002/run+1−1 test/sugar003/run+1−1 test/sugar004/run+1−1 test/sugar005/run+1−1 test/syntax001/expected+2−2 test/syntax001/run+2−2 test/syntax002/run+1−1 test/tactics001/run+1−1 test/totality001/run+3−3 test/totality002/run+3−3 test/totality003/run+2−2 test/totality004/run+2−2 test/totality005/run+2−2 test/totality006/run+3−3 test/totality007/run+1−1 test/totality008/run+1−1 test/totality009/run+2−2 test/totality010/run+1−1 test/tutorial001/run+1−1 test/tutorial002/run+1−1 test/tutorial003/run+1−1 test/tutorial004/run+1−1 test/tutorial005/run+1−1 test/tutorial006/run+3−3 test/unique001/run+6−6 test/unique002/run+2−2 test/unique003/run+1−1
.gitignore+1
@@ -27,6 +27,7 @@ libs/contrib/contrib_doc/
2727test/output
2828test/*[0-9][0-9][0-9]/output
2929test/*[0-9][0-9][0-9]/*.exe
30+test/runtest.exe
3031tags
3132TAGS
3233src/Version_idris.hs
CHANGELOG+26−2
@@ -1,5 +1,29 @@
1−New in 0.9.21:
2−==============
1+New in 0.11:
2+============
3+
4+Updated export rules
5+--------------------
6+
7+* The export rules are:
8+ - 'private' means that the definition is not exported at all
9+ - 'export' means that the top level type is exported, but not the
10+ definition. In the case of 'data', this means the type constructor is
11+ exported but not the data constructors.
12+ - 'public export' means that the entire definition is exported.
13+* By default, names are 'private'. This can be altered with an %access
14+ directive as before.
15+* Exported types can only refer to other exported names
16+* Publicly exported definitions can only refer to publicly exported names
17+
18+Minor language changes
19+----------------------
20+
21+* The '[static]' annotation is changed to '%static' to be consistent with the
22+other annotations.
23+
24+
25+New in 0.10:
26+============
327
428* 'class' and 'instance' are now deprecated keywords. They have been
529 replaced by 'interface' and 'implementation' respectively. This is to
CONTRIBUTORS+1
@@ -11,6 +11,7 @@ Jakob Brünker
1111Alyssa Carter
1212David Raymond Christiansen
1313Carter Charbonneau
14+Aaron Craelius
1415Jason Dagit
1516Guglielmo Fachini
1617Simon Fowler
INSTALL.md+8−3
@@ -63,9 +63,9 @@ contribute.
6363[Stack](https://github.com/commercialhaskell/stack) is a new
6464cross-platform program for developing Haskell projects, that enhances
6565the functionality provided by Cabal. There is experimental support for
66−building Idris from source using with stack, that uses the LTS 3.16
67−resolver. This installation has been tested on Ubuntu 14.04.2 LTS,
68−only.
66+building Idris from source with stack.
67+This installation has been tested on Ubuntu 14.04.2 LTS, and the current
68+NixOS unstable.
6969
7070To build Idris with stack the following commands are recommended:
7171
@@ -77,6 +77,11 @@ haven't used stack before this will also setup the related
7777infrastructure. For more information about Stack please visit the
7878[Stack website](https://github.com/commercialhaskell/stack).
7979
80+On NixOS, please use the following command instead, to make sure
81+the required libraries and header files are available:
82+
83+* `stack build --nix`
84+
8085### System GHC
8186
8287The flag `--system-ghc` can be added to enforce use of your system's
Makefile+3−14
@@ -20,24 +20,13 @@ build: dist/setup-config
2020test: doc test_c
2121
2222test_c:
23− $(MAKE) -C test IDRIS=../dist/build/idris
24−
25−test_java:
26− $(MAKE) -C test IDRIS=../dist/build/idris test_java
27−
28−test_llvm:
29− $(MAKE) -C test IDRIS=../dist/build/idris test_llvm
23+ $(MAKE) -C test IDRIS=../dist/build/idris/idris test
3024
3125test_js:
32− $(MAKE) -C test IDRIS=../dist/build/idris test_js
33−
34−test_all:
35− $(MAKE) test
36− $(MAKE) test_llvm
37− $(MAKE) test_java
26+ $(MAKE) -C test IDRIS=../dist/build/idris/idris test_js
3827
3928test_timed:
40− $(MAKE) -C test IDRIS=../dist/build/idris time
29+ $(MAKE) -C test IDRIS=../dist/build/idris/idris time
4130
4231lib_clean:
4332 $(MAKE) -C libs IDRIS=../../dist/build/idris/idris RTS=../../dist/build/rts/libidris_rts clean
Setup.hs+20−1
@@ -10,6 +10,7 @@ import Distribution.Simple.LocalBuildInfo as L
1010import qualified Distribution.Simple.Setup as S
1111import qualified Distribution.Simple.Program as P
1212import Distribution.Simple.Utils (createDirectoryIfMissingVerbose, rewriteFile)
13+import Distribution.Compiler
1314import Distribution.PackageDescription
1415import Distribution.Text
1516
@@ -45,6 +46,9 @@ mymake = "make"
4546make verbosity =
4647 P.runProgramInvocation verbosity . P.simpleProgramInvocation mymake
4748
49+#ifdef mingw32_HOST_OS
50+windres verbosity = P.runProgramInvocation verbosity . P.simpleProgramInvocation "windres"
51+#endif
4852-- -----------------------------------------------------------------------------
4953-- Flags
5054
@@ -53,7 +57,7 @@ usesGMP flags =
5357 case lookup (FlagName "gmp") (S.configConfigurationsFlags flags) of
5458 Just True -> True
5559 Just False -> False
56− Nothing -> True
60+ Nothing -> False
5761
5862execOnly :: S.ConfigFlags -> Bool
5963execOnly flags =
@@ -198,6 +202,20 @@ getVersion args flags = do
198202 let buildinfo = (emptyBuildInfo { cppOptions = ["-DVERSION="++hash] }) :: BuildInfo
199203 return (Just buildinfo, [])
200204
205+
206+
207+idrisPreBuild args flags = do
208+#ifdef mingw32_HOST_OS
209+ createDirectoryIfMissingVerbose verbosity True dir
210+ windres verbosity ["icons/idris_icon.rc","-o", dir++"idris_icon.o"]
211+ return (Nothing, [("idris", emptyBuildInfo { ldOptions = [dir ++ "idris_icon.o"] })])
212+ where
213+ verbosity = S.fromFlag $ S.buildVerbosity flags
214+ dir = S.fromFlagOrDefault "dist" $ S.buildDistPref flags
215+#else
216+ return (Nothing, [])
217+#endif
218+
201219idrisBuild _ flags _ local = unless (execOnly (configFlags local)) $ do
202220 buildStdLib
203221 buildRTS
@@ -247,6 +265,7 @@ idrisInstall verbosity copy pkg local = unless (execOnly (configFlags local)) $
247265main = defaultMainWithHooks $ simpleUserHooks
248266 { postClean = idrisClean
249267 , postConf = idrisConfigure
268+ , preBuild = idrisPreBuild
250269 , postBuild = idrisBuild
251270 , postCopy = \_ flags pkg local ->
252271 idrisInstall (S.fromFlag $ S.copyVerbosity flags)
config.mk+4−12
@@ -20,28 +20,20 @@ endif
2020MACHINE := $(shell $(CC) -dumpmachine)
2121ifneq (, $(findstring darwin, $(MACHINE)))
2222 OS :=darwin
23−else
24−ifneq (, $(findstring cygwin, $(MACHINE)))
23+else ifneq (, $(findstring cygwin, $(MACHINE)))
2524 OS :=windows
26−else
27−ifneq (, $(findstring mingw, $(MACHINE)))
25+else ifneq (, $(findstring mingw, $(MACHINE)))
2826 OS :=windows
29−else
30−ifneq (, $(findstring windows, $(MACHINE)))
27+else ifneq (, $(findstring windows, $(MACHINE)))
3128 OS :=windows
3229else
3330 OS :=unix
3431endif
35−endif
36−endif
37−endif
3832
3933ifeq ($(OS),darwin)
4034 SHLIB_SUFFIX :=.dylib
41−else
42−ifeq ($(OS),windows)
35+else ifeq ($(OS),windows)
4336 SHLIB_SUFFIX :=.DLL
4437else
4538 SHLIB_SUFFIX :=.so
4639endif
47−endif
docs/conf.py+4−4
@@ -59,9 +59,9 @@ author = u'The Idris Community'
5959# built documents.
6060#
6161# The short X.Y version.
62−version = '0.9.19'
62+version = '0.10.1'
6363# The full version, including alpha/beta/rc tags.
64−release = '0.9.19.1'
64+release = '0.10.1'
6565
6666# The language for content autogenerated by Sphinx. Refer to documentation
6767# for a list of supported languages.
@@ -234,9 +234,9 @@ latex_elements = {
234234# (source start file, target name, title,
235235# author, documentclass [howto, manual, or own class]).
236236latex_documents = [
237− ('guides/index', 'idris-guides.tex', u'Idris Tutorial Series', u'The Idris Community', 'manual'),
238− ('reference/index', 'idris-reference.tex', u'The Idris Reference', u'The Idris Community', 'manual'),
239237 ('tutorial/index', 'idris-tutorial.tex', u'The Idris Tutorial', u'The Idris Community', 'manual'),
238+ ('guides/index', 'idris-guides.tex', u'Idris Tutorial Series', u'The Idris Community', 'manual'),
239+# ('reference/index', 'idris-reference.tex', u'The Idris Reference', u'The Idris Community', 'manual'),
240240 ('effects/index', 'eff-tutorial.tex', u'The Effects Tutorial', u'The Idris Community', 'manual')
241241 ]
242242
docs/effects/depeff.rst+1−1
@@ -183,7 +183,7 @@ to support random access files and better reporting of error conditions.
183183 writeLine : String -> Eff () [FILE_IO (OpenFile Write)]
184184 eof : Eff Bool [FILE_IO (OpenFile Read)]
185185
186− instance Handler FileIO IO
186+ Handler FileIO IO where { ... }
187187
188188In particular, consider the type of ``open``:
189189
docs/effects/hangman.rst+1−1
@@ -193,7 +193,7 @@ implementation for ``MysteryRules`` is surprisingly straightforward:
193193
194194.. code-block:: idris
195195
196− instance Handler MysteryRules m where
196+ Handler MysteryRules m where
197197 handle (MkG w g got []) Won k = k () (GameWon w)
198198 handle (MkG w Z got m) Lost k = k () (GameLost w)
199199
docs/effects/impleff.rst+13−13
@@ -93,16 +93,16 @@ Recall that to run an effectful program in ``Eff``, we use one of the
9393``run`` family of functions to run the program in a particular
9494computation context ``m``. For each effect, therefore, we must explain
9595how it is executed in a particular computation context for ``run`` to
96−work in that context. This is achieved with the following type class:
96+work in that context. This is achieved with the following interface:
9797
9898.. code-block:: idris
9999
100− class Handler (e : Effect) (m : Type -> Type) where
100+ interface Handler (e : Effect) (m : Type -> Type) where
101101 handle : resource -> (eff : e t resource resource') ->
102102 ((x : t) -> resource' x -> m a) -> m a
103103
104−We have already seen some instance declarations in the effect
105−summaries in Section :ref:`sect-simpleff`. An instance of ``Handler e
104+We have already seen some implementation declarations in the effect
105+summaries in Section :ref:`sect-simpleff`. An implementation of ``Handler e
106106m`` means that the effect declared with signature ``e`` can be run in
107107computation context ``m``. The ``handle`` function takes:
108108
@@ -123,7 +123,7 @@ in the case of ``Get``, or passes on a new state, in the case of
123123
124124.. code-block:: idris
125125
126− instance Handler State m where
126+ Handler State m where
127127 handle st Get k = k st st
128128 handle st (Put n) k = k () n
129129
@@ -176,7 +176,7 @@ The following listing summarises what is required to define the
176176 STATE : Type -> EFFECT
177177 STATE t = MkEff t State
178178
179− instance Handler State m where
179+ Handler State m where
180180 handle st Get k = k st st
181181 handle st (Put n) k = k () n
182182
@@ -211,13 +211,13 @@ directly.
211211 PutCh : Char -> sig StdIO ()
212212 GetCh : sig StdIO Char
213213
214− instance Handler StdIO IO where
214+ Handler StdIO IO where
215215 handle () (PutStr s) k = do putStr s; k () ()
216216 handle () GetStr k = do x <- getLine; k x ()
217217 handle () (PutCh c) k = do putChar c; k () ()
218218 handle () GetCh k = do x <- getChar; k x ()
219219
220− instance Handler StdIO (IOExcept a) where
220+ Handler StdIO (IOExcept a) where
221221 handle () (PutStr s) k = do ioe_lift $ putStr s; k () ()
222222 handle () GetStr k = do x <- ioe_lift $ getLine; k x ()
223223 handle () (PutCh c) k = do ioe_lift $ putChar c; k () ()
@@ -241,10 +241,10 @@ error.
241241 data Exception : Type -> Effect where
242242 Raise : a -> sig (Exception a) b
243243
244− instance Handler (Exception a) Maybe where
244+ Handler (Exception a) Maybe where
245245 handle _ (Raise e) k = Nothing
246246
247− instance Handler (Exception a) List where
247+ Handler (Exception a) List where
248248 handle _ (Raise e) k = []
249249
250250 EXCEPTION : Type -> EFFECT
@@ -265,14 +265,14 @@ value.
265265 data Selection : Effect where
266266 Select : List a -> sig Selection a
267267
268− instance Handler Selection Maybe where
268+ Handler Selection Maybe where
269269 handle _ (Select xs) k = tryAll xs where
270270 tryAll [] = Nothing
271271 tryAll (x :: xs) = case k x () of
272272 Nothing => tryAll xs
273273 Just v => Just v
274274
275− instance Handler Selection List where
275+ Handler Selection List where
276276 handle r (Select xs) k = concatMap (\x => k x r) xs
277277
278278 SELECT : EFFECT
@@ -308,7 +308,7 @@ the equivalent ``Eff`` programs.
308308 WriteLine : String -> sig FileIO () (OpenFile Write)
309309 EOF : sig FileIO Bool (OpenFile Read)
310310
311− instance Handler FileIO IO where
311+ Handler FileIO IO where
312312 handle () (Open fname m) k = do h <- openFile fname m
313313 if !(validFile h)
314314 then k True (FH h)
docs/effects/simpleeff.rst+12−12
@@ -19,9 +19,9 @@ in a module ``Effect.State``
1919 putM : y -> Eff () [STATE x] [STATE y]
2020 update : (x -> x) -> Eff () [STATE x]
2121
22− instance Handler State m
22+ Handler State m where { ... }
2323
24−The last line, ``instance Handler State m``, means that the ``STATE``
24+The last line, ``Handler State m where { ... }``, means that the ``STATE``
2525effect is usable in any computation context ``m``. That is, a program
2626which uses this effect and returns something of type ``a`` can be
2727evaluated to something of type ``m a`` using ``run``, for any
@@ -63,8 +63,8 @@ can perform (or at the very least simulate) console I/O:
6363 getStr : Eff String [STDIO]
6464 getChar : Eff Char [STDIO]
6565
66− instance Handler StdIO IO
67− instance Handler StdIO (IOExcept a)
66+ Handler StdIO IO where { ... }
67+ Handler StdIO (IOExcept a) where { ... }
6868
6969Examples
7070--------
@@ -148,11 +148,11 @@ generally:
148148
149149 raise : a -> Eff b [EXCEPTION a]
150150
151− instance Handler (Exception a) Maybe
152− instance Handler (Exception a) List
153− instance Handler (Exception a) (Either a)
154− instance Handler (Exception a) (IOExcept a)
155− instance Show a => Handler (Exception a) IO
151+ Handler (Exception a) Maybe where { ... }
152+ Handler (Exception a) List where { ... }
153+ Handler (Exception a) (Either a) where { ... }
154+ Handler (Exception a) (IOExcept a) where { ... }
155+ Show a => Handler (Exception a) IO where { ... }
156156
157157Example
158158-------
@@ -247,7 +247,7 @@ Random number generation is also implemented by the library, in module
247247 rndInt : Integer -> Integer -> Eff Integer [RND]
248248 rndFin : (k : Nat) -> Eff (Fin (S k)) [RND]
249249
250− instance Handler Random m
250+ Handler Random m where { ... }
251251
252252Random number generation is considered side-effecting because its
253253implementation generally relies on some external source of randomness.
@@ -333,8 +333,8 @@ succeeds:
333333
334334 select : List a -> Eff a [SELECT]
335335
336− instance Handler Selection Maybe
337− instance Handler Selection List
336+ Handler Selection Maybe where { ... }
337+ Handler Selection List where { ... }
338338
339339Example
340340-------
docs/effects/state.rst+6−6
@@ -189,7 +189,7 @@ shown in Listing [introprog].
189189 data BTree a = Leaf
190190 | Node (BTree a) a (BTree a)
191191
192− instance Show a => Show (BTree a) where
192+ Show a => Show (BTree a) where
193193 show Leaf = "[]"
194194 show (Node l x r) = "[" ++ show l ++ " "
195195 ++ show x ++ " "
@@ -231,19 +231,19 @@ here for illustrative purposes):
231231 run : Applicative m => {env : Env m xs} -> Eff a xs -> m a
232232
233233The ``env`` argument is implicit, and initialised automatically where
234−possible using default values given by instances of the following type
235−class:
234+possible using default values given by implementations of the following
235+interface:
236236
237237.. code-block:: idris
238238
239− class Default a where
239+ interface Default a where
240240 default : a
241241
242−Instances of ``Default`` are defined for all primitive types, and many
242+Implementations of ``Default`` are defined for all primitive types, and many
243243library types such as ``List``, ``Vect``, ``Maybe``, pairs, etc.
244244However, where no default value exists for a resource type (for
245245example, you may want a ``STATE`` type for which there is no
246−``Default`` instance) the resource environment can be given explicitly
246+``Default`` implementation) the resource environment can be given explicitly
247247using one of the following functions:
248248
249249.. code-block:: idris
docs/effects/summary.rst+14−14
@@ -22,11 +22,11 @@ EXCEPTION
2222
2323 raise : a -> Eff b [EXCEPTION a]
2424
25− instance Handler (Exception a) Maybe
26− instance Handler (Exception a) List
27− instance Handler (Exception a) (Either a)
28− instance Handler (Exception a) (IOExcept a)
29− instance Show a => Handler (Exception a) IO
25+ Handler (Exception a) Maybe where { ... }
26+ Handler (Exception a) List where { ... }
27+ Handler (Exception a) (Either a) where { ... }
28+ Handler (Exception a) (IOExcept a) where { ... }
29+ Show a => Handler (Exception a) IO where { ... }
3030
3131FILE\_IO
3232========
@@ -54,7 +54,7 @@ FILE\_IO
5454 writeLine : String -> Eff () [FILE_IO (OpenFile Write)]
5555 eof : Eff Bool [FILE_IO (OpenFile Read)]
5656
57− instance Handler FileIO IO
57+ Handler FileIO IO where { ... }
5858
5959RND
6060===
@@ -73,7 +73,7 @@ RND
7373 rndInt : Integer -> Integer -> Eff m Integer [RND]
7474 rndFin : (k : Nat) -> Eff m (Fin (S k)) [RND]
7575
76− instance Handler Random m
76+ Handler Random m where { ... }
7777
7878SELECT
7979======
@@ -88,8 +88,8 @@ SELECT
8888
8989 select : List a -> Eff m a [SELECT]
9090
91− instance Handler Selection Maybe
92− instance Handler Selection List
91+ Handler Selection Maybe where { ... }
92+ Handler Selection List where { ... }
9393
9494STATE
9595=====
@@ -107,7 +107,7 @@ STATE
107107 putM : y -> Eff m () [STATE x] [STATE y]
108108 update : (x -> x) -> Eff m () [STATE x]
109109
110− instance Handler State m
110+ Handler State m where { ... }
111111
112112STDIO
113113=====
@@ -128,8 +128,8 @@ STDIO
128128 getStr : Handler StdIO m => Eff m String [STDIO]
129129 getChar : Handler StdIO m => Eff m Char [STDIO]
130130
131− instance Handler StdIO IO
132− instance Handler StdIO (IOExcept a)
131+ Handler StdIO IO where { ... }
132+ Handler StdIO (IOExcept a) where { ... }
133133
134134SYSTEM
135135======
@@ -148,5 +148,5 @@ SYSTEM
148148 time : Handler System e => Eff e Int [SYSTEM]
149149 getEnv : Handler System e => String -> Eff e (Maybe String) [SYSTEM]
150150
151− instance Handler System IO
152− instance Handler System (IOExcept a)
151+ Handler System IO where { ... }
152+ Handler System (IOExcept a) where { ... }
docs/faq/faq.rst+1−1
@@ -11,7 +11,7 @@ However, Idris has been designed from the start to emphasise general purpose
1111programming rather than theorem proving. As such, it supports interoperability
1212with systems libraries and C programs, and language constructs for
1313domain specific language implementation. It also includes higher level
14−programming constructs such as type classes and do notation.
14+programming constructs such as interfaces (similar to type classes) and do notation.
1515
1616Idris supports multiple back ends (C and JavaScript by default, with the
1717ability to add more via plugins) and has a reference run time system, written
docs/proofs/patterns.rst+2−2
@@ -181,8 +181,8 @@ For ``plus_commutes_Z_rhs_2``, we now see:
181181 --------------------------------------
182182 plus_commutes_Z_rhs_2 : S k = S (plus k 0)
183183
184−Again, the ``fromInteger 0`` is merely due to ``Nat`` being an instance
185−of the ``Num`` typeclass. So we know that ``k = plus k 0``, but how do
184+Again, the ``fromInteger 0`` is merely due to ``Nat`` having an implementation
185+of the ``Num`` interface. So we know that ``k = plus k 0``, but how do
186186we use this to update the goal to ``S k = S k``?
187187
188188To achieve this, Idris provides a ``replace`` function as part of the
docs/proofs/pluscomm.rst+1−1
@@ -177,7 +177,7 @@ given above as Idris type declarations:
177177
178178Both of these properties (and many others) are proved for natural number
179179addition in the Idris standard library, using ``(+)`` from the ``Num``
180−type class rather than using ``plus`` directly. They have the names
180+interface rather than using ``plus`` directly. They have the names
181181``plusCommutative`` and ``plusAssociative`` respectively.
182182
183183In the remainder of this tutorial, we will explore several different
docs/reference/language-features.rst+2−2
@@ -27,7 +27,7 @@ Core Language Features
2727- Heterogeneous equality
2828- ``do`` notation
2929- Idiom brackets
30−- Type classes, supporting default methods and dependencies between
30+- Interfaces (like type classes), supporting default methods and dependencies between
3131 methods
3232- ``rewrite`` prf ``in`` expr
3333- Metavariables
@@ -46,7 +46,7 @@ Core Language Features
4646 using the ``UniqueType`` universe.
4747- `Partial
4848 evaluation <https://github.com/idris-lang/Idris-dev/wiki/Static-Arguments-and-Partial-Evaluation>`__
49− by ``[static]`` argument annotations.
49+ by ``%static`` argument annotations.
5050- Error message reflection
5151- Eliminators
5252- Label types ``'name``
docs/reference/repl.rst+3
@@ -212,6 +212,9 @@ declarations as well, such as ``data``.
212212 Idris> :let x : String; x = "hello"
213213 Idris> x
214214 "hello" : String
215+ Idris> :let y = 10
216+ Idris> y
217+ 10 : Integer
215218 Idris> :let data Foo : Type where Bar : Foo
216219 Idris> Bar
217220 Bar : Foo
docs/tutorial/index.rst+1−1
@@ -21,7 +21,7 @@ The is the Idris Tutorial. It will teach you about programming in the Idris Lang
2121 introduction
2222 starting
2323 typesfuns
24− classes
24+ interfaces
2525 modules
2626 packages
2727 testing
docs/tutorial/classes.rst → docs/tutorial/interfaces.rstrenamed+154−92
@@ -1,8 +1,8 @@
1−.. _sect-classes:
1+.. _sect-interfaces:
22
3−************
4−Type Classes
5−************
3+**********
4+Interfaces
5+**********
66
77We often want to define functions which work across several different
88data types. For example, we would like arithmetic operators to work on
@@ -10,34 +10,33 @@ data types. For example, we would like arithmetic operators to work on
1010``==`` to work on the majority of data types. We would like to be able
1111to display different types in a uniform way.
1212
13−To achieve this, we use a feature which has proved to be effective in
14−Haskell, namely *type classes*. To define a type class, we provide a
15−collection of overloaded operations which describe the interface for
16−*instances* of that class. A simple example is the ``Show`` type
17−class, which is defined in the prelude and provides an interface for
13+To achieve this, we use *interfaces*, which are similar to type classes in
14+Haskell or traits in Rust. To define an interface, we provide a collection of
15+overloadable functions. A simple example is the ``Show``
16+interface, which is defined in the prelude and provides an interface for
1817converting values to ``String``:
1918
2019.. code-block:: idris
2120
22− class Show a where
21+ interface Show a where
2322 show : a -> String
2423
2524This generates a function of the following type (which we call a
26−*method* of the ``Show`` class):
25+*method* of the ``Show`` interface):
2726
2827.. code-block:: idris
2928
3029 show : Show a => a -> String
3130
32−We can read this as: “under the constraint that ``a`` is an instance
33−of ``Show``, take an input ``a`` and return a ``String``.” An instance
34−of a class is defined with an ``instance`` declaration, which provides
35−implementations of the function for a specific type. For example, the
36−``Show`` instance for ``Nat`` could be defined as:
31+We can read this as: “under the constraint that ``a`` has an implementation
32+of ``Show``, take an input ``a`` and return a ``String``.” An implementation
33+of an interface is defined by giving definitions of the methods of the interface.
34+For example, the
35+``Show`` implementation for ``Nat`` could be defined as:
3736
3837.. code-block:: idris
3938
40− instance Show Nat where
39+ Show Nat where
4140 show Z = "Z"
4241 show (S k) = "s" ++ show k
4342
@@ -46,18 +45,18 @@ implementations of the function for a specific type. For example, the
4645 Idris> show (S (S (S Z)))
4746 "sssZ" : String
4847
49−Only one instance of a class can be given for a type — instances may
50−not overlap. Instance declarations can themselves have constraints.
51−To help with resolution, the arguments of an instance must be
48+Only one implementation of an interface can be given for a type — implementations may
49+not overlap. Implementation declarations can themselves have constraints.
50+To help with resolution, the arguments of an implementation must be
5251constructors (either data or type constructors), variables or
53−constants (i.e. you cannot give an instance for a function). For
54−example, to define a ``Show`` instance for vectors, we need to know
55−that there is a ``Show`` instance for the element type, because we are
52+constants (i.e. you cannot give an implementation for a function). For
53+example, to define a ``Show`` implementation for vectors, we need to know
54+that there is a ``Show`` implementation for the element type, because we are
5655going to use it to convert each element to a ``String``:
5756
5857.. code-block:: idris
5958
60− instance Show a => Show (Vect n a) where
59+ Show a => Show (Vect n a) where
6160 show xs = "[" ++ show' xs ++ "]" where
6261 show' : Vect n a -> String
6362 show' Nil = ""
@@ -67,22 +66,22 @@ going to use it to convert each element to a ``String``:
6766Default Definitions
6867===================
6968
70−The library defines an ``Eq`` class which provides an interface for
71−comparing values for equality or inequality, with instances for all of
69+The library defines an ``Eq`` interface which provides methods for
70+comparing values for equality or inequality, with implementations for all of
7271the built-in types:
7372
7473.. code-block:: idris
7574
76− class Eq a where
75+ interface Eq a where
7776 (==) : a -> a -> Bool
7877 (/=) : a -> a -> Bool
7978
80−To declare an instance of a type, we have to give definitions of all
81−of the methods. For example, for an instance of ``Eq`` for ``Nat``:
79+To declare an implementation for a type, we have to give definitions of all
80+of the methods. For example, for an implementation of ``Eq`` for ``Nat``:
8281
8382.. code-block:: idris
8483
85− instance Eq Nat where
84+ Eq Nat where
8685 Z == Z = True
8786 (S x) == (S y) = x == y
8887 Z == (S y) = False
@@ -93,28 +92,28 @@ of the methods. For example, for an instance of ``Eq`` for ``Nat``:
9392It is hard to imagine many cases where the ``/=`` method will be
9493anything other than the negation of the result of applying the ``==``
9594method. It is therefore convenient to give a default definition for
96−each method in the class declaration, in terms of the other method:
95+each method in the interface declaration, in terms of the other method:
9796
9897.. code-block:: idris
9998
100− class Eq a where
99+ interface Eq a where
101100 (==) : a -> a -> Bool
102101 (/=) : a -> a -> Bool
103102
104103 x /= y = not (x == y)
105104 x == y = not (x /= y)
106105
107−A minimal complete definition of an ``Eq`` instance requires either
106+A minimal complete implementation of ``Eq`` requires either
108107``==`` or ``/=`` to be defined, but does not require both. If a method
109108definition is missing, and there is a default definition for it, then
110109the default is used instead.
111110
112−Extending Classes
113−=================
111+Extending Interfaces
112+====================
114113
115−Classes can also be extended. A logical next step from an equality
114+Interfaces can also be extended. A logical next step from an equality
116115relation ``Eq`` is to define an ordering relation ``Ord``. We can
117−define an ``Ord`` class which inherits methods from ``Eq`` as well as
116+define an ``Ord`` interface which inherits methods from ``Eq`` as well as
118117defining some of its own:
119118
120119.. code-block:: idris
@@ -123,7 +122,7 @@ defining some of its own:
123122
124123.. code-block:: idris
125124
126− class Eq a => Ord a where
125+ interface Eq a => Ord a where
127126 compare : a -> a -> Ordering
128127
129128 (<) : a -> a -> Bool
@@ -133,11 +132,11 @@ defining some of its own:
133132 max : a -> a -> a
134133 min : a -> a -> a
135134
136−The ``Ord`` class allows us to compare two values and determine their
135+The ``Ord`` interface allows us to compare two values and determine their
137136ordering. Only the ``compare`` method is required; every other method
138137has a default definition. Using this we can write functions such as
139138``sort``, a function which sorts a list into increasing order,
140−provided that the element type of the list is in the ``Ord`` class. We
139+provided that the element type of the list is in the ``Ord`` interface. We
141140give the constraints on the type variables left of the fat arrow
142141``=>``, and the function type to the right of the fat arrow:
143142
@@ -145,7 +144,7 @@ give the constraints on the type variables left of the fat arrow
145144
146145 sort : Ord a => List a -> List a
147146
148−Functions, classes and instances can have multiple
147+Functions, interfaces and implementations can have multiple
149148constraints. Multiple constraints are written in brackets in a comma
150149separated list, for example:
151150
@@ -157,16 +156,16 @@ separated list, for example:
157156Functors and Applicatives
158157=========================
159158
160−So far, we have seen single parameter type classes, where the parameter
161−is of type ``Type``. In general, there can be any number (greater than
162−0) of parameters, and the parameters can have *any* type. If the type
159+So far, we have seen single parameter interfaces, where the parameter
160+is of type ``Type``. In general, there can be any number of parameters
161+(even zero), and the parameters can have *any* type. If the type
163162of the parameter is not ``Type``, we need to give an explicit type
164−declaration. For example, the ``Functor`` class is defined in the
165−library:
163+declaration. For example, the ``Functor`` interface is defined in the
164+prelude:
166165
167166.. code-block:: idris
168167
169− class Functor (f : Type -> Type) where
168+ interface Functor (f : Type -> Type) where
170169 map : (m : a -> b) -> f a -> f b
171170
172171A functor allows a function to be applied across a structure, for
@@ -174,7 +173,7 @@ example to apply a function to every element in a ``List``:
174173
175174.. code-block:: idris
176175
177− instance Functor List where
176+ Functor List where
178177 map f [] = []
179178 map f (x::xs) = f x :: map f xs
180179
@@ -190,21 +189,21 @@ abstracts the notion of function application:
190189
191190 infixl 2 <*>
192191
193− class Functor f => Applicative (f : Type -> Type) where
192+ interface Functor f => Applicative (f : Type -> Type) where
194193 pure : a -> f a
195194 (<*>) : f (a -> b) -> f a -> f b
196195
197196Monads and ``do``-notation
198197==========================
199198
200−The ``Monad`` class allows us to encapsulate binding and computation,
199+The ``Monad`` interface allows us to encapsulate binding and computation,
201200and is the basis of ``do``-notation introduced in Section
202201:ref:`sect-do`. It extends ``Applicative`` as defined above, and is
203202defined as follows:
204203
205204.. code-block:: idris
206205
207− class Applicative m => Monad (m : Type -> Type) where
206+ interface Applicative m => Monad (m : Type -> Type) where
208207 (>>=) : m a -> (a -> m b) -> m b
209208
210209Inside a ``do`` block, the following syntactic transformations are
@@ -216,12 +215,12 @@ applied:
216215
217216- ``let x = v; e`` becomes ``let x = v in e``
218217
219−``IO`` is an instance of ``Monad``, defined using primitive functions.
220−We can also define an instance for ``Maybe``, as follows:
218+``IO`` has an implementation of ``Monad``, defined using primitive functions.
219+We can also define an implementation for ``Maybe``, as follows:
221220
222221.. code-block:: idris
223222
224− instance Monad Maybe where
223+ Monad Maybe where
225224 Nothing >>= k = Nothing
226225 (Just x) >>= k = k x
227226
@@ -242,11 +241,75 @@ are both available, or return ``Nothing`` if one or both are not ("fail fast").
242241
243242::
244243
245− *classes> m_add (Just 20) (Just 22)
244+ *ifaces> m_add (Just 20) (Just 22)
246245 Just 42 : Maybe Int
247− *classes> m_add (Just 20) Nothing
246+ *ifaces> m_add (Just 20) Nothing
248247 Nothing : Maybe Int
249248
249+Pattern Matching Bind
250+---------------------
251+
252+Sometimes we want to pattern match immediately on the result of a function
253+in ``do`` notation. For example, let's say we have a function ``readNumber``
254+which reads a number from the console, returning a value of the form
255+``Just x`` if the number is valid, or ``Nothing`` otherwise:
256+
257+.. code-block:: idris
258+
259+ readNumber : IO (Maybe Nat)
260+ readNumber = do
261+ input <- getLine
262+ if all isDigit (unpack input)
263+ then pure (Just (cast input))
264+ else pure Nothing
265+
266+If we then use it to write a function to read two numbers, returning
267+``Nothing`` if neither are valid, then we would like to pattern match
268+on the result of ``readNumber``:
269+
270+.. code-block:: idris
271+
272+ readNumbers : IO (Maybe (Nat, Nat))
273+ readNumbers =
274+ do x <- readNumber
275+ case x of
276+ Nothing => pure Nothing
277+ Just x_ok => do y <- readNumber
278+ case y of
279+ Nothing => pure Nothing
280+ Just y_ok => pure (Just (x_ok, y_ok))
281+
282+If there's a lot of error handling, this could get deeply nested very quickly!
283+So instead, we can combine the bind and the pattern match in one line. For example,
284+we could try pattern matching on values of the form ``Just x_ok``:
285+
286+.. code-block:: idris
287+
288+ readNumbers : IO (Maybe (Nat, Nat))
289+ readNumbers =
290+ do Just x_ok <- readNumber
291+ Just y_ok <- readNumber
292+ pure (Just (x_ok, y_ok))
293+
294+There is still a problem, however, because we've now omitted the case for
295+``Nothing`` so ``readNumbers`` is no longer total! We can add the ``Nothing``
296+case back as follows:
297+
298+.. code-block:: idris
299+
300+ readNumbers : IO (Maybe (Nat, Nat))
301+ readNumbers =
302+ do Just x_ok <- readNumber | Nothing => pure Nothing
303+ Just y_ok <- readNumber | Nothing => pure Nothing
304+ pure (Just (x_ok, y_ok))
305+
306+The effect of this version of ``readNumbers`` is identical to the first (in
307+fact, it is syntactic sugar for it and directly translated back into that form).
308+The first part of each statement (``Just x_ok <-`` and ``Just y_ok <-``) gives
309+the preferred binding - if this matches, execution will continue with the rest
310+of the ``do`` block. The second part gives the alternative bindings, of which
311+there may be more than one.
312+
250313``!``-notation
251314--------------
252315
@@ -296,11 +359,11 @@ Monad comprehensions
296359
297360The list comprehension notation we saw in Section
298361:ref:`sect-more-expr` is more general, and applies to anything which
299−is an instance of both ``Monad`` and ``Alternative``:
362+has an implementation of both ``Monad`` and ``Alternative``:
300363
301364.. code-block:: idris
302365
303− class Applicative f => Alternative (f : Type -> Type) where
366+ interface Applicative f => Alternative (f : Type -> Type) where
304367 empty : f a
305368 (<|>) : f a -> f a -> f a
306369
@@ -364,19 +427,19 @@ alternative notion of function application, with explicit calls to
364427
365428Rather than having to insert ``m_app`` everywhere there is an
366429application, we can use idiom brackets to do the job for us.
367−To do this, we can make ``Maybe`` an instance of ``Applicative``
430+To do this, we can give ``Maybe`` an implementation of ``Applicative``
368431as follows, where ``<*>`` is defined in the same way as ``m_app``
369432above (this is defined in the Idris library):
370433
371434.. code-block:: idris
372435
373− instance Applicative Maybe where
436+ Applicative Maybe where
374437 pure = Just
375438
376439 (Just f) <*> (Just a) = Just (f a)
377440 _ <*> _ = Nothing
378441
379−Using ``<*>`` we can use this instance as follows, where a function
442+Using ``<*>`` we can use this implementation as follows, where a function
380443application ``[| f a1 …an |]`` is translated into ``pure f <*> a1 <*>
381444… <*> an``:
382445
@@ -407,8 +470,8 @@ We define a data type ``Eval`` to wrap an evaluator:
407470 data Eval : Type -> Type where
408471 MkEval : (List (String, Int) -> Maybe a) -> Eval a
409472
410−Wrapping the evaluator in a data type means we will be able to make it
411−an instance of a type class later. We begin by defining a function to
473+Wrapping the evaluator in a data type means we will be able to provide
474+implementations of interfaces for it later. We begin by defining a function to
412475retrieve values from the context during evaluation:
413476
414477.. code-block:: idris
@@ -421,18 +484,18 @@ retrieve values from the context during evaluation:
421484 then (Just val)
422485 else (fetchVal xs)
423486
424−When defining an evaluator for the language, we will be applying
425−functions in the context of an ``Eval``, so it is natural to make
426−``Eval`` an instance of ``Applicative``. Before ``Eval`` can be an
427−instance of ``Applicative`` it is necessary to make ``Eval`` an
428−instance of ``Functor``:
487+When defining an evaluator for the language, we will be applying functions in
488+the context of an ``Eval``, so it is natural to give ``Eval`` an implementation
489+of ``Applicative``. Before ``Eval`` can have an implementation of
490+``Applicative`` it is necessary for ``Eval`` to have an implementation of
491+``Functor``:
429492
430493.. code-block:: idris
431494
432− instance Functor Eval where
495+ Functor Eval where
433496 map f (MkEval g) = MkEval (\e => map f (g e))
434497
435− instance Applicative Eval where
498+ Applicative Eval where
436499 pure x = MkEval (\e => Just x)
437500
438501 (<*>) (MkEval f) (MkEval g) = MkEval (\x => app (f x) (g x)) where
@@ -454,24 +517,24 @@ to handle errors:
454517 runEval env e = case eval e of
455518 MkEval envFn => envFn env
456519
457−Named Instances
458−===============
520+Named Implementations
521+=====================
459522
460−It can be desirable to have multiple instances of a type class, for
461−example to provide alternative methods for sorting or printing values.
462−To achieve this, instances can be *named* as follows:
523+It can be desirable to have multiple implementations of an interface for the
524+same type, for example to provide alternative methods for sorting or printing
525+values. To achieve this, implementations can be *named* as follows:
463526
464527.. code-block:: idris
465528
466− instance [myord] Ord Nat where
529+ [myord] Ord Nat where
467530 compare Z (S n) = GT
468531 compare (S n) Z = LT
469532 compare Z Z = EQ
470533 compare (S x) (S y) = compare @{myord} x y
471534
472−This declares an instance as normal, but with an explicit name,
473−``myord``. The syntax ``compare @{myord}`` gives an explicit instance to
474−``compare``, otherwise it would use the default instance for ``Nat``. We
535+This declares an implementation as normal, but with an explicit name,
536+``myord``. The syntax ``compare @{myord}`` gives an explicit implementation to
537+``compare``, otherwise it would use the default implementation for ``Nat``. We
475538can use this, for example, to sort a list of ``Nat`` in reverse.
476539Given the following list:
477540
@@ -480,35 +543,34 @@ Given the following list:
480543 testList : List Nat
481544 testList = [3,4,1]
482545
483−We can sort it using the default ``Ord`` instance, then the named
484−instance ``myord`` as follows, at the Idris prompt:
546+We can sort it using the default ``Ord`` implementation, then the named
547+implementation ``myord`` as follows, at the Idris prompt:
485548
486549::
487550
488− *named_instance> show (sort testList)
551+ *named_impl> show (sort testList)
489552 "[sO, sssO, ssssO]" : String
490− *named_instance> show (sort @{myord} testList)
553+ *named_impl> show (sort @{myord} testList)
491554 "[ssssO, sssO, sO]" : String
492555
493556
494557Determining Parameters
495558======================
496559
497−When a class has more than one parameter, it can help resolution if
498−the parameters used to resolve the type class are restricted. For
499−example:
560+When an interface has more than one parameter, it can help resolution if the
561+parameters used to find an implementation are restricted. For example:
500562
501563.. code-block:: idris
502564
503− class Monad m => MonadState s (m : Type -> Type) | m where
565+ interface Monad m => MonadState s (m : Type -> Type) | m where
504566 get : m s
505567 put : s -> m ()
506568
507−In this class, only ``m`` needs to be known to resolve this class, and
508−``s`` can then be determined from the instance. This is declared with
509−the ``| m`` after the class declaration. We call ``m`` a *determining
510−parameter* of the ``MonadState`` class, because it is the parameter
511−used to resolve an instance.
569+In this interface, only ``m`` needs to be known to find an implementation of
570+this interface, and ``s`` can then be determined from the implementation. This
571+is declared with the ``| m`` after the interface declaration. We call ``m`` a
572+*determining parameter* of the ``MonadState`` interface, because it is the
573+parameter used to find an implementation.
512574
513575
514576.. [1] Conor McBride and Ross Paterson. 2008. Applicative programming
docs/tutorial/interp.rst+3−3
@@ -285,15 +285,15 @@ program at the Idris interactive environment is:
285285Aside: ``cast``
286286---------------
287287
288−The prelude defines a type class ``Cast`` which allows conversion
288+The prelude defines an interface ``Cast`` which allows conversion
289289between types:
290290
291291.. code-block:: idris
292292
293− class Cast from to where
293+ interface Cast from to where
294294 cast : from -> to
295295
296−It is a *multi-parameter* type class, defining the source type and
296+It is a *multi-parameter* interface, defining the source type and
297297object type of the cast. It must be possible for the type checker to
298298infer *both* parameters at the point where the cast is applied. There
299299are casts defined between all of the primitive types, as far as they
docs/tutorial/modules.rst+4−4
@@ -8,7 +8,7 @@ An Idris program consists of a collection of modules. Each module
88includes an optional ``module`` declaration giving the name of the
99module, a list of ``import`` statements giving the other modules which
1010are to be imported, and a collection of declarations and definitions of
11−types, classes and functions. For example, the listing below gives a
11+types, interfaces and functions. For example, the listing below gives a
1212module which defines a binary tree type ``BTree`` (in a file
1313``Btree.idr``):
1414
@@ -78,19 +78,19 @@ Export Modifiers
7878By default, all names defined in a module are exported for use by other
7979modules. However, it is good practice only to export a minimal interface
8080and keep internal details abstract. Idris allows functions, types,
81−and classes to be marked as: ``public``, ``abstract`` or ``private``:
81+and interfaces to be marked as: ``public``, ``abstract`` or ``private``:
8282
8383- ``public`` means that both the name and definition are exported. For
8484 functions, this means that the implementation is exported (which
8585 means, for example, it can be used in a dependent type). For data
8686 types, this means that the type name and the constructors are
87− exported. For classes, this means that the class name and method
87+ exported. For interfaces, this means that the interface name and method
8888 names are exported.
8989
9090- ``abstract`` means that only the name is exported. For functions,
9191 this means that the implementation is not exported. For data types,
9292 this means that the type name is exported but not the constructors.
93− For classes, this means that the class name is exported but not the
93+ For interfaces, this means that the interface name is exported but not the
9494 method names.
9595
9696- ``private`` means that neither the name nor the definition is
docs/tutorial/provisional.rst+2−2
@@ -266,12 +266,12 @@ the user and outputs it in binary.
266266 x <- getLine
267267 print (natToBin (fromInteger (cast x)))
268268
269−For this to work, of course, we need a ``Show`` instance for
269+For this to work, of course, we need a ``Show`` implementation for
270270``Binary n``:
271271
272272.. code-block:: idris
273273
274− instance Show (Binary n) where
274+ Show (Binary n) where
275275 show (BO x) = show x ++ "0"
276276 show (BI x) = show x ++ "1"
277277 show BEnd = ""
docs/tutorial/syntax.rst+2−2
@@ -168,7 +168,7 @@ declaring:
168168 pure : Expr G a -> Expr G a
169169 pure = id
170170
171−Note that there is no need for these to be part of an instance of
171+Note that there is no need for these to be part of an implementation of
172172``Applicative``, since idiom bracket notation translates directly to
173173the names ``<*>`` and ``pure``, and ad-hoc type-directed overloading
174174is allowed. We can now say:
@@ -179,7 +179,7 @@ is allowed. We can now say:
179179 fact = expr (\x => If (Op (==) x (Val 0))
180180 (Val 1) (Op (*) [| fact (Op (-) x (Val 1)) |] x))
181181
182−With some more ad-hoc overloading and type class instances, and a new
182+With some more ad-hoc overloading and use of interfaces, and a new
183183syntax rule, we can even go as far as:
184184
185185.. code-block:: idris
docs/tutorial/typesfuns.rst+22−22
@@ -61,8 +61,8 @@ answer. For example:
6161 True : Bool
6262
6363All of the usual arithmetic and comparison operators are defined for
64−the primitive types. They are overloaded using type classes, as we
65−will discuss in Section :ref:`sect-classes` and can be extended to
64+the primitive types. They are overloaded using interfaces, as we
65+will discuss in Section :ref:`sect-interfaces` and can be extended to
6666work on user defined types. Boolean expressions can be tested with the
6767``if...then...else`` construct, for example:
6868
@@ -162,7 +162,7 @@ Idris prompt:
162162 4 : Nat
163163
164164Like arithmetic operations, integer literals are also overloaded using
165−type classes, meaning that we can also test the functions as follows:
165+interfaces, meaning that we can also test the functions as follows:
166166
167167::
168168
@@ -475,15 +475,16 @@ Sometimes it is useful to provide types of implicit arguments,
475475particularly where there is a dependency ordering, or where the
476476implicit arguments themselves have dependencies. For example, we may
477477wish to state the types of the implicit arguments in the following
478−definition, which defines a predicate on vectors:
478+definition, which defines a predicate on vectors (this is also defined
479+in ``Data.Vect``, under the name ``Elem``):
479480
480481.. code-block:: idris
481482
482− data Elem : a -> Vect n a -> Type where
483− Here : {x:a} -> {xs:Vect n a} -> Elem x (x :: xs)
484− There : {x,y:a} -> {xs:Vect n a} -> Elem x xs -> Elem x (y :: xs)
483+ data IsElem : a -> Vect n a -> Type where
484+ Here : {x:a} -> {xs:Vect n a} -> IsElem x (x :: xs)
485+ There : {x,y:a} -> {xs:Vect n a} -> IsElem x xs -> IsElem x (y :: xs)
485486
486−An instance of ``Elem x xs`` states that ``x`` is an element of
487+An instance of ``IsElem x xs`` states that ``x`` is an element of
487488``xs``. We can construct such a predicate if the required element is
488489``Here``, at the head of the vector, or ``There``, in the tail of the
489490vector. For example:
@@ -493,7 +494,7 @@ vector. For example:
493494 testVec : Vect 4 Int
494495 testVec = 3 :: 4 :: 5 :: 6 :: Nil
495496
496− inVect : Elem 5 testVec
497+ inVect : IsElem 5 testVec
497498 inVect = There (There Here)
498499
499500If the same implicit arguments are being used a lot, it can make a
@@ -504,9 +505,9 @@ appear within the block:
504505.. code-block:: idris
505506
506507 using (x:a, y:a, xs:Vect n a)
507− data Elem : a -> Vect n a -> Type where
508− Here : Elem x (x :: xs)
509− There : Elem x xs -> Elem x (y :: xs)
508+ data IsElem : a -> Vect n a -> Type where
509+ Here : IsElem x (x :: xs)
510+ There : IsElem x xs -> IsElem x (y :: xs)
510511
511512Note: Declaration Order and ``mutual`` blocks
512513~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -579,14 +580,14 @@ example for reading and writing files, including:
579580 data File -- abstract
580581 data Mode = Read | Write | ReadWrite
581582
582− openFile : String -> Mode -> IO File
583+ openFile : (f : String) -> (m : Mode) -> IO (Either FileError File)
583584 closeFile : File -> IO ()
585+
586+ fGetLine : (h : File) -> IO (Either FileError String)
587+ fPutStr : (h : File) -> (str : String) -> IO (Either FileError ())
588+ fEOF : File -> IO Bool
584589
585− fread : File -> IO String
586− fwrite : File -> String -> IO ()
587− feof : File -> IO Bool
588−
589− readFile : String -> IO String
590+Note that several of these return ``Either``, since they may fail.
590591
591592.. _sect-do:
592593
@@ -724,8 +725,7 @@ the vector:
724725 *usefultypes> show (map double intVec)
725726 "[2, 4, 6, 8, 10]" : String
726727
727−You’ll find these examples in ``usefultypes.idr`` in the ``examples/``
728−directory. For more details of the functions available on ``List`` and
728+For more details of the functions available on ``List`` and
729729``Vect``, look in the library files:
730730
731731- ``libs/prelude/Prelude/List.idr``
@@ -997,7 +997,7 @@ syntax:
997997 record { a->b->c = val } x
998998
999999This returns a new record, with the field accessed by the path
1000−``a->b->c`` set to ``x``. The syntax is first class, i.e. ``record {
1000+``a->b->c`` set to ``val``. The syntax is first class, i.e. ``record {
10011001a->b->c = val }`` itself has a function type. Symmetrically, the field
10021002can also be accessed with the following syntax:
10031003
@@ -1045,7 +1045,7 @@ using natural numbers, the new value can be incremented using the
10451045.. code-block:: idris
10461046
10471047 addStudent : Person -> SizedClass n -> SizedClass (S n)
1048− addStudent p c = record { students = p :: students c } c
1048+ addStudent p c = SizedClassInfo (p :: students c) (className c)
10491049
10501050.. _sect-more-expr:
10511051
icons/idris_icon.rcnew file+1
@@ -0,0 +1 @@
1+0 ICON "idris.ico"
idris-tutorial.pdf

Binary file not shown.

idris.cabal+15−8
@@ -1,5 +1,5 @@
11Name: idris
2−Version: 0.9.20.2
2+Version: 0.10
33License: BSD3
44License-file: LICENSE
55Author: Edwin Brady
@@ -18,12 +18,12 @@ Description: Idris is a general purpose language with full dependent types.
1818 <http://www.idris-lang.org/documentation>.
1919 Features include:
2020 .
21− * Full dependent types with dependent pattern matching
21+ * Full, first class, dependent types with dependent pattern matching
2222 .
23− * where clauses, with rule, simple case expressions,
23+ * where clauses, with rule, case expressions,
2424 pattern matching let and lambda bindings
2525 .
26− * Type classes, monad comprehensions
26+ * Interfaces (similar to type classes), monad comprehensions
2727 .
2828 * do notation, idiom brackets, syntactic conveniences for lists,
2929 tuples, dependent pairs
@@ -34,8 +34,6 @@ Description: Idris is a general purpose language with full dependent types.
3434 .
3535 * Indentation significant syntax, extensible syntax
3636 .
37− * Tactic based theorem proving (influenced by Coq)
38− .
3937 * Cumulative universes
4038 .
4139 * Simple foreign function interface (to C)
@@ -152,7 +150,7 @@ Extra-source-files:
152150 libs/pruviloj/Pruviloj/Internals/*.idr
153151
154152 test/Makefile
155− test/runtest.pl
153+ test/runtest.hs
156154 test/reg001/run
157155 test/reg001/*.idr
158156 test/reg001/expected
@@ -165,6 +163,9 @@ Extra-source-files:
165163 test/reg004/run
166164 test/reg004/*.idr
167165 test/reg004/expected
166+ test/reg005/run
167+ test/reg005/*.idr
168+ test/reg005/expected
168169 test/reg006/run
169170 test/reg006/*.idr
170171 test/reg006/expected
@@ -790,6 +791,9 @@ Extra-source-files:
790791 benchmarks/trivial/sortvec.idr
791792 benchmarks/trivial/sortvec.ipkg
792793
794+ icons/idris_icon.rc
795+ icons/idris.ico
796+
793797source-repository head
794798 type: git
795799 location: git://github.com/idris-lang/Idris-dev.git
@@ -962,7 +966,7 @@ Library
962966 , haskeline >= 0.7 && < 0.8
963967 , mtl >= 2.1 && < 2.3
964968 , network < 2.7
965− , optparse-applicative >= 0.11 && < 0.12
969+ , optparse-applicative >= 0.11 && < 0.13
966970 , parsers >= 0.9 && < 0.13
967971 , pretty < 1.2
968972 , process < 1.3
@@ -979,6 +983,9 @@ Library
979983 , vector-binary-instances < 0.3
980984 , zip-archive > 0.2.3.5 && < 0.2.4
981985 , safe
986+ , fsnotify < 2.2
987+ , async < 2.1
988+
982989 -- zlib >= 0.6.1 is broken with GHC < 7.10.3
983990 if impl(ghc < 7.10.3)
984991 build-depends: zlib < 0.6.1
libs/base/Control/Arrow.idr+1−1
@@ -3,7 +3,7 @@ module Control.Arrow
33import Data.Morphisms
44import Control.Category
55
6−%access public
6+%access public export
77
88infixr 5 <++>
99infixr 3 ***
libs/base/Control/Catchable.idr+2
@@ -2,6 +2,8 @@ module Control.Catchable
22
33import Control.IOExcept
44
5+%access public export
6+
57interface Catchable (m : Type -> Type) t where
68 throw : t -> m a
79 catch : m a -> (t -> m a) -> m a
libs/base/Control/Category.idr+1−1
@@ -2,7 +2,7 @@ module Control.Category
22
33import Data.Morphisms
44
5−%access public
5+%access public export
66
77interface Category (cat : Type -> Type -> Type) where
88 id : cat a a
libs/base/Control/IOExcept.idr+13−8
@@ -1,26 +1,31 @@
11module Control.IOExcept
22
3+%access public export
4+
35-- An IO monad with exception handling
46
5−record IOExcept err a where
7+record IOExcept' (f:FFI) err a where
68 constructor IOM
7− runIOExcept : IO (Either err a)
9+ runIOExcept : IO' f (Either err a)
810
9−implementation Functor (IOExcept e) where
11+Functor (IOExcept' f e) where
1012 map f (IOM fn) = IOM (map (map f) fn)
1113
12−implementation Applicative (IOExcept e) where
14+Applicative (IOExcept' f e) where
1315 pure x = IOM (pure (pure x))
1416 (IOM f) <*> (IOM a) = IOM [| f <*> a |]
1517
16−implementation Monad (IOExcept e) where
18+Monad (IOExcept' f e) where
1719 (IOM x) >>= f = IOM $ x >>= either (pure . Left) (runIOExcept . f)
1820
19−ioe_lift : IO a -> IOExcept err a
21+ioe_lift : IO' f a -> IOExcept' f err a
2022ioe_lift op = IOM $ map Right op
2123
22−ioe_fail : err -> IOExcept err a
24+ioe_fail : err -> IOExcept' f err a
2325ioe_fail e = IOM $ pure (Left e)
2426
25−ioe_run : IOExcept err a -> (err -> IO b) -> (a -> IO b) -> IO b
27+ioe_run : IOExcept' f err a -> (err -> IO' f b) -> (a -> IO' f b) -> IO' f b
2628ioe_run (IOM act) err ok = either err ok !act
29+
30+IOExcept : Type -> Type -> Type
31+IOExcept = IOExcept' FFI_C
libs/base/Control/Isomorphism.idr+1
@@ -4,6 +4,7 @@ import Syntax.PreorderReasoning
44import Data.Fin
55
66%default total
7+%access public export
78
89||| An isomorphism between two types
910data Iso : Type -> Type -> Type where
libs/base/Control/Monad/Identity.idr+3−1
@@ -1,6 +1,8 @@
11module Control.Monad.Identity
22
3−public record Identity (a : Type) where
3+%access public export
4+
5+public export record Identity (a : Type) where
46 constructor Id
57 runIdentity : a
68
libs/base/Control/Monad/RWS.idr+1−1
@@ -5,7 +5,7 @@ import Control.Monad.State
55import Control.Monad.Writer
66import Control.Monad.Reader
77
8−%access public
8+%access public export
99
1010||| A combination of the Reader, Writer, and State monads
1111interface (Monoid w, MonadReader r m, MonadWriter w m, MonadState s m) => MonadRWS r w s (m : Type -> Type) where {}
libs/base/Control/Monad/Reader.idr+1−1
@@ -4,7 +4,7 @@ import Builtins
44import Control.Monad.Identity
55import Control.Monad.Trans
66
7−%access public
7+%access public export
88
99||| A monad representing a computation that runs in an immutable context
1010interface Monad m => MonadReader r (m : Type -> Type) where
libs/base/Control/Monad/State.idr+1−1
@@ -3,7 +3,7 @@ module Control.Monad.State
33import public Control.Monad.Identity
44import public Control.Monad.Trans
55
6−%access public
6+%access public export
77
88||| A computation which runs in a context and produces an output
99interface Monad m => MonadState s (m : Type -> Type) | m where
libs/base/Control/Monad/Trans.idr+2
@@ -1,4 +1,6 @@
11module Control.Monad.Trans
22
3+%access public export
4+
35interface MonadTrans (t : (Type -> Type) -> Type -> Type) where
46 lift : Monad m => m a -> t m a
libs/base/Control/Monad/Writer.idr+1−1
@@ -4,7 +4,7 @@ import Builtins
44import Control.Monad.Identity
55import Control.Monad.Trans
66
7−%access public
7+%access public export
88
99||| A monad representing a computation that produces a stream of output
1010interface (Monoid w, Monad m) => MonadWriter w (m : Type -> Type) where
libs/base/Data/Bits.idr+51−29
@@ -4,6 +4,7 @@ import Data.Fin
44
55%default total
66
7+public export
78nextPow2 : Nat -> Nat
89nextPow2 Z = Z
910nextPow2 (S x) = if (S x) == (2 `power` l2x)
@@ -12,9 +13,11 @@ nextPow2 (S x) = if (S x) == (2 `power` l2x)
1213 where
1314 l2x = log2NZ (S x) SIsNotZ
1415
16+public export
1517nextBytes : Nat -> Nat
1618nextBytes bits = (nextPow2 (divCeilNZ bits 8 SIsNotZ))
1719
20+public export
1821machineTy : Nat -> Type
1922machineTy Z = Bits8
2023machineTy (S Z) = Bits16
@@ -44,7 +47,7 @@ natToBits {n=n} x with (n)
4447getPad : Nat -> machineTy n
4548getPad n = natToBits (minus (bitsUsed (nextBytes n)) n)
4649
47−public
50+public export
4851data Bits : Nat -> Type where
4952 MkBits : machineTy (nextBytes n) -> Bits n
5053
@@ -89,6 +92,10 @@ pad64' n f x y = prim__lshrB64 (f (prim__shlB64 x pad) y) pad
8992 where
9093 pad = getPad {n=3} n
9194
95+-- TODO: This (and all the other functions along these lings) is public export
96+-- because it is used by public export things. Do they really need to be
97+-- public export, or is export good enough?
98+public export
9299shiftLeft' : machineTy (nextBytes n) -> machineTy (nextBytes n) -> machineTy (nextBytes n)
93100shiftLeft' {n=n} x c with (nextBytes n)
94101 | Z = pad8' n prim__shlB8 x c
@@ -96,10 +103,11 @@ shiftLeft' {n=n} x c with (nextBytes n)
96103 | S (S Z) = pad32' n prim__shlB32 x c
97104 | S (S (S _)) = pad64' n prim__shlB64 x c
98105
99−public
106+public export
100107shiftLeft : Bits n -> Bits n -> Bits n
101108shiftLeft (MkBits x) (MkBits y) = MkBits (shiftLeft' x y)
102109
110+public export
103111shiftRightLogical' : machineTy n -> machineTy n -> machineTy n
104112shiftRightLogical' {n=n} x c with (n)
105113 | Z = prim__lshrB8 x c
@@ -107,11 +115,12 @@ shiftRightLogical' {n=n} x c with (n)
107115 | S (S Z) = prim__lshrB32 x c
108116 | S (S (S _)) = prim__lshrB64 x c
109117
110−public
118+public export
111119shiftRightLogical : Bits n -> Bits n -> Bits n
112120shiftRightLogical {n} (MkBits x) (MkBits y)
113121 = MkBits {n} (shiftRightLogical' {n=nextBytes n} x y)
114122
123+public export
115124shiftRightArithmetic' : machineTy (nextBytes n) -> machineTy (nextBytes n) -> machineTy (nextBytes n)
116125shiftRightArithmetic' {n=n} x c with (nextBytes n)
117126 | Z = pad8' n prim__ashrB8 x c
@@ -119,10 +128,11 @@ shiftRightArithmetic' {n=n} x c with (nextBytes n)
119128 | S (S Z) = pad32' n prim__ashrB32 x c
120129 | S (S (S _)) = pad64' n prim__ashrB64 x c
121130
122−public
131+public export
123132shiftRightArithmetic : Bits n -> Bits n -> Bits n
124133shiftRightArithmetic (MkBits x) (MkBits y) = MkBits (shiftRightArithmetic' x y)
125134
135+public export
126136and' : machineTy n -> machineTy n -> machineTy n
127137and' {n=n} x y with (n)
128138 | Z = prim__andB8 x y
@@ -130,10 +140,11 @@ and' {n=n} x y with (n)
130140 | S (S Z) = prim__andB32 x y
131141 | S (S (S _)) = prim__andB64 x y
132142
133−public
143+public export
134144and : Bits n -> Bits n -> Bits n
135145and {n} (MkBits x) (MkBits y) = MkBits (and' {n=nextBytes n} x y)
136146
147+public export
137148or' : machineTy n -> machineTy n -> machineTy n
138149or' {n=n} x y with (n)
139150 | Z = prim__orB8 x y
@@ -141,10 +152,11 @@ or' {n=n} x y with (n)
141152 | S (S Z) = prim__orB32 x y
142153 | S (S (S _)) = prim__orB64 x y
143154
144−public
155+public export
145156or : Bits n -> Bits n -> Bits n
146157or {n} (MkBits x) (MkBits y) = MkBits (or' {n=nextBytes n} x y)
147158
159+public export
148160xor' : machineTy n -> machineTy n -> machineTy n
149161xor' {n=n} x y with (n)
150162 | Z = prim__xorB8 x y
@@ -152,10 +164,11 @@ xor' {n=n} x y with (n)
152164 | S (S Z) = prim__xorB32 x y
153165 | S (S (S _)) = prim__xorB64 x y
154166
155−public
167+public export
156168xor : Bits n -> Bits n -> Bits n
157169xor {n} (MkBits x) (MkBits y) = MkBits {n} (xor' {n=nextBytes n} x y)
158170
171+public export
159172plus' : machineTy (nextBytes n) -> machineTy (nextBytes n) -> machineTy (nextBytes n)
160173plus' {n=n} x y with (nextBytes n)
161174 | Z = pad8 n prim__addB8 x y
@@ -163,10 +176,11 @@ plus' {n=n} x y with (nextBytes n)
163176 | S (S Z) = pad32 n prim__addB32 x y
164177 | S (S (S _)) = pad64 n prim__addB64 x y
165178
166−public
179+public export
167180plus : Bits n -> Bits n -> Bits n
168181plus (MkBits x) (MkBits y) = MkBits (plus' x y)
169182
183+public export
170184minus' : machineTy (nextBytes n) -> machineTy (nextBytes n) -> machineTy (nextBytes n)
171185minus' {n=n} x y with (nextBytes n)
172186 | Z = pad8 n prim__subB8 x y
@@ -174,10 +188,11 @@ minus' {n=n} x y with (nextBytes n)
174188 | S (S Z) = pad32 n prim__subB32 x y
175189 | S (S (S _)) = pad64 n prim__subB64 x y
176190
177−public
191+public export
178192minus : Bits n -> Bits n -> Bits n
179193minus (MkBits x) (MkBits y) = MkBits (minus' x y)
180194
195+public export
181196times' : machineTy (nextBytes n) -> machineTy (nextBytes n) -> machineTy (nextBytes n)
182197times' {n=n} x y with (nextBytes n)
183198 | Z = pad8 n prim__mulB8 x y
@@ -185,11 +200,12 @@ times' {n=n} x y with (nextBytes n)
185200 | S (S Z) = pad32 n prim__mulB32 x y
186201 | S (S (S _)) = pad64 n prim__mulB64 x y
187202
188−public
203+public export
189204times : Bits n -> Bits n -> Bits n
190205times (MkBits x) (MkBits y) = MkBits (times' x y)
191206
192207partial
208+public export
193209sdiv' : machineTy (nextBytes n) -> machineTy (nextBytes n) -> machineTy (nextBytes n)
194210sdiv' {n=n} x y with (nextBytes n)
195211 | Z = prim__sdivB8 x y
@@ -197,11 +213,12 @@ sdiv' {n=n} x y with (nextBytes n)
197213 | S (S Z) = prim__sdivB32 x y
198214 | S (S (S _)) = prim__sdivB64 x y
199215
200−public partial
216+public export partial
201217sdiv : Bits n -> Bits n -> Bits n
202218sdiv (MkBits x) (MkBits y) = MkBits (sdiv' x y)
203219
204220partial
221+public export
205222udiv' : machineTy (nextBytes n) -> machineTy (nextBytes n) -> machineTy (nextBytes n)
206223udiv' {n=n} x y with (nextBytes n)
207224 | Z = prim__udivB8 x y
@@ -209,11 +226,11 @@ udiv' {n=n} x y with (nextBytes n)
209226 | S (S Z) = prim__udivB32 x y
210227 | S (S (S _)) = prim__udivB64 x y
211228
212−public partial
229+public export partial
213230udiv : Bits n -> Bits n -> Bits n
214231udiv (MkBits x) (MkBits y) = MkBits (udiv' x y)
215232
216−partial
233+public export partial
217234srem' : machineTy (nextBytes n) -> machineTy (nextBytes n) -> machineTy (nextBytes n)
218235srem' {n=n} x y with (nextBytes n)
219236 | Z = prim__sremB8 x y
@@ -221,11 +238,11 @@ srem' {n=n} x y with (nextBytes n)
221238 | S (S Z) = prim__sremB32 x y
222239 | S (S (S _)) = prim__sremB64 x y
223240
224−public partial
241+public export partial
225242srem : Bits n -> Bits n -> Bits n
226243srem (MkBits x) (MkBits y) = MkBits (srem' x y)
227244
228−partial
245+public export partial
229246urem' : machineTy (nextBytes n) -> machineTy (nextBytes n) -> machineTy (nextBytes n)
230247urem' {n=n} x y with (nextBytes n)
231248 | Z = prim__uremB8 x y
@@ -233,7 +250,7 @@ urem' {n=n} x y with (nextBytes n)
233250 | S (S Z) = prim__uremB32 x y
234251 | S (S (S _)) = prim__uremB64 x y
235252
236−public partial
253+public export partial
237254urem : Bits n -> Bits n -> Bits n
238255urem (MkBits x) (MkBits y) = MkBits (urem' x y)
239256
@@ -273,9 +290,11 @@ gt {n=n} x y with (nextBytes n)
273290 | S (S Z) = prim__gtB32 x y
274291 | S (S (S _)) = prim__gtB64 x y
275292
293+public export
276294implementation Eq (Bits n) where
277295 (MkBits x) == (MkBits y) = boolOp eq x y
278296
297+public export
279298implementation Ord (Bits n) where
280299 (MkBits x) < (MkBits y) = boolOp lt x y
281300 (MkBits x) <= (MkBits y) = boolOp lte x y
@@ -288,6 +307,7 @@ implementation Ord (Bits n) where
288307 then EQ
289308 else GT
290309
310+public export
291311complement' : machineTy (nextBytes n) -> machineTy (nextBytes n)
292312complement' {n=n} x with (nextBytes n)
293313 | Z = let pad = getPad {n=0} n in
@@ -299,12 +319,12 @@ complement' {n=n} x with (nextBytes n)
299319 | S (S (S _)) = let pad = getPad {n=3} n in
300320 prim__complB64 (x `prim__shlB64` pad) `prim__lshrB64` pad
301321
302−public
322+public export
303323complement : Bits n -> Bits n
304324complement (MkBits x) = MkBits (complement' x)
305325
306326-- TODO: Prove
307−%assert_total -- can't verify coverage of with block
327+public export %assert_total -- can't verify coverage of with block
308328zext' : machineTy (nextBytes n) -> machineTy (nextBytes (n+m))
309329zext' {n=n} {m=m} x with (nextBytes n, nextBytes (n+m))
310330 | (Z, Z) = believe_me x
@@ -318,11 +338,11 @@ zext' {n=n} {m=m} x with (nextBytes n, nextBytes (n+m))
318338 | (S (S Z), S (S (S _))) = believe_me (prim__zextB32_B64 (believe_me x))
319339 | (S (S (S _)), S (S (S _))) = believe_me x
320340
321−public
341+public export
322342zeroExtend : Bits n -> Bits (n+m)
323343zeroExtend (MkBits x) = MkBits (zext' x)
324344
325−%assert_total
345+public export %assert_total
326346intToBits' : Integer -> machineTy (nextBytes n)
327347intToBits' {n=n} x with (nextBytes n)
328348 | Z = let pad = getPad {n=0} n in
@@ -334,13 +354,14 @@ intToBits' {n=n} x with (nextBytes n)
334354 | S (S (S _)) = let pad = getPad {n=3} n in
335355 prim__lshrB64 (prim__shlB64 (prim__truncBigInt_B64 x) pad) pad
336356
337−public
357+public export
338358intToBits : Integer -> Bits n
339359intToBits n = MkBits (intToBits' n)
340360
341361implementation Cast Integer (Bits n) where
342362 cast = intToBits
343363
364+public export
344365bitsToInt' : machineTy (nextBytes n) -> Integer
345366bitsToInt' {n=n} x with (nextBytes n)
346367 | Z = prim__zextB8_BigInt x
@@ -348,11 +369,12 @@ bitsToInt' {n=n} x with (nextBytes n)
348369 | S (S Z) = prim__zextB32_BigInt x
349370 | S (S (S _)) = prim__zextB64_BigInt x
350371
351−public
372+public export
352373bitsToInt : Bits n -> Integer
353374bitsToInt (MkBits x) = bitsToInt' x
354375
355376-- Zero out the high bits of a truncated bitstring
377+public export
356378zeroUnused : machineTy (nextBytes n) -> machineTy (nextBytes n)
357379zeroUnused {n} x = x `and'` complement' (intToBits' {n=n} 0)
358380
@@ -390,12 +412,12 @@ sext' {n=n} {m=m} x with (nextBytes n, nextBytes (n+m))
390412 | (S (S (S _)), S (S (S _))) = let pad = getPad {n=3} n in
391413 believe_me (prim__ashrB64 (prim__shlB64 (believe_me x) pad) pad)
392414
393−--public
415+--public export
394416--signExtend : Bits n -> Bits (n+m)
395417--signExtend {m=m} (MkBits x) = MkBits (zeroUnused (sext' x))
396418
397419-- TODO: Prove
398−%assert_total -- can't verify coverage of with block
420+public export %assert_total -- can't verify coverage of with block
399421trunc' : machineTy (nextBytes (m+n)) -> machineTy (nextBytes n)
400422trunc' {m=m} {n=n} x with (nextBytes n, nextBytes (m+n))
401423 | (Z, Z) = believe_me x
@@ -409,23 +431,23 @@ trunc' {m=m} {n=n} x with (nextBytes n, nextBytes (m+n))
409431 | (S (S Z), S (S (S _))) = believe_me (prim__truncB64_B32 (believe_me x))
410432 | (S (S (S _)), S (S (S _))) = believe_me x
411433
412−public
434+public export
413435truncate : Bits (m+n) -> Bits n
414436truncate (MkBits x) = MkBits (zeroUnused (trunc' x))
415437
416−public
438+public export
417439bitAt : Fin n -> Bits n
418440bitAt n = intToBits 1 `shiftLeft` intToBits (cast n)
419441
420−public
442+public export
421443getBit : Fin n -> Bits n -> Bool
422444getBit n x = (x `and` (bitAt n)) /= intToBits 0
423445
424−public
446+public export
425447setBit : Fin n -> Bits n -> Bits n
426448setBit n x = x `or` (bitAt n)
427449
428−public
450+public export
429451unsetBit : Fin n -> Bits n -> Bits n
430452unsetBit n x = x `and` complement (bitAt n)
431453
libs/base/Data/Complex.idr+2
@@ -5,6 +5,8 @@
55
66module Data.Complex
77
8+%access public export
9+
810------------------------------ Rectangular form
911
1012infix 6 :+
libs/base/Data/Erased.idr+1−1
@@ -1,6 +1,6 @@
11module Data.Erased
22
3−%access public
3+%access public export
44%default total
55
66||| The erasure monad.
libs/base/Data/Fin.idr+2−2
@@ -1,7 +1,7 @@
11module Data.Fin
22
33%default total
4−%access public
4+%access public export
55
66||| Numbers strictly less than some bound. The name comes from "finite sets".
77|||
@@ -149,7 +149,7 @@ mkFinIntegerErr lit finSize subErr
149149 , TermPart `(Fin ~(getNat finSize))
150150 , SubReport subErr
151151 ]
152−total
152+total export
153153finFromIntegerErrors : Err -> Maybe (List ErrorReportPart)
154154finFromIntegerErrors (CantUnify x tm `(IsJust (integerToFin ~(TConst c) ~m)) err xs y)
155155 = mkFinIntegerErr (TConst c) m
libs/base/Data/HVect.idr+1−1
@@ -2,7 +2,7 @@ module Data.HVect
22
33import public Data.Vect
44
5−%access public
5+%access public export
66%default total
77
88||| Heterogeneous vectors where the type index gives, element-wise,
libs/base/Data/List.idr+1−1
@@ -1,6 +1,6 @@
11module Data.List
22
3−%access public
3+%access public export
44
55||| A proof that some element is found in a list.
66|||
libs/base/Data/List/Quantifiers.idr+2
@@ -2,6 +2,8 @@ module Data.List.Quantifiers
22
33import Data.List
44
5+%access public export
6+
57||| A proof that some element of a list satisfies some property
68|||
79||| @ P the property to be satsified
libs/base/Data/Mod2.idr+5−4
@@ -5,26 +5,27 @@ import Data.Bits
55%default total
66
77||| Integers modulo 2^n
8−public
8+public export
99data Mod2 : Nat -> Type where
1010 MkMod2 : {n : Nat} -> Bits n -> Mod2 n
1111
12+public export
1213modBin : (Bits n -> Bits n -> Bits n) -> Mod2 n -> Mod2 n -> Mod2 n
1314modBin f (MkMod2 x) (MkMod2 y) = MkMod2 (f x y)
1415
1516modComp : (Bits n -> Bits n -> a) -> Mod2 n -> Mod2 n -> a
1617modComp f (MkMod2 x) (MkMod2 y) = f x y
1718
18−public partial
19+public export partial
1920div : Mod2 n -> Mod2 n -> Mod2 n
2021div = modBin udiv
2122
22−public partial
23+public export partial
2324rem : Mod2 n -> Mod2 n -> Mod2 n
2425rem = modBin urem
2526
2627%assert_total
27−public
28+public export
2829intToMod : {n : Nat} -> Integer -> Mod2 n
2930intToMod {n=n} x = MkMod2 (intToBits x)
3031
libs/base/Data/Morphisms.idr+1−1
@@ -1,6 +1,6 @@
11module Data.Morphisms
22
3−%access public
3+%access public export
44
55data Morphism : Type -> Type -> Type where
66 Mor : (a -> b) -> Morphism a b
libs/base/Data/So.idr+1
@@ -1,6 +1,7 @@
11module Data.So
22
33%default total
4+%access public export
45
56||| Ensure that some run-time Boolean test has been performed.
67|||
libs/base/Data/String.idr+1−1
@@ -1,5 +1,5 @@
11module Data.String
2−%access public
2+%access public export
33
44private
55parseNumWithoutSign : List Char -> Integer -> Maybe Integer
libs/base/Data/Vect.idr+1−1
@@ -3,7 +3,7 @@ module Data.Vect
33import public Data.Fin
44import Language.Reflection
55
6−%access public
6+%access public export
77%default total
88
99infixr 7 ::
libs/base/Data/Vect/Quantifiers.idr+2
@@ -2,6 +2,8 @@ module Data.Vect.Quantifiers
22
33import Data.Vect
44
5+%access public export
6+
57||| A proof that some element of a vector satisfies some property
68|||
79||| @ P the property to be satsified
libs/base/Debug/Error.idr+1−1
@@ -7,7 +7,7 @@ import System
77|||
88||| @ loc The source location to display for the error
99||| @ message The error to print
10−partial
10+partial export
1111error : {default (%runElab sourceLocation) loc : SourceLocation} ->
1212 (message : String) ->
1313 a
libs/base/Debug/Trace.idr+1
@@ -3,6 +3,7 @@ module Debug.Trace
33||| Print a message for debugging purposes as a side effect
44||| @ msg what to print
55||| @ result the final result
6+export
67trace : (msg : String) -> (result : a) -> a
78trace x val = unsafePerformIO {ffi=FFI_C} (do putStrLn x; return val)
89
libs/base/Language/Reflection/Utils.idr+2
@@ -4,6 +4,8 @@ import Language.Reflection
44import Language.Reflection.Elab
55import Language.Reflection.Errors
66
7+%access public export
8+
79--------------------------------------------------------
810-- Tactic construction conveniences
911--------------------------------------------------------
libs/base/Syntax/PreorderReasoning.idr+2
@@ -1,5 +1,7 @@
11module Syntax.PreorderReasoning
22
3+%access public export
4+
35-- QED is first to get the precedence to work out. It's just Refl with an explicit argument.
46syntax [expr] "QED" = qed expr
57-- foo ={ prf }= bar ={ prf' }= fnord QED
libs/base/System.idr+1−1
@@ -2,7 +2,7 @@ module System
22
33%include C "unistd.h"
44%default partial
5−%access public
5+%access public export
66
77||| Retrieves a value from the environment if the given key is present,
88||| otherwise it returns Nothing.
libs/base/System/Concurrency/Raw.idr+2
@@ -6,6 +6,8 @@ module System.Concurrency.Raw
66
77import System
88
9+%access export
10+
911||| Send a message of any type to the thread with the given thread id
1012||| Returns 1 if the message was sent successfully, 0 otherwise
1113sendToThread : (thread_id : Ptr) -> a -> IO Int
libs/base/System/Info.idr+3
@@ -1,13 +1,16 @@
11module System.Info
22
33||| The Idris backend in use
4+export
45backend : String
56backend = prim__systemInfo 0
67
78||| The operating system in use.
9+export
810os : String
911os = prim__systemInfo 1
1012
1113||| The triple this program was targeted for
14+export
1215targetTriple : String
1316targetTriple = prim__systemInfo 2
libs/contrib/Classes/Verified.idr+9
@@ -4,6 +4,8 @@ import Control.Algebra
44import Control.Algebra.Lattice
55import Control.Algebra.VectorSpace
66
7+%access public export
8+
79-- Due to these being basically unused and difficult to implement,
810-- they're in contrib for a bit. Once a design is found that lets them
911-- be implemented for a number of implementations, and we get those
@@ -92,6 +94,11 @@ interface MeetSemilattice a => VerifiedMeetSemilattice a where
9294 total meetSemilatticeMeetIsCommutative : (l, r : a) -> meet l r = meet r l
9395 total meetSemilatticeMeetIsIdempotent : (e : a) -> meet e e = e
9496
97+{- FIXME: Some maintenance required here.
98+ Algebra.top and Algebra.bottom don't exist!
99+-}
100+{-
101+
95102interface (VerifiedJoinSemilattice a, BoundedJoinSemilattice a) => VerifiedBoundedJoinSemilattice a where
96103 total boundedJoinSemilatticeBottomIsBottom : (e : a) -> join e Algebra.bottom = e
97104
@@ -112,3 +119,5 @@ interface (VerifiedBoundedJoinSemilattice a, VerifiedBoundedMeetSemilattice a, V
112119-- total moduleScalarMultDistributiveWRTModuleAddition : (s, t : a) -> (v : b) -> (s <+> t) <#> v = (s <#> v) <+> (t <#> v)
113120
114121--interface (VerifiedField a, VerifiedModule a b) => VerifiedVectorSpace a b where {}
122+
123+-}
libs/contrib/Control/Algebra.idr+1
@@ -3,6 +3,7 @@ module Control.Algebra
33infixl 6 <->
44infixl 7 <.>
55
6+%access public export
67
78||| Sets equipped with a single binary operation that is associative, along with
89||| a neutral element for that binary operation and inverses for all elements.
libs/contrib/Control/Algebra/Lattice.idr+1
@@ -3,6 +3,7 @@ module Control.Algebra.Lattice
33import Control.Algebra
44import Data.Heap
55
6+%access public export
67
78||| Sets equipped with a binary operation that is commutative, associative and
89||| idempotent. Must satisfy the following laws:
libs/contrib/Control/Algebra/NumericInstances.idr+1
@@ -7,6 +7,7 @@ import Control.Algebra.VectorSpace
77import Data.Complex
88import Data.ZZ
99
10+%access public export
1011
1112Semigroup Integer where
1213 (<+>) = (+)
libs/contrib/Control/Algebra/VectorSpace.idr+2
@@ -2,6 +2,8 @@ module Control.Algebra.VectorSpace
22
33import Control.Algebra
44
5+%access public export
6+
57infixl 5 <#>
68infixr 2 <||>
79
libs/contrib/Control/Isomorphism/Primitives.idr+1−1
@@ -4,7 +4,7 @@ import Control.Isomorphism
44import Data.ZZ
55
66%default total
7−%access public
7+%access public export
88
99-- This module contains isomorphisms between convenient inductive types and
1010-- Idris primitives. Because primitives lack a convenient structure, these
libs/contrib/Control/Partial.idr+1−1
@@ -7,7 +7,7 @@ module Control.Partial
77||| @ p the predicate to wait for
88||| @ f the function to repeatedly apply
99||| @ v the starting value
10−partial
10+partial export
1111until : (p : a -> Bool) -> (f : a -> a) -> (v : a) -> a
1212until p f v with (p v)
1313 | False = until p f (f v)
libs/contrib/Control/WellFounded.idr+1−1
@@ -6,7 +6,7 @@
66module Control.WellFounded
77
88%default total
9−
9+%access public export
1010
1111||| Accessibility: some element `x` is accessible if all `y` such that
1212||| `rel y x` are themselves accessible.
libs/contrib/Data/BoundedList.idr+1−1
@@ -2,7 +2,7 @@ module Data.BoundedList
22
33import Data.Fin
44
5−%access public
5+%access public export
66%default total
77
88||| A list with an upper bound on its length.
libs/contrib/Data/CoList.idr+1−1
@@ -1,6 +1,6 @@
11module Data.CoList
22
3−%access public
3+%access public export
44%default total
55
66||| Idris will know that it always can produce a new element in finite time
libs/contrib/Data/Fun.idr+1
@@ -3,6 +3,7 @@ module Data.Fun
33import public Data.Vect
44
55%default total
6+%access public export
67
78||| Build an n-ary function type from a Vect of Types and a result type
89Fun : Vect n Type -> Type -> Type
libs/contrib/Data/Hash.idr+1−1
@@ -2,7 +2,7 @@ module Data.Hash
22
33import Data.Vect
44
5−%access public
5+%access public export
66%default total
77
88{- A general purpose Hashing library (not cryptographic)
libs/contrib/Data/Heap.idr+2−2
@@ -7,9 +7,9 @@ module Data.Heap
77
88
99%default total
10−%access public
10+%access export
1111
12−abstract data MaxiphobicHeap : Type -> Type where
12+export data MaxiphobicHeap : Type -> Type where
1313 Empty : MaxiphobicHeap a
1414 Node : Nat -> MaxiphobicHeap a -> a -> MaxiphobicHeap a -> MaxiphobicHeap a
1515
libs/contrib/Data/Matrix.idr+1
@@ -5,6 +5,7 @@ module Data.Matrix
55import public Data.Vect
66
77%default total
8+%access public export
89
910||| Matrix with n rows and m columns
1011Matrix : Nat -> Nat -> Type -> Type
libs/contrib/Data/Matrix/Algebraic.idr+1−1
@@ -9,7 +9,7 @@ import public Control.Algebra.NumericInstances
99
1010import public Data.Matrix
1111
12−
12+%access public export
1313%default total
1414
1515infixr 2 <:> -- vector inner product
libs/contrib/Data/Matrix/Numeric.idr+1
@@ -5,6 +5,7 @@ module Data.Matrix.Numeric
55import public Data.Matrix
66
77%default total
8+%access public export
89
910infixr 2 <:> -- vector inner product
1011infixr 2 >< -- vector outer product
libs/contrib/Data/Nat/DivMod.idr+1
@@ -2,6 +2,7 @@
22module Data.Nat.DivMod
33
44%default total
5+%access public export
56
67||| The result of euclidean division of natural numbers
78|||
libs/contrib/Data/Nat/DivMod/IteratedSubtraction.idr+1−1
@@ -8,7 +8,7 @@ import Data.So
88import Control.WellFounded
99
1010%default total
11−%access public
11+%access public export
1212
1313||| A strict less-than relation on `Nat`.
1414|||
libs/contrib/Data/Rel.idr+1
@@ -2,6 +2,7 @@ module Data.Rel
22
33import Data.Fun
44
5+%access public export
56
67||| Build an n-ary relation type from a Vect of Types
78Rel : Vect n Type -> Type
libs/contrib/Data/Sign.idr+2
@@ -1,5 +1,7 @@
11module Data.Sign
22
3+%access public export
4+
35||| A representation of signs for signed datatypes such as `ZZ`
46data Sign = Plus | Zero | Minus
57
libs/contrib/Data/SortedMap.idr+7−8
@@ -192,21 +192,21 @@ treeToList = treeToList' (:: [])
192192 treeToList' cont (Branch2 t1 _ t2) = treeToList' (:: treeToList' cont t2) t1
193193 treeToList' cont (Branch3 t1 _ t2 _ t3) = treeToList' (:: treeToList' (:: treeToList' cont t3) t2) t1
194194
195−abstract
195+export
196196data SortedMap : Type -> Type -> Type where
197197 Empty : Ord k => SortedMap k v
198198 M : (o : Ord k) => (n:Nat) -> Tree n k v o -> SortedMap k v
199199
200−public
200+export
201201empty : Ord k => SortedMap k v
202202empty = Empty
203203
204−public
204+export
205205lookup : k -> SortedMap k v -> Maybe v
206206lookup _ Empty = Nothing
207207lookup k (M _ t) = treeLookup k t
208208
209−public
209+export
210210insert : k -> v -> SortedMap k v -> SortedMap k v
211211insert k v Empty = M Z (Leaf k v)
212212insert k v (M _ t) =
@@ -214,7 +214,7 @@ insert k v (M _ t) =
214214 Left t' => (M _ t')
215215 Right t' => (M _ t')
216216
217−public
217+export
218218delete : k -> SortedMap k v -> SortedMap k v
219219delete _ Empty = Empty
220220delete k (M Z t) =
@@ -226,16 +226,15 @@ delete k (M (S _) t) =
226226 Left t' => (M _ t')
227227 Right t' => (M _ t')
228228
229−public
229+export
230230fromList : Ord k => List (k, v) -> SortedMap k v
231231fromList l = foldl (flip (uncurry insert)) empty l
232232
233−public
233+export
234234toList : SortedMap k v -> List (k, v)
235235toList Empty = []
236236toList (M _ t) = treeToList t
237237
238−public
239238treeMap : (a -> b) -> Tree n k a o -> Tree n k b o
240239treeMap f (Leaf k v) = Leaf k (f v)
241240treeMap f (Branch2 t1 k t2) = Branch2 (treeMap f t1) k (treeMap f t2)
libs/contrib/Data/SortedSet.idr+7−7
@@ -4,30 +4,30 @@ import Data.SortedMap
44
55-- TODO: add intersection, union, difference
66
7−abstract
7+export
88data SortedSet k = SetWrapper (Data.SortedMap.SortedMap k ())
99
10−public
10+export
1111empty : Ord k => SortedSet k
1212empty = SetWrapper Data.SortedMap.empty
1313
14−public
14+export
1515insert : k -> SortedSet k -> SortedSet k
1616insert k (SetWrapper m) = SetWrapper (Data.SortedMap.insert k () m)
1717
18−public
18+export
1919delete : k -> SortedSet k -> SortedSet k
2020delete k (SetWrapper m) = SetWrapper (Data.SortedMap.delete k m)
2121
22−public
22+export
2323contains : k -> SortedSet k -> Bool
2424contains k (SetWrapper m) = isJust (Data.SortedMap.lookup k m)
2525
26−public
26+export
2727fromList : Ord k => List k -> SortedSet k
2828fromList l = SetWrapper (Data.SortedMap.fromList (map (\i => (i, ())) l))
2929
30−public
30+export
3131toList : SortedSet k -> List k
3232toList (SetWrapper m) = map (\(i, _) => i) (Data.SortedMap.toList m)
3333
libs/contrib/Data/ZZ.idr+1−1
@@ -4,7 +4,7 @@ import Decidable.Equality
44import Data.Sign
55
66%default total
7−%access public
7+%access public export
88
99
1010||| An integer is either a positive `Nat` or the negated successor of a `Nat`.
libs/contrib/Decidable/Decidable.idr+1−1
@@ -3,7 +3,7 @@ module Decidable.Decidable
33import Data.Rel
44import Data.Fun
55
6−%access public
6+%access public export
77
88--------------------------------------------------------------------------------
99-- Interface for decidable n-ary Relations
libs/contrib/Decidable/Order.idr+1−1
@@ -6,7 +6,7 @@ import Data.Fin
66import Data.Fun
77import Data.Rel
88
9−%access public
9+%access public export
1010
1111--------------------------------------------------------------------------------
1212-- Utility Lemmas
libs/contrib/Network/Cgi.idr+11−11
@@ -4,7 +4,7 @@ import System
44
55%default total
66
7−public
7+public export
88Vars : Type
99Vars = List (String, String)
1010
@@ -23,7 +23,7 @@ add_Headers str st = record { Headers = Headers st ++ str } st
2323add_Output : String -> CGIInfo -> CGIInfo
2424add_Output str st = record { Output = Output st ++ str } st
2525
26−abstract
26+export
2727data CGI : Type -> Type where
2828 MkCGI : (CGIInfo -> IO (a, CGIInfo)) -> CGI a
2929
@@ -51,32 +51,32 @@ setInfo i = MkCGI (\s => return ((), i))
5151getInfo : CGI CGIInfo
5252getInfo = MkCGI (\s => return (s, s))
5353
54−abstract
54+export
5555lift : IO a -> CGI a
5656lift op = MkCGI (\st => do { x <- op
5757 return (x, st) } )
5858
59−abstract
59+export
6060output : String -> CGI ()
6161output s = do i <- getInfo
6262 setInfo (add_Output s i)
6363
64−abstract
64+export
6565queryVars : CGI Vars
6666queryVars = do i <- getInfo
6767 return (GET i)
6868
69−abstract
69+export
7070postVars : CGI Vars
7171postVars = do i <- getInfo
7272 return (POST i)
7373
74−abstract
74+export
7575cookieVars : CGI Vars
7676cookieVars = do i <- getInfo
7777 return (Cookies i)
7878
79−abstract
79+export
8080queryVar : String -> CGI (Maybe String)
8181queryVar x = do vs <- queryVars
8282 return (lookup x vs)
@@ -89,12 +89,12 @@ getHeaders : CGI String
8989getHeaders = do i <- getInfo
9090 return (Headers i)
9191
92−abstract
92+export
9393flushHeaders : CGI ()
9494flushHeaders = do o <- getHeaders
9595 lift (putStrLn o)
9696
97−abstract
97+export
9898flush : CGI ()
9999flush = do o <- getOutput
100100 lift (putStr o)
@@ -119,7 +119,7 @@ getCgiEnv key = do
119119 val <- getEnv key
120120 return $ maybe "" id val
121121
122−abstract
122+export
123123runCGI : CGI a -> IO a
124124runCGI prog = do
125125 clen_in <- getCgiEnv "CONTENT_LENGTH"
libs/contrib/Network/Socket.idr+7−8
@@ -8,9 +8,7 @@ module IdrisNet.Socket
88%include C "sys/socket.h"
99%include C "netdb.h"
1010
11−%access public
12−
13−ByteLength : Type
11+public export ByteLength : Type
1412ByteLength = Int
1513
1614interface ToCode a where
@@ -67,8 +65,9 @@ implementation ToCode SocketType where
6765
6866data RecvStructPtr = RSPtr Ptr
6967data RecvfromStructPtr = RFPtr Ptr
70−data BufPtr = BPtr Ptr
71−data SockaddrPtr = SAPtr Ptr
68+
69+export data BufPtr = BPtr Ptr
70+export data SockaddrPtr = SAPtr Ptr
7271
7372||| Protocol Number.
7473|||
@@ -120,18 +119,18 @@ record UDPAddrInfo where
120119 remote_port : Port
121120
122121||| Frees a given pointer
123−public
122+export
124123sock_free : BufPtr -> IO ()
125124sock_free (BPtr ptr) = foreign FFI_C "idrnet_free" (Ptr -> IO ()) ptr
126125
127−public
126+export
128127sockaddr_free : SockaddrPtr -> IO ()
129128sockaddr_free (SAPtr ptr) = foreign FFI_C "idrnet_free" (Ptr -> IO ()) ptr
130129
131130||| Allocates an amount of memory given by the ByteLength parameter.
132131|||
133132||| Used to allocate a mutable pointer to be given to the Recv functions.
134−public
133+export
135134sock_alloc : ByteLength -> IO BufPtr
136135sock_alloc bl = map BPtr $ foreign FFI_C "idrnet_malloc" (Int -> IO Ptr) bl
137136
libs/contrib/System/Concurrency/Process.idr+10−2
@@ -4,9 +4,9 @@ module System.Concurrency.Process
44
55import System.Concurrency.Raw
66
7−%access public
7+%access public export
88
9−abstract
9+export
1010data ProcID msg = MkPID Ptr
1111
1212||| Type safe message passing programs. Parameterised over the type of
@@ -30,24 +30,29 @@ run : Process msg x -> IO x
3030run (Lift prog) = prog
3131
3232||| Get current process ID
33+export
3334myID : Process msg (ProcID msg)
3435myID = Lift (return (MkPID prim__vm))
3536
3637||| Send a message to another process
3738||| Returns whether the send was unsuccessful.
39+export
3840send : ProcID msg -> msg -> Process msg Bool
3941send (MkPID p) m = Lift (do x <- sendToThread p (prim__vm, m)
4042 return (x == 1))
4143
4244||| Return whether a message is waiting in the queue
45+export
4346msgWaiting : Process msg Bool
4447msgWaiting = Lift checkMsgs
4548
4649||| Return whether a message is waiting in the queue from a specific sender
50+export
4751msgWaitingFrom : ProcID msg -> Process msg Bool
4852msgWaitingFrom (MkPID p) = Lift (checkMsgsFrom p)
4953
5054||| Receive a message - blocks if there is no message waiting
55+export
5156recv : Process msg msg
5257recv {msg} = do (senderid, m) <- Lift get
5358 return m
@@ -55,6 +60,7 @@ recv {msg} = do (senderid, m) <- Lift get
5560 get = getMsg
5661
5762||| Receive a message from specific sender - blocks if there is no message waiting
63+export
5864recvFrom : ProcID msg -> Process msg msg
5965recvFrom (MkPID p) {msg} = do (senderid, m) <- Lift get
6066 return m
@@ -62,6 +68,7 @@ recvFrom (MkPID p) {msg} = do (senderid, m) <- Lift get
6268 get = getMsgFrom p
6369
6470||| receive a message, and return with the sender's process ID.
71+export
6572recvWithSender : Process msg (ProcID msg, msg)
6673recvWithSender {msg}
6774 = do (senderid, m) <- Lift get
@@ -69,6 +76,7 @@ recvWithSender {msg}
6976 where get : IO (Ptr, msg)
7077 get = getMsg
7178
79+export
7280create : Process msg () -> Process msg (ProcID msg)
7381create (Lift p) = do ptr <- Lift (fork p)
7482 return (MkPID ptr)
libs/contrib/contrib.ipkg+2
@@ -7,7 +7,9 @@ modules = Control.Algebra,
77 Control.Isomorphism.Primitives,
88 Control.Partial,
99 Control.WellFounded,
10+
1011 Classes.Verified,
12+
1113 Data.Fun, Data.Rel,
1214 Data.Hash,
1315 Data.Matrix, Data.Matrix.Algebraic, Data.Matrix.Numeric,
libs/effects/Effect/Default.idr+2
@@ -2,6 +2,8 @@ module Effect.Default
22
33import Data.Vect
44
5+%access public export
6+
57interface Default a where
68 default : a
79
libs/effects/Effect/Exception.idr+2
@@ -4,6 +4,8 @@ import Effects
44import System
55import Control.IOExcept
66
7+%access public export
8+
79data Exception : Type -> Effect where
810 Raise : a -> sig (Exception a) b
911
libs/effects/Effect/File.idr+1
@@ -4,6 +4,7 @@ module Effect.File
44import Effects
55import Control.IOExcept
66
7+%access public export
78
89||| A Dependent type to describe File Handles. File handles are
910||| parameterised with the current state of the file: Closed; Open for
libs/effects/Effect/Logging/Category.idr+1−1
@@ -14,7 +14,7 @@ module Effect.Logging.Category
1414import Effects
1515import public Effect.Logging.Level
1616
17−%access public
17+%access public export
1818
1919-- -------------------------------------------------------- [ Logging Resource ]
2020
libs/effects/Effect/Logging/Default.idr+1−1
@@ -15,7 +15,7 @@ module Effect.Logging.Default
1515import Effects
1616import public Effect.Logging.Level
1717
18−%access public
18+%access public export
1919
2020-- ------------------------------------------------------------ [ The Resource ]
2121
libs/effects/Effect/Logging/Level.idr+1−1
@@ -14,7 +14,7 @@
1414||| loggers.
1515module Effect.Logging.Level
1616
17−%access public
17+%access public export
1818%default total
1919
2020-- ---------------------------------------------------- [ Log Level Definition ]
libs/effects/Effect/Memory.idr+9−3
@@ -5,13 +5,13 @@ import Control.IOExcept
55import Data.Vect
66import public Data.So
77
8−%access public
8+%access public export
99
10−abstract
10+export
1111data MemoryChunk : Nat -> Nat -> Type where
1212 CH : Ptr -> MemoryChunk size initialized
1313
14−abstract
14+export
1515data RawMemory : Effect where
1616 Allocate : (n : Nat) ->
1717 RawMemory () () (\v => MemoryChunk n 0)
@@ -102,10 +102,12 @@ implementation Handler RawMemory (IOExcept String) where
102102RAW_MEMORY : Type -> EFFECT
103103RAW_MEMORY t = MkEff t RawMemory
104104
105+export
105106allocate : (n : Nat) ->
106107 Eff () [RAW_MEMORY ()] (\v => [RAW_MEMORY (MemoryChunk n 0)])
107108allocate size = call $ Allocate size
108109
110+export
109111initialize : {i : Nat} ->
110112 {n : Nat} ->
111113 Bits8 ->
@@ -115,9 +117,11 @@ initialize : {i : Nat} ->
115117 (\v => [RAW_MEMORY (MemoryChunk n (i + size))])
116118initialize c size prf = call $ Initialize c size prf
117119
120+export
118121free : Eff () [RAW_MEMORY (MemoryChunk n i)] (\v => [RAW_MEMORY ()])
119122free = call Free
120123
124+export
121125peek : {i : Nat} ->
122126 (offset : Nat) ->
123127 (size : Nat) ->
@@ -125,6 +129,7 @@ peek : {i : Nat} ->
125129 { [RAW_MEMORY (MemoryChunk n i)] } Eff (Vect size Bits8)
126130peek offset size prf = call $ Peek offset size prf
127131
132+export
128133poke : {n : Nat} ->
129134 {i : Nat} ->
130135 (offset : Nat) ->
@@ -155,6 +160,7 @@ move' src_ptr dst_offset src_offset size dst_bounds src_bounds
155160
156161data MoveDescriptor = Dst | Src
157162
163+export
158164move : {dst_size : Nat} ->
159165 {dst_init : Nat} ->
160166 {src_size : Nat} ->
libs/effects/Effect/Monad.idr+2
@@ -2,6 +2,8 @@ module Effect.Monad
22
33import Effects
44
5+%access public export
6+
57data MonadEffT : List EFFECT -> (Type -> Type) -> Type -> Type where
68 MkMonadEffT : EffM m a xs (\v => xs) -> MonadEffT xs m a
79
libs/effects/Effect/Perf.idr+1−1
@@ -12,7 +12,7 @@ import System
1212import Effects
1313import Effect.Default
1414
15−%access public
15+%access public export
1616
1717-- ---------------------------------------------------- [ Timer Data Structure ]
1818
libs/effects/Effect/Random.idr+2
@@ -3,6 +3,8 @@ module Effect.Random
33import Effects
44import Data.Vect
55
6+%access public export
7+
68data Random : Effect where
79 GetRandom : sig Random Integer Integer
810 SetSeed : Integer -> sig Random () Integer
libs/effects/Effect/Select.idr+2
@@ -2,6 +2,8 @@ module Effect.Select
22
33import Effects
44
5+%access public export
6+
57data Selection : Effect where
68 Select : List a -> sig Selection a ()
79
libs/effects/Effect/State.idr+1−1
@@ -2,7 +2,7 @@ module Effect.State
22
33import Effects
44
5−%access public
5+%access public export
66
77data State : Effect where
88 Get : sig State a a
libs/effects/Effect/StdIO.idr+2
@@ -3,6 +3,8 @@ module Effect.StdIO
33import Effects
44import Control.IOExcept
55
6+%access public export
7+
68-------------------------------------------------------------
79-- IO effects internals
810-------------------------------------------------------------
libs/effects/Effect/System.idr+2
@@ -7,6 +7,8 @@ import Effects
77import System
88import Control.IOExcept
99
10+%access public export
11+
1012data System : Effect where
1113 Args : sig System (List String)
1214 Time : sig System Integer
libs/effects/Effect/Trans.idr+1−1
@@ -2,7 +2,7 @@ module Effect.Trans
22
33import Effects
44
5−%access public
5+%access public export
66
77data Trans : (Type -> Type) -> Effect where
88 Lift : m a -> sig (Trans m) a
libs/effects/Effects.idr+25−1
@@ -7,7 +7,7 @@ import Data.Vect
77--- Effectful computations are described as algebraic data types that
88--- explain how an effect is interpreted in some underlying context.
99
10−%access public
10+%access export
1111-- ----------------------------------------------------------------- [ Effects ]
1212||| The Effect type describes effectful computations.
1313|||
@@ -15,11 +15,13 @@ import Data.Vect
1515||| + The return type of the computation.
1616||| + The input resource.
1717||| + The computation to run on the resource given the return value.
18+public export
1819Effect : Type
1920Effect = (x : Type) -> Type -> (x -> Type) -> Type
2021
2122||| The `EFFECT` Data type describes how to promote the Effect
2223||| description into a concrete effect.
24+public export
2325%error_reverse
2426data EFFECT : Type where
2527 MkEff : Type -> Effect -> EFFECT
@@ -30,24 +32,29 @@ data EFFECT : Type where
3032-- or a dependent change. These are easily disambiguated by type.
3133
3234namespace NoResourceEffect
35+ public export
3336 sig : Effect -> Type -> Type
3437 sig e r = e r () (\v => ())
3538
3639namespace NoUpdateEffect
40+ public export
3741 sig : Effect -> (ret : Type) -> (resource : Type) -> Type
3842 sig e r e_in = e r e_in (\v => e_in)
3943
4044namespace UpdateEffect
45+ public export
4146 sig : Effect -> (ret : Type) -> (res_in : Type) -> (res_out : Type) -> Type
4247 sig e r e_in e_out = e r e_in (\v => e_out)
4348
4449namespace DepUpdateEffect
50+ public export
4551 sig : Effect ->
4652 (ret : Type) -> (res_in : Type) -> (res_out : ret -> Type) -> Type
4753 sig e r e_in e_out = e r e_in e_out
4854
4955||| Handler interfaces describe how an effect `e` is translated to the
5056||| underlying computation context `m` for execution.
57+public export
5158interface Handler (e : Effect) (m : Type -> Type) where
5259 ||| How to handle the effect.
5360 |||
@@ -77,6 +84,7 @@ syntax "{" [inst] "==>" "{" {b} "}" [outst] "}" [eff]
7784syntax "{" [inst] "==>" [outst] "}" [eff] = eff inst (\result => outst)
7885
7986-- --------------------------------------- [ Properties and Proof Construction ]
87+public export
8088data SubList : List a -> List a -> Type where
8189 SubNil : SubList [] []
8290 Keep : SubList xs ys -> SubList (x :: xs) (x :: ys)
@@ -88,21 +96,25 @@ subListId {xs = Nil} = SubNil
8896subListId {xs = x :: xs} = Keep subListId
8997
9098namespace Env
99+ public export
91100 data Env : (m : Type -> Type) -> List EFFECT -> Type where
92101 Nil : Env m Nil
93102 (::) : Handler eff m => a -> Env m xs -> Env m (MkEff a eff :: xs)
94103
104+public export
95105data EffElem : Effect -> Type ->
96106 List EFFECT -> Type where
97107 Here : EffElem x a (MkEff a x :: xs)
98108 There : EffElem x a xs -> EffElem x a (y :: xs)
99109
100110||| make an environment corresponding to a sub-list
111+private
101112dropEnv : Env m ys -> SubList xs ys -> Env m xs
102113dropEnv [] SubNil = []
103114dropEnv (v :: vs) (Keep rest) = v :: dropEnv vs rest
104115dropEnv (v :: vs) (Drop rest) = dropEnv vs rest
105116
117+public export
106118updateWith : (ys' : List a) -> (xs : List a) ->
107119 SubList ys xs -> List a
108120updateWith (y :: ys) (x :: xs) (Keep rest) = y :: updateWith ys xs rest
@@ -112,6 +124,7 @@ updateWith (y :: ys) [] SubNil = y :: ys
112124updateWith [] (x :: xs) (Keep rest) = []
113125
114126||| Put things back, replacing old with new in the sub-environment
127+private
115128rebuildEnv : Env m ys' -> (prf : SubList ys xs) ->
116129 Env m xs -> Env m (updateWith ys' xs prf)
117130rebuildEnv [] SubNil env = env
@@ -123,6 +136,7 @@ rebuildEnv xs (Drop rest) (y :: env) = y :: rebuildEnv xs rest env
123136
124137-- -------------------------------------------------- [ The Effect EDSL itself ]
125138
139+public export
126140updateResTy : (val : t) ->
127141 (xs : List EFFECT) -> EffElem e a xs -> e t a b ->
128142 List EFFECT
@@ -131,9 +145,11 @@ updateResTy val (x :: xs) (There p) n = x :: updateResTy val xs p n
131145
132146infix 5 :::, :-, :=
133147
148+public export
134149data LRes : lbl -> Type -> Type where
135150 (:=) : (x : lbl) -> res -> LRes x res
136151
152+public export
137153(:::) : lbl -> EFFECT -> EFFECT
138154(:::) {lbl} x (MkEff r e) = MkEff (LRes x r) e
139155
@@ -156,6 +172,7 @@ relabel {xs = (MkEff a e :: xs)} l (v :: vs) = (l := v) :: relabel l vs
156172||| @ x The return type of the result.
157173||| @ es The list of allowed side-effects.
158174||| @ ce Function to compute a new list of allowed side-effects.
175+public export
159176data EffM : (m : Type -> Type) -> (x : Type)
160177 -> (es : List EFFECT)
161178 -> (ce : x -> List EFFECT) -> Type where
@@ -182,27 +199,33 @@ data EffM : (m : Type -> Type) -> (x : Type)
182199
183200namespace SimpleEff
184201 -- Simple effects, no updates
202+ public export
185203 Eff : (x : Type) -> (es : List EFFECT) -> Type
186204 Eff x es = {m : Type -> Type} -> EffM m x es (\v => es)
187205
206+ public export
188207 EffT : (m : Type -> Type) -> (x : Type) -> (es : List EFFECT) -> Type
189208 EffT m x es = EffM m x es (\v => es)
190209
191210namespace TransEff
192211 -- Dependent effects, updates not dependent on result
212+ public export
193213 Eff : (x : Type) -> (es : List EFFECT) -> (ce : List EFFECT) -> Type
194214 Eff x es ce = {m : Type -> Type} -> EffM m x es (\_ => ce)
195215
216+ public export
196217 EffT : (m : Type -> Type) ->
197218 (x : Type) -> (es : List EFFECT) -> (ce : List EFFECT) -> Type
198219 EffT m x es ce = EffM m x es (\_ => ce)
199220
200221namespace DepEff
201222 -- Dependent effects, updates dependent on result
223+ public export
202224 Eff : (x : Type) -> (es : List EFFECT)
203225 -> (ce : x -> List EFFECT) -> Type
204226 Eff x es ce = {m : Type -> Type} -> EffM m x es ce
205227
228+ public export
206229 EffT : (m : Type -> Type) -> (x : Type) -> (es : List EFFECT)
207230 -> (ce : x -> List EFFECT) -> Type
208231 EffT m x es ce = EffM m x es ce
@@ -271,6 +294,7 @@ execEff (val :: env) (There p) eff k
271294-- Q: Instead of m b, implement as StateT (Env m xs') m b, so that state
272295-- updates can be propagated even through failing computations?
273296
297+export
274298eff : Env m xs -> EffM m a xs xs' -> ((x : a) -> Env m (xs' x) -> m b) -> m b
275299eff env (Value x) k = k x env
276300eff env (prog `EBind` c) k
libs/prelude/Builtins.idr+5−5
@@ -1,6 +1,6 @@
11%unqualified
22
3−%access public
3+%access public export
44%default total
55
66||| The canonical single-element type, also known as the trivially
@@ -155,13 +155,13 @@ assert_total x = x
155155
156156||| Subvert the type checker. This function is abstract, so it will not reduce in
157157||| the type checker. Use it with care - it can result in segfaults or worse!
158−abstract %assert_total -- need to pretend
158+export %assert_total -- need to pretend
159159believe_me : a -> b
160160believe_me x = prim__believe_me _ _ x
161161
162162||| Subvert the type checker. This function *will* reduce in the type checker.
163163||| Use it with extreme care - it can result in segfaults or worse!
164−public %assert_total
164+public export %assert_total
165165really_believe_me : a -> b
166166really_believe_me x = prim__believe_me _ _ x
167167
@@ -174,8 +174,8 @@ Float = Double
174174-- Pointers as external primitive; there's no literals for these, so no
175175-- need for them to be part of the compiler.
176176
177−abstract data Ptr : Type
178−abstract data ManagedPtr : Type
177+export data Ptr : Type
178+export data ManagedPtr : Type
179179
180180%extern prim__readFile : prim__WorldType -> Ptr -> String
181181%extern prim__writeFile : prim__WorldType -> Ptr -> String -> Int
libs/prelude/Decidable/Equality.idr+4−5
@@ -3,12 +3,14 @@ module Decidable.Equality
33import Builtins
44import Prelude.Basics
55import Prelude.Bool
6−import Prelude.Classes
6+import Prelude.Interfaces
77import Prelude.Either
88import Prelude.List
99import Prelude.Nat
1010import Prelude.Maybe
1111
12+%access public export
13+
1214--------------------------------------------------------------------------------
1315-- Utility lemmas
1416--------------------------------------------------------------------------------
@@ -141,7 +143,7 @@ implementation DecEq a => DecEq (List a) where
141143 decEq [] (x :: xs) = No (negEqSym lemma_val_not_nil)
142144 decEq (x :: xs) (y :: ys) with (decEq x y)
143145 decEq (x :: xs) (x :: ys) | Yes Refl with (decEq xs ys)
144− decEq (x :: xs) (x :: xs) | (Yes Refl) | (Yes Refl) = Yes Refl
146+ decEq (x :: xs) (x :: xs) | (Yes Refl) | (Yes Refl) = Yes Refl
145147 decEq (x :: xs) (x :: ys) | (Yes Refl) | (No p) = No (\eq => lemma_x_eq_xs_neq Refl p eq)
146148 decEq (x :: xs) (y :: ys) | No p with (decEq xs ys)
147149 decEq (x :: xs) (y :: xs) | (No p) | (Yes Refl) = No (\eq => lemma_x_neq_xs_eq p Refl eq)
@@ -211,6 +213,3 @@ implementation DecEq ManagedPtr where
211213 where primitiveEq : x = y
212214 primitiveEq = believe_me (Refl {x})
213215 postulate primitiveNotEq : x = y -> Void
214−
215−
216−
libs/prelude/IO.idr+22−9
@@ -3,25 +3,25 @@
33import Builtins
44import Prelude.List
55
6−%access public
6+%access export
77
88||| Idris's primitive IO, for building abstractions on top of
9−abstract
109data PrimIO : Type -> Type where
1110 Prim__IO : a -> PrimIO a
1211
1312||| A token representing the world, for use in `IO`
14−abstract data World = TheWorld prim__WorldType
13+data World = TheWorld prim__WorldType
1514
1615private
1716world : World -> prim__WorldType
1817world (TheWorld w) = w
1918
20−abstract WorldRes : Type -> Type
19+WorldRes : Type -> Type
2120WorldRes x = x
2221
2322||| An FFI specifier, which describes how a particular compiler
2423||| backend handles foreign function calls.
24+public export
2525record FFI where
2626 constructor MkFFI
2727 ||| A family describing which types are available in the FFI
@@ -35,10 +35,10 @@ record FFI where
3535
3636||| The IO type, parameterised over the FFI that is available within
3737||| it.
38−abstract
3938data IO' : (lang : FFI) -> Type -> Type where
4039 MkIO : (World -> PrimIO (WorldRes a)) -> IO' lang a
4140
41+public export
4242data FTy : FFI -> List Type -> Type -> Type where
4343 FRet : ffi_types f t -> FTy f xs (IO' f t)
4444 FFun : ffi_types f s -> FTy f (s :: xs) t -> FTy f xs (s -> t)
@@ -54,6 +54,7 @@ ForeignPrimType {ffi} (x :: xs) ((a, _) :: env) t
5454 = (ffi_types ffi x, x) -> ForeignPrimType xs env t
5555
5656%inline
57+private
5758applyEnv : (env : FEnv ffi xs) ->
5859 ForeignPrimType xs env t ->
5960 World -> ffi_fn ffi -> ffi_types ffi t -> PrimIO t
@@ -66,6 +67,7 @@ mkForeignPrim : {xs : _} -> {ffi : _} -> {env : FEnv ffi xs} -> {t : Type} ->
6667-- explicit here.
6768
6869%inline
70+private
6971foreign_prim : (f : FFI) ->
7072 (fname : ffi_fn f) -> FTy f xs ty -> FEnv f xs -> ty
7173foreign_prim f fname (FRet y) env
@@ -91,25 +93,21 @@ foreign : (f : FFI) -> (fname : ffi_fn f) -> (ty : Type) ->
9193 {auto fty : FTy f [] ty} -> ty
9294foreign ffi fname ty {fty} = foreign_prim ffi fname fty []
9395
94−abstract
9596prim_io_bind : PrimIO a -> (a -> PrimIO b) -> PrimIO b
9697prim_io_bind (Prim__IO v) k = k v
9798
9899unsafePerformPrimIO : PrimIO a -> a
99100-- compiled as primitive
100101
101−abstract
102102prim_io_return : a -> PrimIO a
103103prim_io_return x = Prim__IO x
104104
105−abstract
106105io_bind : IO' l a -> (a -> IO' l b) -> IO' l b
107106io_bind (MkIO fn) k
108107 = MkIO (\w => prim_io_bind (fn w)
109108 (\ b => case k b of
110109 MkIO fkb => fkb w))
111110
112−abstract
113111io_return : a -> IO' l a
114112io_return x = MkIO (\w => prim_io_return x)
115113
@@ -143,6 +141,7 @@ prim_fwrite h s
143141
144142--------- The C FFI
145143namespace FFI_C
144+ public export
146145 data Raw : Type -> Type where
147146 -- code generated can assume it's compiled just as 't'
148147 MkRaw : (x : t) -> Raw t
@@ -151,6 +150,7 @@ namespace FFI_C
151150 %used MkRaw x
152151
153152 ||| Supported C integer types
153+ public export
154154 data C_IntTypes : Type -> Type where
155155 C_IntChar : C_IntTypes Char
156156 C_IntNative : C_IntTypes Int
@@ -160,6 +160,7 @@ namespace FFI_C
160160 C_IntBits64 : C_IntTypes Bits64
161161
162162 ||| Supported C foreign types
163+ public export
163164 data C_Types : Type -> Type where
164165 C_Str : C_Types String
165166 C_Float : C_Types Double
@@ -172,12 +173,14 @@ namespace FFI_C
172173 ||| A descriptor for the C FFI. See the constructors of `C_Types`
173174 ||| and `C_IntTypes` for the concrete types that are available.
174175 %error_reverse
176+ public export
175177 FFI_C : FFI
176178 FFI_C = MkFFI C_Types String String
177179
178180||| Interactive programs, describing I/O actions and returning a value.
179181||| @res The result type of the program
180182%error_reverse
183+public export
181184IO : (res : Type) -> Type
182185IO = IO' FFI_C
183186
@@ -207,18 +210,22 @@ namespace IO
207210
208211-- Supported JS foreign types
209212mutual
213+ public export
210214 data JsFn : Type -> Type where
211215 MkJsFn : (x : t) -> JsFn t
212216
217+ public export
213218 data JS_IntTypes : Type -> Type where
214219 JS_IntChar : JS_IntTypes Char
215220 JS_IntNative : JS_IntTypes Int
216221
222+ public export
217223 data JS_FnTypes : Type -> Type where
218224 JS_Fn : JS_Types s -> JS_FnTypes t -> JS_FnTypes (s -> t)
219225 JS_FnIO : JS_Types t -> JS_FnTypes (IO' l t)
220226 JS_FnBase : JS_Types t -> JS_FnTypes t
221227
228+ public export
222229 data JS_Types : Type -> Type where
223230 JS_Str : JS_Types String
224231 JS_Float : JS_Types Double
@@ -236,10 +243,12 @@ mutual
236243||| JavaScript code snippets, into which the arguments are substituted
237244||| for the placeholders `%0`, `%1`, etc.
238245%error_reverse
246+public export
239247FFI_JS : FFI
240248FFI_JS = MkFFI JS_Types String String
241249
242250%error_reverse
251+public export
243252JS_IO : Type -> Type
244253JS_IO = IO' FFI_JS
245254
@@ -249,10 +258,12 @@ JS_IO = IO' FFI_JS
249258namespace FFI_Export
250259-- It's just like Data.List.Elem, but we don't need all the other stuff
251260-- that comes with it, just a proof that a data type is defined.
261+ public export
252262 data DataDefined : Type -> List (Type, s) -> s -> Type where
253263 DHere : DataDefined x ((x, t) :: xs) t
254264 DThere : DataDefined x xs t -> DataDefined x (y :: xs) t
255265
266+ public export
256267 data FFI_Base : (f : FFI) -> List (Type, ffi_data f) -> Type -> Type where
257268 FFI_ExpType : {n : ffi_data f} -> (def : DataDefined t xs n) -> FFI_Base f xs t
258269 FFI_Prim : (prim : ffi_types f t) -> FFI_Base f xs t
@@ -261,6 +272,7 @@ namespace FFI_Export
261272 %used FFI_ExpType def
262273 %used FFI_Prim prim
263274
275+ public export
264276 data FFI_Exportable : (f : FFI) -> List (Type, ffi_data f) -> Type -> Type where
265277 FFI_IO : (b : FFI_Base f xs t) -> FFI_Exportable f xs (IO' f t)
266278 FFI_Fun : (b : FFI_Base f xs s) -> (a : FFI_Exportable f xs t) -> FFI_Exportable f xs (s -> t)
@@ -271,6 +283,7 @@ namespace FFI_Export
271283 %used FFI_Fun a
272284 %used FFI_Ret b
273285
286+ public export
274287 data FFI_Export : (f : FFI) -> String -> List (Type, ffi_data f) -> Type where
275288 Data : (x : Type) -> (n : ffi_data f) ->
276289 (es : FFI_Export f h ((x, n) :: xs)) -> FFI_Export f h xs
libs/prelude/Language/Reflection.idr+3−3
@@ -9,7 +9,7 @@ import Prelude.List
99import Prelude.Nat
1010import Prelude.Traversable
1111
12−%access public
12+%access public export
1313
1414||| A source location in an Idris file
1515record SourceLocation where
@@ -80,7 +80,7 @@ data Const = I Int | BI Integer | Fl Double | Ch Char | Str String
8080 | WorldType | TheWorld
8181%name Const c, c'
8282
83−abstract interface ReflConst (a : Type) where
83+export interface ReflConst (a : Type) where
8484 toConst : a -> Const
8585
8686implementation ReflConst Int where
@@ -110,7 +110,7 @@ implementation ReflConst Bits32 where
110110implementation ReflConst Bits64 where
111111 toConst = B64
112112
113−implicit
113+implicit export
114114reflectConstant: (ReflConst a) => a -> Const
115115reflectConstant = toConst
116116
libs/prelude/Language/Reflection/Elab.idr+54−2
@@ -16,6 +16,8 @@ import Prelude.Monad
1616import Prelude.Nat
1717import Language.Reflection
1818
19+%access public export
20+
1921data Fixity = Infixl Nat | Infixr Nat | Infix Nat | Prefix Nat
2022
2123||| Erasure annotations reflect Idris's idea of what is intended to be
@@ -100,7 +102,7 @@ record Datatype where
100102 constructors : List (TTName, List CtorArg, Raw)
101103
102104||| A reflected elaboration script.
103−abstract
105+export
104106data Elab : Type -> Type where
105107 -- obligatory control stuff
106108 Prim__PureElab : a -> Elab a
@@ -164,7 +166,7 @@ data Elab : Type -> Type where
164166-------------
165167-- Public API
166168-------------
167−%access public
169+%access public export
168170namespace Tactics
169171 implementation Functor Elab where
170172 map f t = Prim__BindElab t (\x => Prim__PureElab (f x))
@@ -186,31 +188,38 @@ namespace Tactics
186188 x >>= f = Prim__BindElab x f
187189
188190 ||| Halt elaboration with an error
191+ export
189192 fail : List ErrorReportPart -> Elab a
190193 fail err = Prim__Fail err
191194
192195 ||| Look up the lexical binding at the focused hole. Fails if no holes are present.
196+ export
193197 getEnv : Elab (List (TTName, Binder TT))
194198 getEnv = Prim__Env
195199
196200 ||| Get the name and type of the focused hole. Fails if not holes are present.
201+ export
197202 getGoal : Elab (TTName, TT)
198203 getGoal = Prim__Goal
199204
200205 ||| Get the hole queue, in order.
206+ export
201207 getHoles : Elab (List TTName)
202208 getHoles = Prim__Holes
203209
204210 ||| If the current hole contains a guess, return it. Otherwise, fail.
211+ export
205212 getGuess : Elab TT
206213 getGuess = Prim__Guess
207214
208215 ||| Look up the types of every overloading of a name.
216+ export
209217 lookupTy : TTName -> Elab (List (TTName, NameType, TT))
210218 lookupTy n = Prim__LookupTy n
211219
212220 ||| Get the type of a fully-qualified name. Fail if it doesn not
213221 ||| resolve uniquely.
222+ export
214223 lookupTyExact : TTName -> Elab (TTName, NameType, TT)
215224 lookupTyExact n = case !(lookupTy n) of
216225 [res] => return res
@@ -219,12 +228,14 @@ namespace Tactics
219228
220229 ||| Find the reflected representation of all datatypes whose names
221230 ||| are overloadings of some name.
231+ export
222232 lookupDatatype : TTName -> Elab (List Datatype)
223233 lookupDatatype n = Prim__LookupDatatype n
224234
225235 ||| Find the reflected representation of a datatype, given its
226236 ||| fully-qualified name. Fail if the name does not uniquely resolve
227237 ||| to a datatype.
238+ export
228239 lookupDatatypeExact : TTName -> Elab Datatype
229240 lookupDatatypeExact n = case !(lookupDatatype n) of
230241 [res] => return res
@@ -233,12 +244,14 @@ namespace Tactics
233244
234245 ||| Find the reflected function definition of all functions whose names
235246 ||| are overloadings of some name.
247+ export
236248 lookupFunDefn : TTName -> Elab (List (FunDefn TT))
237249 lookupFunDefn n = Prim__LookupFunDefn n
238250
239251 ||| Find the reflected function definition of a function, given its
240252 ||| fully-qualified name. Fail if the name does not uniquely resolve
241253 ||| to a function.
254+ export
242255 lookupFunDefnExact : TTName -> Elab (FunDefn TT)
243256 lookupFunDefnExact n = case !(lookupFunDefn n) of
244257 [res] => return res
@@ -246,11 +259,13 @@ namespace Tactics
246259 xs => fail [TextPart "More than one function named", NamePart n]
247260
248261 ||| Get the argument specification for each overloading of a name.
262+ export
249263 lookupArgs : TTName -> Elab (List (TTName, List FunArg, Raw))
250264 lookupArgs n = Prim__LookupArgs n
251265
252266 ||| Get the argument specification for a name. Fail if the name does
253267 ||| not uniquely resolve.
268+ export
254269 lookupArgsExact : TTName -> Elab (TTName, List FunArg, Raw)
255270 lookupArgsExact n = case !(lookupArgs n) of
256271 [res] => return res
@@ -261,6 +276,7 @@ namespace Tactics
261276 |||
262277 ||| @ env the environment within which to check the type
263278 ||| @ tm the term to check
279+ export
264280 check : (env : List (TTName, Binder TT)) -> (tm : Raw) -> Elab (TT, TT)
265281 check env tm = Prim__Check env tm
266282
@@ -269,15 +285,18 @@ namespace Tactics
269285 |||
270286 ||| **NB**: the generated name is unique _for this run of the
271287 ||| elaborator_. Do not assume that they are globally unique.
288+ export
272289 gensym : (hint : String) -> Elab TTName
273290 gensym hint = Prim__Gensym hint
274291
275292 ||| Substitute a guess into a hole.
293+ export
276294 solve : Elab ()
277295 solve = Prim__Solve
278296
279297 ||| Place a term into a hole, unifying its type. Fails if the focus
280298 ||| is not a hole.
299+ export
281300 fill : Raw -> Elab ()
282301 fill tm = Prim__Fill tm
283302
@@ -295,6 +314,7 @@ namespace Tactics
295314 ||| @ argSpec instructions for finding the arguments to the term,
296315 ||| where the Boolean states whether or not to attempt to solve
297316 ||| the argument by unification.
317+ export
298318 apply : (op : Raw) -> (argSpec : List Bool) -> Elab (List TTName)
299319 apply tm argSpec = map snd <$> Prim__Apply tm argSpec
300320
@@ -313,6 +333,7 @@ namespace Tactics
313333 ||| where the Boolean states whether or not to attempt to solve
314334 ||| the argument by matching.
315335
336+ export
316337 matchApply : (op : Raw) -> (argSpec : List Bool) -> Elab (List TTName)
317338 matchApply tm argSpec = map snd <$> Prim__Apply tm argSpec
318339
@@ -320,11 +341,13 @@ namespace Tactics
320341 ||| exist.
321342 |||
322343 ||| @ hole the hole to focus on
344+ export
323345 focus : (hole : TTName) -> Elab ()
324346 focus hole = Prim__Focus hole
325347
326348 ||| Send the currently-focused hole to the end of the hole queue and
327349 ||| focus on the next hole.
350+ export
328351 unfocus : TTName -> Elab ()
329352 unfocus hole = Prim__Unfocus hole
330353
@@ -336,6 +359,7 @@ namespace Tactics
336359 ||| binding, or else the scopes of the generated terms won't make
337360 ||| sense. This tactic creates a new hole of the proper form, and
338361 ||| points the old hole at it.
362+ export
339363 attack : Elab ()
340364 attack = Prim__Attack
341365
@@ -344,6 +368,7 @@ namespace Tactics
344368 ||| The new hole will be focused, and the previously-focused hole
345369 ||| will be immediately after it in the hole queue. Because this
346370 ||| tactic introduces a new binding, you may need to `attack` first.
371+ export
347372 claim : TTName -> Raw -> Elab ()
348373 claim n ty = Prim__Claim n ty
349374
@@ -352,6 +377,7 @@ namespace Tactics
352377 ||| `attack`).
353378 |||
354379 ||| @ n the name to use for the argument
380+ export
355381 intro : (n : TTName) -> Elab ()
356382 intro n = Prim__Intro (Just n)
357383
@@ -361,6 +387,7 @@ namespace Tactics
361387 |||
362388 ||| Requires that the hole be immediately under its binder (use
363389 ||| `attack` if it might not be).
390+ export
364391 intro' : Elab ()
365392 intro' = Prim__Intro Nothing
366393
@@ -369,10 +396,12 @@ namespace Tactics
369396 |||
370397 ||| Requires that the hole be immediately under its binder (use
371398 ||| `attack` if it might not be).
399+ export
372400 forall : TTName -> Raw -> Elab ()
373401 forall n ty = Prim__Forall n ty
374402
375403 ||| Convert a hole into a pattern variable.
404+ export
376405 patvar : TTName -> Elab ()
377406 patvar n = Prim__PatVar n
378407
@@ -380,6 +409,7 @@ namespace Tactics
380409 |||
381410 ||| Requires that the hole be immediately under its binder (use
382411 ||| `attack` if it might not be).
412+ export
383413 patbind : TTName -> Elab ()
384414 patbind n = Prim__PatBind n
385415
@@ -391,10 +421,12 @@ namespace Tactics
391421 ||| @ n the name to let bind
392422 ||| @ ty the type of the term to be let-bound
393423 ||| @ tm the term to be bound
424+ export
394425 letbind : (n : TTName) -> (ty, tm : Raw) -> Elab ()
395426 letbind n ty tm = Prim__LetBind n ty tm
396427
397428 ||| Normalise the goal.
429+ export
398430 compute : Elab ()
399431 compute = Prim__Compute
400432
@@ -402,12 +434,14 @@ namespace Tactics
402434 |||
403435 ||| @ env the environment in which to compute (get one of these from `getEnv`)
404436 ||| @ term the term to normalise
437+ export
405438 normalise : (env : List (TTName, Binder TT)) -> (term : TT) -> Elab TT
406439 normalise env term = Prim__Normalise env term
407440
408441 ||| Reduce a closed term to weak-head normal form
409442 |||
410443 ||| @ term the term to reduce
444+ export
411445 whnf : (term : TT) -> Elab TT
412446 whnf term = Prim__Whnf term
413447
@@ -417,6 +451,7 @@ namespace Tactics
417451 ||| @ env a lexical environment to compare the terms in (see `getEnv`)
418452 ||| @ term1 the first term to convert
419453 ||| @ term2 the second term to convert
454+ export
420455 convertsInEnv : (env : List (TTName, Binder TT)) -> (term1, term2 : TT) -> Elab ()
421456 convertsInEnv env term1 term2 = Prim__Converts env term1 term2
422457
@@ -424,14 +459,17 @@ namespace Tactics
424459 |||
425460 ||| @ term1 the first term to convert
426461 ||| @ term2 the second term to convert
462+ export
427463 converts : (term1, term2 : TT) -> Elab ()
428464 converts term1 term2 = convertsInEnv !getEnv term1 term2
429465
430466 ||| Find the source context for the elaboration script
467+ export
431468 getSourceLocation : Elab SourceLocation
432469 getSourceLocation = Prim__SourceLocation
433470
434471 ||| Attempt to solve the current goal with the source code location
472+ export
435473 sourceLocation : Elab ()
436474 sourceLocation = do loc <- getSourceLocation
437475 fill (quote loc)
@@ -442,6 +480,7 @@ namespace Tactics
442480 |||
443481 ||| The namespace is represented as a reverse-order list of strings,
444482 ||| just as in the representation of names.
483+ export
445484 currentNamespace : Elab (List String)
446485 currentNamespace = Prim__Namespace
447486
@@ -455,16 +494,19 @@ namespace Tactics
455494 ||| Because this tactic internally introduces a `let` binding, it
456495 ||| requires that the hole be immediately under its binder (use
457496 ||| `attack` if it might not be).
497+ export
458498 rewriteWith : Raw -> Elab ()
459499 rewriteWith rule = Prim__Rewrite rule
460500
461501 ||| Add a type declaration to the global context.
502+ export
462503 declareType : TyDecl -> Elab ()
463504 declareType decl = Prim__DeclareType decl
464505
465506 ||| Define a function in the global context. The function must have
466507 ||| already been declared, either in ordinary Idris code or using
467508 ||| `declareType`.
509+ export
468510 defineFunction : FunDefn Raw -> Elab ()
469511 defineFunction defun = Prim__DefineFunction defun
470512
@@ -472,12 +514,14 @@ namespace Tactics
472514 |||
473515 ||| @ ifaceName the name of the interface for which an implementation is being registered
474516 ||| @ instName the name of the definition to use in implementation search
517+ export
475518 addInstance : (ifaceName, instName : TTName) -> Elab ()
476519 addInstance ifaceName instName = Prim__AddInstance ifaceName instName
477520
478521 ||| Determine whether a name denotes an interface.
479522 |||
480523 ||| @ name a name that might denote an interface.
524+ export
481525 isTCName : (name : TTName) -> Elab Bool
482526 isTCName name = Prim__IsTCName name
483527
@@ -485,10 +529,12 @@ namespace Tactics
485529 |||
486530 ||| @ fn the name of the definition being elaborated (to prevent Idris
487531 ||| from looping)
532+ export
488533 resolveTC : (fn : TTName) -> Elab ()
489534 resolveTC fn = Prim__ResolveTC fn
490535
491536 ||| Use Idris's internal proof search.
537+ export
492538 search : Elab ()
493539 search = Prim__Search 100 []
494540
@@ -496,6 +542,7 @@ namespace Tactics
496542 |||
497543 ||| @ depth the search depth
498544 ||| @ hints additional names to try
545+ export
499546 search' : (depth : Int) -> (hints : List TTName) -> Elab ()
500547 search' depth hints = Prim__Search depth hints
501548
@@ -505,6 +552,7 @@ namespace Tactics
505552 ||| if the string is not a valid operator.
506553 |||
507554 ||| @ operator the operator string to look up
555+ export
508556 operatorFixity : (operator : String) -> Elab Fixity
509557 operatorFixity operator = Prim__Fixity operator
510558
@@ -512,6 +560,7 @@ namespace Tactics
512560 |||
513561 ||| This is intended for elaboration script developers, not for
514562 ||| end-users. Use `fail` for final scripts.
563+ export
515564 debug : Elab a
516565 debug = Prim__Debug []
517566
@@ -522,18 +571,21 @@ namespace Tactics
522571 ||| end-users. Use `fail` for final scripts.
523572 |||
524573 ||| @ msg the message to display
574+ export
525575 debugMessage : (msg : List ErrorReportPart) -> Elab a
526576 debugMessage msg = Prim__Debug msg
527577
528578 ||| Create a new top-level metavariable to solve the current hole.
529579 |||
530580 ||| @ name the name for the top-level variable
581+ export
531582 metavar : (name : TTName) -> Elab ()
532583 metavar name = Prim__Metavar name
533584
534585 ||| Recursively invoke the reflected elaborator with some goal.
535586 |||
536587 ||| The result is the final term and its type.
588+ export
537589 runElab : Raw -> Elab () -> Elab (TT, TT)
538590 runElab goal script = Prim__RecursiveElab goal script
539591
libs/prelude/Language/Reflection/Errors.idr+2
@@ -8,6 +8,8 @@ import Prelude.Bool
88import Prelude.List
99import Prelude.Maybe
1010
11+%access public export
12+
1113data Err = Msg String
1214 | InternalMsg String
1315 | CantUnify Bool TT TT Err (List (TTName, TT)) Int
libs/prelude/Prelude.idr+7−7
@@ -6,7 +6,7 @@ import public IO
66import public Prelude.Algebra
77import public Prelude.Basics
88import public Prelude.Bool
9−import public Prelude.Classes
9+import public Prelude.Interfaces
1010import public Prelude.Cast
1111import public Prelude.Nat
1212import public Prelude.List
@@ -33,7 +33,7 @@ import public Language.Reflection
3333import public Language.Reflection.Elab
3434import public Language.Reflection.Errors
3535
36−%access public
36+%access public export
3737%default total
3838
3939-- Things that can't be elsewhere for import cycle reasons
@@ -210,7 +210,7 @@ Enum Int where
210210Enum Char where
211211 toNat c = toNat (ord c)
212212 fromNat n = chr (fromNat n)
213−
213+
214214 pred c = fromNat (pred (toNat c))
215215
216216syntax "[" [start] ".." [end] "]"
@@ -264,13 +264,13 @@ while t b = do v <- t
264264------- Some error rewriting
265265
266266%language ErrorReflection
267−
267+
268268private
269269cast_part : TT -> ErrorReportPart
270270cast_part (P Bound n t) = TextPart "unknown type"
271271cast_part x = TermPart x
272−
273−%error_handler
272+
273+%error_handler export
274274cast_error : Err -> Maybe (List ErrorReportPart)
275275cast_error (CantResolve `(Cast ~x ~y))
276276 = Just [TextPart "Can't cast from",
@@ -280,8 +280,8 @@ cast_error (CantResolve `(Cast ~x ~y))
280280cast_error _ = Nothing
281281
282282%error_handler
283+export
283284num_error : Err -> Maybe (List ErrorReportPart)
284285num_error (CantResolve `(Num ~x))
285286 = Just [TermPart x, TextPart "is not a numeric type"]
286287num_error _ = Nothing
287−
libs/prelude/Prelude/Algebra.idr+1−1
@@ -4,7 +4,7 @@ import Builtins
44
55infixl 6 <+>
66
7−%access public
7+%access public export
88
99--------------------------------------------------------------------------------
1010-- A modest interface hierarchy
libs/prelude/Prelude/Applicative.idr+3−1
@@ -4,10 +4,12 @@ import Builtins
44
55import Prelude.Basics
66import Prelude.Bool
7−import Prelude.Classes
7+import Prelude.Interfaces
88import Prelude.Foldable
99import Prelude.Functor
1010
11+%access public export
12+
1113---- Applicative functors/Idioms
1214
1315infixl 2 <*>
libs/prelude/Prelude/Basics.idr+6−4
@@ -1,7 +1,9 @@
11module Prelude.Basics
22
33import Builtins
4−
4+
5+%access public export
6+
57Not : Type -> Type
68Not a = a -> Void
79
@@ -51,9 +53,9 @@ data Dec : Type -> Type where
5153
5254 ||| The case where the property holds
5355 ||| @ prf the proof
54− Yes : {A : Type} -> (prf : A) -> Dec A
56+ Yes : (prf : prop) -> Dec prop
5557
5658 ||| The case where the property holding would be a contradiction
57− ||| @ contra a demonstration that A would be a contradiction
58− No : {A : Type} -> (contra : A -> Void) -> Dec A
59+ ||| @ contra a demonstration that prop would be a contradiction
60+ No : (contra : prop -> Void) -> Dec prop
5961
libs/prelude/Prelude/Bits.idr+2−2
@@ -6,13 +6,13 @@ import Prelude.Basics
66import Prelude.Bool
77import Prelude.Cast
88import Prelude.Chars
9−import Prelude.Classes
9+import Prelude.Interfaces
1010import Prelude.Foldable
1111import Prelude.Nat
1212import Prelude.List
1313import Prelude.Strings
1414
15−%access public
15+%access public export
1616%default total
1717
1818b8ToString : Bits8 -> String
libs/prelude/Prelude/Bool.idr+2
@@ -4,6 +4,8 @@ import Builtins
44
55import Prelude.Uninhabited
66
7+%access public export
8+
79||| Boolean Data Type
810%case data Bool = False | True
911
libs/prelude/Prelude/Cast.idr+2
@@ -3,6 +3,8 @@ module Prelude.Cast
33import Prelude.Bool
44import public Builtins
55
6+%access public export
7+
68||| Interface for transforming an instance of a data type to another type.
79interface Cast from to where
810 ||| Perform a cast operation.
libs/prelude/Prelude/Chars.idr+3−3
@@ -2,11 +2,13 @@ module Prelude.Chars
22-- Functions operating over Chars
33
44import Prelude.Bool
5−import Prelude.Classes
5+import Prelude.Interfaces
66import Prelude.List
77import Prelude.Cast
88import Builtins
99
10+%access public export
11+
1012||| Convert the number to its ASCII equivalent.
1113chr : Int -> Char
1214chr x = if (x >= 0 && x < 0x110000)
@@ -74,5 +76,3 @@ isHexDigit x = elem (toUpper x) hexChars where
7476||| Returns true if the character is an octal digit.
7577isOctDigit : Char -> Bool
7678isOctDigit x = (x >= '0' && x <= '7')
77−
78−
libs/prelude/Prelude/Doubles.idr+4−6
@@ -1,16 +1,16 @@
1−module Prelude.Doubles
1+module Prelude.Doubles
22
33import Builtins
4−import Prelude.Classes
4+import Prelude.Interfaces
55
6−%access public
6+%access public export
77%default total
88
99%include C "math.h"
1010%lib C "m"
1111
1212pi : Double
13−pi = 3.14159265358979323846
13+pi = 3.14159265358979323846
1414
1515euler : Double
1616euler = 2.7182818284590452354
@@ -59,5 +59,3 @@ floor x = prim__floatFloor x
5959
6060ceiling : Double -> Double
6161ceiling x = prim__floatCeil x
62−
63−
libs/prelude/Prelude/Either.idr+3−1
@@ -4,10 +4,12 @@ import Builtins
44
55import Prelude.Basics
66import Prelude.Bool
7−import Prelude.Classes
7+import Prelude.Interfaces
88import Prelude.Maybe
99import Prelude.List
1010
11+%access public export
12+
1113||| A sum type
1214%elim data Either : (a, b : Type) -> Type where
1315 ||| One possibility of the sum, conventionally used to represent errors
libs/prelude/Prelude/File.idr+35−8
@@ -9,15 +9,15 @@ import Prelude.Strings
99import Prelude.Cast
1010import Prelude.Bool
1111import Prelude.Basics
12−import Prelude.Classes
12+import Prelude.Interfaces
1313import Prelude.Either
1414import Prelude.Show
1515import IO
1616
17−%access public
17+%access public export
1818
1919||| A file handle
20−abstract
20+export
2121data File : Type where
2222 FHandle : (p : Ptr) -> File
2323
@@ -39,7 +39,7 @@ strError err = unsafePerformIO -- yeah, yeah...
3939 (foreign FFI_C "idris_showerror" (Int -> IO String) err)
4040
4141getFileError : IO FileError
42−getFileError = do MkRaw err <- foreign FFI_C "idris_mkFileError"
42+getFileError = do MkRaw err <- foreign FFI_C "idris_mkFileError"
4343 (Ptr -> IO (Raw FileError)) prim__vm
4444 return err
4545
@@ -49,25 +49,31 @@ Show FileError where
4949 show (GenericFileError errno) = strError errno
5050
5151||| Standard input
52+export
5253stdin : File
5354stdin = FHandle prim__stdin
5455
5556||| Standard output
57+export
5658stdout : File
5759stdout = FHandle prim__stdout
5860
5961||| Standard output
62+export
6063stderr : File
6164stderr = FHandle prim__stderr
6265
66+private
6367do_ferror : Ptr -> IO Int
6468do_ferror h = foreign FFI_C "fileError" (Ptr -> IO Int) h
6569
70+export
6671ferror : File -> IO Bool
6772ferror (FHandle h) = do err <- do_ferror h
6873 return (not (err == 0))
6974
7075||| Call the RTS's file opening function
76+private
7177do_fopen : String -> String -> IO Ptr
7278do_fopen f m
7379 = foreign FFI_C "fileOpen" (String -> String -> IO Ptr) f m
@@ -75,6 +81,7 @@ do_fopen f m
7581||| Open a file
7682||| @ f the filename
7783||| @ m the mode as a String (`"r"`, `"w"`, or `"r+"`)
84+export
7885fopen : (f : String) -> (m : String) -> IO (Either FileError File)
7986fopen f m = do h <- do_fopen f m
8087 if !(nullPtr h)
@@ -83,6 +90,7 @@ fopen f m = do h <- do_fopen f m
8390 else return (Right (FHandle h))
8491
8592||| Check whether a file handle is actually a null pointer
93+export
8694validFile : File -> IO Bool
8795validFile (FHandle h) = do x <- nullPtr h
8896 return (not x)
@@ -114,27 +122,34 @@ openFile f m = fopen f (modeStr m)
114122openFileX : (f : String) -> (m : Mode) -> IO (Either FileError File)
115123openFileX f m = fopen f $ modeStr m ++ "x"
116124
125+private
117126do_fclose : Ptr -> IO ()
118127do_fclose h = foreign FFI_C "fileClose" (Ptr -> IO ()) h
119128
129+export
120130closeFile : File -> IO ()
121131closeFile (FHandle h) = do_fclose h
122132
133+private
123134do_fread : Ptr -> IO' l String
124135do_fread h = prim_fread h
125136
137+export
126138fgetc : File -> IO (Either FileError Char)
127139fgetc (FHandle h) = do let c = cast !(foreign FFI_C "fgetc" (Ptr -> IO Int) h)
128140 if !(ferror (FHandle h))
129141 then return (Left FileReadError)
130142 else return (Right c)
131143
144+export
132145fflush : File -> IO ()
133146fflush (FHandle h) = foreign FFI_C "fflush" (Ptr -> IO ()) h
134147
148+private
135149do_popen : String -> String -> IO Ptr
136150do_popen f m = foreign FFI_C "do_popen" (String -> String -> IO Ptr) f m
137151
152+export
138153popen : String -> Mode -> IO (Either FileError File)
139154popen f m = do ptr <- do_popen f (modeStr m)
140155 if !(nullPtr ptr)
@@ -142,12 +157,14 @@ popen f m = do ptr <- do_popen f (modeStr m)
142157 return (Left err)
143158 else return (Right (FHandle ptr))
144159
160+export
145161pclose : File -> IO ()
146162pclose (FHandle h) = foreign FFI_C "pclose" (Ptr -> IO ()) h
147163
148164-- mkForeign (FFun "idris_readStr" [FPtr, FPtr] (FAny String))
149165-- prim__vm h
150166
167+export
151168fread : File -> IO (Either FileError String)
152169fread (FHandle h) = do str <- do_fread h
153170 if !(ferror (FHandle h))
@@ -156,56 +173,65 @@ fread (FHandle h) = do str <- do_fread h
156173
157174||| Read a line from a file
158175||| @h a file handle which must be open for reading
176+export
159177fGetLine : (h : File) -> IO (Either FileError String)
160178fGetLine = fread
161179
162180%deprecate fread "Use fGetLine instead"
163181
182+private
164183do_fwrite : Ptr -> String -> IO (Either FileError ())
165184do_fwrite h s = do res <- prim_fwrite h s
166185 if (res /= 0)
167186 then do errno <- getErrno
168− if errno == 0
187+ if errno == 0
169188 then return (Left FileWriteError)
170189 else do err <- getFileError
171190 return (Left err)
172191 else return (Right ())
173192
193+export
174194fwrite : File -> String -> IO (Either FileError ())
175195fwrite (FHandle h) s = do_fwrite h s
176196
177197||| Write a line to a file
178198||| @h a file handle which must be open for writing
179199||| @str the line to write to the file
200+export
180201fPutStr : (h : File) -> (str : String) -> IO (Either FileError ())
181202fPutStr (FHandle h) s = do_fwrite h s
182203
204+export
183205fPutStrLn : File -> String -> IO (Either FileError ())
184206fPutStrLn (FHandle h) s = do_fwrite h (s ++ "\n")
185207
186208%deprecate fwrite "Use fPutStr instead"
187209
210+private
188211do_feof : Ptr -> IO Int
189212do_feof h = foreign FFI_C "fileEOF" (Ptr -> IO Int) h
190213
191214||| Check if a file handle has reached the end
215+export
192216fEOF : File -> IO Bool
193217fEOF (FHandle h) = do eof <- do_feof h
194218 return (not (eof == 0))
195219
196220||| Check if a file handle has reached the end
221+export
197222feof : File -> IO Bool
198223feof = fEOF
199224
200225%deprecate feof "Use fEOF instead"
201226
227+export
202228fpoll : File -> IO Bool
203229fpoll (FHandle h) = do p <- foreign FFI_C "fpoll" (Ptr -> IO Int) h
204230 return (p > 0)
205231
206232||| Read the contents of a file into a string
207−partial -- might be reading something infinitely long like /dev/null ...
208−covering
233+partial -- might be reading something infinitely long like /dev/null ...
234+covering export
209235readFile : String -> IO (Either FileError String)
210236readFile fn = do Right h <- openFile fn Read
211237 | Left err => return (Left err)
@@ -223,7 +249,8 @@ readFile fn = do Right h <- openFile fn Read
223249 else return (Right contents)
224250
225251||| Write a string to a file
226−writeFile : (filepath : String) -> (contents : String) ->
252+export
253+writeFile : (filepath : String) -> (contents : String) ->
227254 IO (Either FileError ())
228255writeFile fn contents = do
229256 Right h <- openFile fn Write | Left err => return (Left err)
libs/prelude/Prelude/Foldable.idr+4−5
@@ -3,15 +3,15 @@ module Prelude.Foldable
33import Builtins
44import Prelude.Bool
55import Prelude.Basics
6−import Prelude.Classes
6+import Prelude.Interfaces
77import Prelude.Algebra
88
9−%access public
9+%access public export
1010%default total
1111
1212interface Foldable (t : Type -> Type) where
13− foldr : (elt -> acc -> acc) -> acc -> t elt -> acc
14− foldl : (acc -> elt -> acc) -> acc -> t elt -> acc
13+ foldr : (elem -> acc -> acc) -> acc -> t elem -> acc
14+ foldl : (acc -> elem -> acc) -> acc -> t elem -> acc
1515 foldl f z t = foldr (flip (.) . flip f) id t z
1616
1717||| Combine each element of a structure into a monoid
@@ -54,4 +54,3 @@ sum = foldr (+) 0
5454||| Multiply together all elements of a structure
5555product : (Foldable t, Num a) => t a -> a
5656product = foldr (*) 1
57−
libs/prelude/Prelude/Functor.idr+7−5
@@ -2,21 +2,23 @@ module Prelude.Functor
22
33import Prelude.Basics
44
5+%access public export
6+
57||| Functors allow a uniform action over a parameterised type.
68||| @ f a parameterised type
79interface Functor (f : Type -> Type) where
810 ||| Apply a function across everything of type 'a' in a
911 ||| parameterised type
1012 ||| @ f the parameterised type
11− ||| @ m the function to apply
12− map : (m : a -> b) -> f a -> f b
13+ ||| @ func the function to apply
14+ map : (func : a -> b) -> f a -> f b
1315
1416infixl 4 <$>
1517
1618||| An infix alias for `map`, applying a function across everything of
1719||| type 'a' in a parameterised type
1820||| @ f the parameterised type
19−||| @ m the function to apply
20−(<$>) : Functor f => (m : a -> b) -> f a -> f b
21−m <$> x = map m x
21+||| @ func the function to apply
22+(<$>) : Functor f => (func : a -> b) -> f a -> f b
23+func <$> x = map func x
2224
libs/prelude/Prelude/Interactive.idr+18−19
@@ -1,5 +1,5 @@
11||| Various helper functions for creating simple interactive systems.
2−|||
2+|||
33||| These are mostly intended for helping with teaching, in that they will allow
44||| the easy creation of interactive programs without needing to teach IO
55||| or Effects first, but they also capture some common patterns of interactive
@@ -10,7 +10,7 @@ import Builtins
1010import Prelude.List
1111import Prelude.File
1212import Prelude.Bool
13−import Prelude.Classes
13+import Prelude.Interfaces
1414import Prelude.Strings
1515import Prelude.Chars
1616import Prelude.Show
@@ -21,7 +21,7 @@ import Prelude.Either
2121import Prelude.Monad
2222import IO
2323
24−%access public
24+%access public export
2525
2626---- some basic io
2727
@@ -115,19 +115,19 @@ getArgs = do n <- numArgs
115115||| @ onEOF the function to run on reaching end of file, returning a String
116116||| to output
117117partial
118−processHandle : File ->
118+processHandle : File ->
119119 (state : a) ->
120− (onRead : a -> String -> (String, a)) ->
121− (onEOF : a -> String) ->
120+ (onRead : a -> String -> (String, a)) ->
121+ (onEOF : a -> String) ->
122122 IO ()
123−processHandle h acc onRead onEOF
123+processHandle h acc onRead onEOF
124124 = if !(fEOF h)
125125 then putStr (onEOF acc)
126126 else do Right x <- fGetLine h
127127 | Left err => putStr (onEOF acc)
128128 let (out, acc') = onRead acc x
129129 putStr out
130− processHandle h acc' onRead onEOF
130+ processHandle h acc' onRead onEOF
131131
132132||| Process input from the standard input stream, while maintaining a state.
133133||| @ state the input state
@@ -136,34 +136,33 @@ processHandle h acc onRead onEOF
136136||| @ onEOI the function to run on reaching end of input, returning a String
137137||| to output
138138partial
139−processStdin : (state : a) ->
140− (onRead : a -> String -> (String, a)) ->
139+processStdin : (state : a) ->
140+ (onRead : a -> String -> (String, a)) ->
141141 (onEOI : a -> String) -> IO ()
142142processStdin = processHandle stdin
143143
144144||| A basic read-eval-print loop, maintaining a state
145145||| @ state the input state
146−||| @ prompt the prompt to show
146+||| @ prompt the prompt to show
147147||| @ onInput the function to run on reading input, returning a String to
148148||| output and a new state. Returns Nothing if the repl should exit
149149partial
150−replWith : (state : a) -> (prompt : String) ->
150+replWith : (state : a) -> (prompt : String) ->
151151 (onInput : a -> String -> Maybe (String, a)) -> IO ()
152−replWith acc prompt fn
152+replWith acc prompt fn
153153 = do putStr prompt
154154 x <- getLine
155155 case fn acc x of
156− Just (out, acc') => do putStr out
156+ Just (out, acc') => do putStr out
157157 replWith acc' prompt fn
158158 Nothing => return ()
159159
160160||| A basic read-eval-print loop
161−||| @ prompt the prompt to show
161+||| @ prompt the prompt to show
162162||| @ onInput the function to run on reading input, returning a String to
163−||| output
163+||| output
164164partial
165−repl : (prompt : String) ->
165+repl : (prompt : String) ->
166166 (onInput : String -> String) -> IO ()
167−repl prompt fn
167+repl prompt fn
168168 = replWith () prompt (\x, s => Just (fn s, ()))
169−
libs/prelude/Prelude/Classes.idr → libs/prelude/Prelude/Interfaces.idrrenamed+11−11
@@ -1,9 +1,11 @@
1−module Prelude.Classes
1+module Prelude.Interfaces
22
33import Builtins
44import Prelude.Basics
55import Prelude.Bool
66
7+%access public export
8+
79-- Numerical Operator Precedence
810infixl 5 ==, /=
911infixl 6 <, <=, >, >=
@@ -57,7 +59,7 @@ Eq Bool where
5759 True == False = False
5860 False == True = False
5961 False == False = True
60−
62+
6163(Eq a, Eq b) => Eq (a, b) where
6264 (==) (a, c) (b, d) = (a == b) && (c == d)
6365
@@ -357,7 +359,7 @@ divB8 x y = case y == 0 of
357359modB8 : Bits8 -> Bits8 -> Bits8
358360modB8 x y = case y == 0 of
359361 False => prim__sremB8 x y
360−
362+
361363Integral Bits8 where
362364 div = divB8
363365 mod = modB8
@@ -372,8 +374,8 @@ modB16 x y = case y == 0 of
372374 False => prim__sremB16 x y
373375
374376Integral Bits16 where
375− div = divB16
376− mod = modB16
377+ div = divB16
378+ mod = modB16
377379
378380-- ------------------------------------------------------------------ [ Bits32 ]
379381divB32 : Bits32 -> Bits32 -> Bits32
@@ -385,8 +387,8 @@ modB32 x y = case y == 0 of
385387 False => prim__sremB32 x y
386388
387389Integral Bits32 where
388− div = divB32
389− mod = modB32
390+ div = divB32
391+ mod = modB32
390392
391393-- ------------------------------------------------------------------ [ Bits64 ]
392394divB64 : Bits64 -> Bits64 -> Bits64
@@ -398,7 +400,5 @@ modB64 x y = case y == 0 of
398400 False => prim__sremB64 x y
399401
400402Integral Bits64 where
401− div = divB64
402− mod = modB64
403−
404−
403+ div = divB64
404+ mod = modB64
libs/prelude/Prelude/List.idr+5−6
@@ -5,14 +5,14 @@ import Builtins
55import Prelude.Algebra
66import Prelude.Basics
77import Prelude.Bool
8−import Prelude.Classes
8+import Prelude.Interfaces
99import Prelude.Foldable
1010import Prelude.Functor
1111import Prelude.Maybe
1212import Prelude.Uninhabited
1313import Prelude.Nat
1414
15−%access public
15+%access public export
1616%default total
1717
1818infix 5 \\
@@ -174,7 +174,7 @@ init' [] = Nothing
174174init' (x::xs) =
175175 case xs of
176176 [] => Just []
177− y::ys =>
177+ y::ys =>
178178 case init' $ y::ys of
179179 Nothing => Nothing
180180 Just j => Just $ x :: j
@@ -305,7 +305,7 @@ zipWith f (x::xs) (y::ys) = f x y :: zipWith f xs ys
305305||| @ z the third list
306306zipWith3 : (f : a -> b -> c -> d) -> (x : List a) -> (y : List b) ->
307307 (z : List c) -> List d
308−zipWith3 f _ [] (z::zs) = []
308+zipWith3 f _ [] (z::zs) = []
309309zipWith3 f _ (y::ys) [] = []
310310zipWith3 f [] (y::ys) _ = []
311311zipWith3 f (x::xs) [] _ = []
@@ -761,7 +761,7 @@ mergeBy : (a -> a -> Ordering) -> List a -> List a -> List a
761761mergeBy order [] right = right
762762mergeBy order left [] = left
763763mergeBy order (x::xs) (y::ys) =
764− if order x y == LT
764+ if order x y == LT
765765 then x :: mergeBy order xs (y::ys)
766766 else y :: mergeBy order (x::xs) ys
767767
@@ -888,4 +888,3 @@ foldlAsFoldr f z t = foldr (flip (.) . flip f) id t z
888888foldlMatchesFoldr : (f : b -> a -> b) -> (q : b) -> (xs : List a) -> foldl f q xs = foldlAsFoldr f q xs
889889foldlMatchesFoldr f q [] = Refl
890890foldlMatchesFoldr f q (x :: xs) = foldlMatchesFoldr f (f q x) xs
891−
libs/prelude/Prelude/Maybe.idr+2−2
@@ -5,10 +5,10 @@ import Prelude.Algebra
55import Prelude.Basics
66import Prelude.Bool
77import Prelude.Cast
8−import Prelude.Classes
8+import Prelude.Interfaces
99import Prelude.Foldable
1010
11−%access public
11+%access public export
1212%default total
1313
1414||| An optional value. This can be used to represent the possibility of
libs/prelude/Prelude/Monad.idr+1−1
@@ -8,7 +8,7 @@ import Prelude.Applicative
88import Prelude.Basics
99import IO
1010
11−%access public
11+%access public export
1212
1313infixl 5 >>=
1414
libs/prelude/Prelude/Nat.idr+18−19
@@ -6,10 +6,10 @@ import Prelude.Algebra
66import Prelude.Basics
77import Prelude.Bool
88import Prelude.Cast
9−import Prelude.Classes
9+import Prelude.Interfaces
1010import Prelude.Uninhabited
1111
12−%access public
12+%access public export
1313%default total
1414
1515||| Natural numbers: unbounded, unsigned integers which can be pattern
@@ -224,9 +224,9 @@ record Multiplicative where
224224
225225||| A wrapper for Nat that specifies the semigroup and monad implementations that use (+)
226226record Additive where
227− constructor GetAdditive
227+ constructor GetAdditive
228228 _ : Nat
229−
229+
230230Semigroup Multiplicative where
231231 (<+>) left right = GetMultiplicative $ left' * right'
232232 where
@@ -424,7 +424,7 @@ total plusCommutative : (left : Nat) -> (right : Nat) ->
424424plusCommutative Z right = rewrite plusZeroRightNeutral right in Refl
425425plusCommutative (S left) right =
426426 let inductiveHypothesis = plusCommutative left right in
427− rewrite inductiveHypothesis in
427+ rewrite inductiveHypothesis in
428428 rewrite plusSuccRightSucc right left in Refl
429429
430430total plusAssociative : (left : Nat) -> (centre : Nat) -> (right : Nat) ->
@@ -450,21 +450,21 @@ total plusLeftCancel : (left : Nat) -> (right : Nat) -> (right' : Nat) ->
450450plusLeftCancel Z right right' p = p
451451plusLeftCancel (S left) right right' p =
452452 let inductiveHypothesis = plusLeftCancel left right right' in
453− inductiveHypothesis (succInjective _ _ p)
453+ inductiveHypothesis (succInjective _ _ p)
454454
455455total plusRightCancel : (left : Nat) -> (left' : Nat) -> (right : Nat) ->
456456 (p : left + right = left' + right) -> left = left'
457457plusRightCancel left left' Z p = rewrite sym (plusZeroRightNeutral left) in
458458 rewrite sym (plusZeroRightNeutral left') in
459− p
459+ p
460460plusRightCancel left left' (S right) p =
461− plusRightCancel left left' right
462− (succInjective _ _ (rewrite plusSuccRightSucc left right in
461+ plusRightCancel left left' right
462+ (succInjective _ _ (rewrite plusSuccRightSucc left right in
463463 rewrite plusSuccRightSucc left' right in p))
464464
465465total plusLeftLeftRightZero : (left : Nat) -> (right : Nat) ->
466466 (p : left + right = left) -> right = Z
467−plusLeftLeftRightZero Z right p = p
467+plusLeftLeftRightZero Z right p = p
468468plusLeftLeftRightZero (S left) right p =
469469 plusLeftLeftRightZero left right (succInjective _ _ p)
470470
@@ -481,7 +481,7 @@ total multRightSuccPlus : (left : Nat) -> (right : Nat) ->
481481multRightSuccPlus Z right = Refl
482482multRightSuccPlus (S left) right =
483483 let inductiveHypothesis = multRightSuccPlus left right in
484− rewrite inductiveHypothesis in
484+ rewrite inductiveHypothesis in
485485 rewrite plusAssociative left right (mult left right) in
486486 rewrite plusAssociative right left (mult left right) in
487487 rewrite plusCommutative right left in
@@ -493,11 +493,11 @@ multLeftSuccPlus left right = Refl
493493
494494total multCommutative : (left : Nat) -> (right : Nat) ->
495495 left * right = right * left
496−multCommutative Z right = rewrite multZeroRightZero right in Refl
496+multCommutative Z right = rewrite multZeroRightZero right in Refl
497497multCommutative (S left) right =
498498 let inductiveHypothesis = multCommutative left right in
499499 rewrite inductiveHypothesis in
500− rewrite multRightSuccPlus right left in
500+ rewrite multRightSuccPlus right left in
501501 Refl
502502
503503total multDistributesOverPlusRight : (left : Nat) -> (centre : Nat) -> (right : Nat) ->
@@ -505,7 +505,7 @@ total multDistributesOverPlusRight : (left : Nat) -> (centre : Nat) -> (right :
505505multDistributesOverPlusRight Z centre right = Refl
506506multDistributesOverPlusRight (S left) centre right =
507507 let inductiveHypothesis = multDistributesOverPlusRight left centre right in
508− rewrite inductiveHypothesis in
508+ rewrite inductiveHypothesis in
509509 rewrite plusAssociative (plus centre (mult left centre)) right (mult left right) in
510510 rewrite sym (plusAssociative centre (mult left centre) right) in
511511 rewrite plusCommutative (mult left centre) right in
@@ -527,7 +527,7 @@ total multAssociative : (left : Nat) -> (centre : Nat) -> (right : Nat) ->
527527multAssociative Z centre right = Refl
528528multAssociative (S left) centre right =
529529 let inductiveHypothesis = multAssociative left centre right in
530− rewrite inductiveHypothesis in
530+ rewrite inductiveHypothesis in
531531 rewrite multDistributesOverPlusLeft centre (mult left centre) right in
532532 Refl
533533
@@ -619,7 +619,7 @@ powerSuccPowerLeft base exp = Refl
619619
620620total multPowerPowerPlus : (base : Nat) -> (exp : Nat) -> (exp' : Nat) ->
621621 (power base exp) * (power base exp') = power base (exp + exp')
622−multPowerPowerPlus base Z exp' =
622+multPowerPowerPlus base Z exp' =
623623 rewrite sym (plusZeroRightNeutral (power base exp')) in Refl
624624multPowerPowerPlus base (S exp) exp' =
625625 let inductiveHypothesis = multPowerPowerPlus base exp exp' in
@@ -651,7 +651,7 @@ total powerPowerMultPower : (base : Nat) -> (exp : Nat) -> (exp' : Nat) ->
651651powerPowerMultPower base exp Z = rewrite multZeroRightZero exp in Refl
652652powerPowerMultPower base exp (S exp') =
653653 let inductiveHypothesis = powerPowerMultPower base exp exp' in
654− rewrite inductiveHypothesis in
654+ rewrite inductiveHypothesis in
655655 rewrite multRightSuccPlus exp exp' in
656656 rewrite sym (multPowerPowerPlus base exp (mult exp exp')) in
657657 Refl
@@ -664,7 +664,7 @@ total minusSuccPred : (left : Nat) -> (right : Nat) ->
664664 minus left (S right) = pred (minus left right)
665665minusSuccPred Z right = Refl
666666minusSuccPred (S left) Z =
667− rewrite minusZeroRight left in Refl
667+ rewrite minusZeroRight left in Refl
668668minusSuccPred (S left) (S right) =
669669 let inductiveHypothesis = minusSuccPred left right in
670670 rewrite inductiveHypothesis in Refl
@@ -782,4 +782,3 @@ sucMinL (S l) = cong (sucMinL l)
782782total sucMinR : (l : Nat) -> minimum l (S l) = l
783783sucMinR Z = Refl
784784sucMinR (S l) = cong (sucMinR l)
785−
libs/prelude/Prelude/Pairs.idr+1−1
@@ -2,7 +2,7 @@ module Prelude.Pairs
22
33import Builtins
44
5−%access public
5+%access public export
66%default total
77
88swap : (a, b) -> (b, a)
libs/prelude/Prelude/Providers.idr+3−1
@@ -4,8 +4,10 @@ import Prelude.Functor
44import Prelude.Applicative
55import Prelude.Monad
66
7+%access public export
8+
79||| Type providers must build one of these in an IO computation.
8−public
10+public export
911data Provider : (a : Type) -> Type where
1012 ||| Return a term to be spliced in
1113 ||| @ x the term to be spliced (i.e. the proof)
libs/prelude/Prelude/Show.idr+3−2
@@ -7,13 +7,15 @@ import Prelude.Bits
77import Prelude.Bool
88import Prelude.Cast
99import Prelude.Chars
10−import Prelude.Classes
10+import Prelude.Interfaces
1111import Prelude.List
1212import Prelude.Maybe
1313import Prelude.Either
1414import Prelude.Nat
1515import Prelude.Strings
1616
17+%access public export
18+
1719%default total
1820
1921||| The precedence of an Idris operator or syntactic context.
@@ -192,4 +194,3 @@ Show a => Show (Maybe a) where
192194
193195(Show a, {y : a} -> Show (p y)) => Show (Sigma a p) where
194196 show (y ** prf) = "(" ++ show y ++ " ** " ++ show prf ++ ")"
195−
libs/prelude/Prelude/Stream.idr+1−1
@@ -9,7 +9,7 @@ import Prelude.Monad
99import Prelude.Nat
1010import Prelude.List
1111
12−%access public
12+%access public export
1313%default total
1414
1515||| An infinite stream
libs/prelude/Prelude/Strings.idr+4−3
@@ -8,7 +8,7 @@ import Prelude.Basics
88import Prelude.Bool
99import Prelude.Chars
1010import Prelude.Cast
11−import Prelude.Classes
11+import Prelude.Interfaces
1212import Prelude.Either
1313import Prelude.Foldable
1414import Prelude.Functor
@@ -17,6 +17,8 @@ import Prelude.Nat
1717import Prelude.Monad
1818import Decidable.Equality
1919
20+%access public export
21+
2022partial
2123foldr1 : (a -> a -> a) -> List a -> a
2224foldr1 _ [x] = x
@@ -112,7 +114,7 @@ strTail' x p = assert_total $ prim__strTail x
112114-- we need the 'believe_me' because the operations are primitives
113115strM : (x : String) -> StrM x
114116strM x with (decEq (not (x == "")) True)
115− strM x | (Yes p) = really_believe_me $
117+ strM x | (Yes p) = really_believe_me $
116118 StrCons (assert_total (strHead' x p))
117119 (assert_total (strTail' x p))
118120 strM x | (No p) = really_believe_me StrNil
@@ -364,4 +366,3 @@ partial
364366nullStr : String -> IO Bool
365367nullStr p = do ok <- foreign FFI_C "isNull" (String -> IO Int) p
366368 return (ok /= 0)
367−
libs/prelude/Prelude/Traversable.idr+2
@@ -7,6 +7,8 @@ import Prelude.Applicative
77import Prelude.Foldable
88import Prelude.Functor
99
10+%access public export
11+
1012traverse_ : (Foldable t, Applicative f) => (a -> f b) -> t a -> f ()
1113traverse_ f = foldr ((*>) . f) (pure ())
1214
libs/prelude/Prelude/Uninhabited.idr+2
@@ -5,6 +5,8 @@ module Prelude.Uninhabited
55
66import Builtins
77
8+%access public export
9+
810||| A canonical proof that some type is empty
911interface Uninhabited t where
1012 ||| If I have a t, I've had a contradiction
libs/prelude/prelude.ipkg+1−2
@@ -4,7 +4,7 @@ opts = "--nobuiltins --total --no-elim-deprecation-warnings"
44modules = Builtins, Prelude, IO,
55
66 Prelude.Algebra, Prelude.Basics, Prelude.Bool, Prelude.Cast,
7− Prelude.Classes, Prelude.Nat, Prelude.List,
7+ Prelude.Interfaces, Prelude.Nat, Prelude.List,
88 Prelude.Maybe, Prelude.Monad, Prelude.Applicative, Prelude.Either,
99 Prelude.Strings, Prelude.Chars, Prelude.Show, Prelude.Functor,
1010 Prelude.Foldable, Prelude.Traversable, Prelude.Bits, Prelude.Stream,
@@ -14,4 +14,3 @@ modules = Builtins, Prelude, IO,
1414 Language.Reflection, Language.Reflection.Errors, Language.Reflection.Elab,
1515
1616 Decidable.Equality
17−
libs/pruviloj/Pruviloj/Core.idr+2
@@ -5,6 +5,8 @@ module Pruviloj.Core
55
66import Language.Reflection.Utils
77
8+%access public export
9+
810||| Run something for effects, throwing away the return value
911ignore : Functor f => f a -> f ()
1012ignore x = map (const ()) x
libs/pruviloj/Pruviloj/Derive/DecEq.idr+1−1
@@ -133,7 +133,7 @@ mkRhs fn fam k =
133133||| equality.
134134|||
135135||| @ fn the name of the function whose type has been declared
136−abstract partial -- because of mkRhs
136+export partial -- because of mkRhs
137137deriveDecEq : (fn : TTName) -> Elab ()
138138deriveDecEq fn =
139139 do (_, Ref, sig') <- lookupTyExact fn
libs/pruviloj/Pruviloj/Derive/Eliminators.idr+1−1
@@ -248,7 +248,7 @@ getElimClauses info elimn ctors =
248248 in traverse (\(i, con) => getElimClause info elimn methodCount con i)
249249 (enumerate ctors)
250250
251−abstract
251+export
252252deriveElim : (tyn, elimn : TTName) -> Elab ()
253253deriveElim tyn elimn =
254254 do -- Begin with some basic sanity checking: the type name uniquely
libs/pruviloj/Pruviloj/Disjoint.idr+1−1
@@ -67,7 +67,7 @@ getDisjointness l r = exists <|> declare
6767
6868||| Solve a goal of the form `(C1 x1 x2 ... xn = C2 x1 x2 ... xn) ->
6969||| Void` for disjoint constructors `C1` and `C2`.
70−public covering
70+public export covering
7171disjoint : Elab ()
7272disjoint =
7373 do compute
libs/pruviloj/Pruviloj/Induction.idr+1−1
@@ -125,7 +125,7 @@ makeMotive info sub subjTy goal =
125125
126126||| Perform induction on some expression to solve the current
127127||| goal. Return a list of new holes to be solved.
128−public
128+public export
129129induction : Raw -> Elab (List TTName)
130130induction subj =
131131 do g <- goalType
libs/pruviloj/Pruviloj/Injective.idr+1−1
@@ -92,7 +92,7 @@ countBinders _ = Z
9292|||
9393||| @ tm the equality to exploit injectivity on
9494||| @ n the name at which to bind the result
95−covering public
95+covering public export
9696injective : (tm : Raw) -> (n : TTName) -> Elab ()
9797injective tm n =
9898 do (_, ty) <- check !getEnv tm
libs/pruviloj/Pruviloj/Internals.idr+2
@@ -7,6 +7,8 @@ import Pruviloj.Renamers
77
88import Data.Vect
99
10+%access public export
11+
1012||| Get the name of a reflected type constructor argument.
1113tyConArgName : TyConArg -> TTName
1214tyConArgName (TyConParameter a) = name a
libs/pruviloj/Pruviloj/Internals/TyConInfo.idr+1−1
@@ -6,7 +6,7 @@ import Pruviloj.Renamers
66
77import Language.Reflection.Utils
88
9−
9+%access public export
1010
1111||| A representation of a type constructor in which all argument names
1212||| are made unique and they are separated into params and then
libs/pruviloj/Pruviloj/Renamers.idr+2
@@ -2,6 +2,8 @@ module Pruviloj.Renamers
22
33import Language.Reflection.Utils
44
5+%access public export
6+
57||| A renamer keeps track of names to be substituted
68Renamer : Type
79Renamer = TTName -> Maybe TTName
samples/tutorial/interp.idr+1−1
@@ -33,7 +33,7 @@ using (G : Vect n Ty)
3333 Expr G c
3434 If : Expr G TyBool -> Lazy (Expr G a) -> Lazy (Expr G a) -> Expr G a
3535
36− interp : Env G -> [static] (e : Expr G t) -> interpTy t
36+ interp : Env G -> %static (e : Expr G t) -> interpTy t
3737 interp env (Var i) = lookup i env
3838 interp env (Val x) = x
3939 interp env (Lam sc) = \x => interp (x :: env) sc
src/IRTS/Compiler.hs+1−1
@@ -462,7 +462,7 @@ doForeign vs env (ret : fname : world : args)
462462 = do let l' = toFDesc l
463463 r' <- irTerm vs env r
464464 return (l', r')
465− splitArg _ = ifail "Badly formed foreign function call"
465+ splitArg _ = ifail $ "Badly formed foreign function call"
466466
467467 toFDesc (Constant (Str str)) = FStr str
468468 toFDesc tm
src/IRTS/System.hs+3−7
@@ -21,10 +21,7 @@ getCC :: IO String
2121getCC = fromMaybe "gcc" <$> environment "IDRIS_CC"
2222
2323getEnvFlags :: IO [String]
24−getEnvFlags = do flags <- environment "IDRIS_CFLAGS"
25− case flags of
26− Nothing -> return $ []
27− Just s -> return $ splitOn " " s
24+getEnvFlags = maybe [] (splitOn " ") <$> environment "IDRIS_CFLAGS"
2825
2926mvnCommand :: String
3027#ifdef mingw32_HOST_OS
@@ -37,9 +34,8 @@ getMvn :: IO String
3734getMvn = fromMaybe mvnCommand <$> environment "IDRIS_MVN"
3835
3936environment :: String -> IO (Maybe String)
40−environment x = catchIO (do e <- getEnv x
41− return (Just e))
42− (\_ -> return Nothing)
37+environment x = catchIO (Just <$> getEnv x)
38+ (\_ -> return Nothing)
4339
4440getTargetDir :: IO String
4541getTargetDir = environment "TARGET" >>= maybe getDataDir return
src/Idris/ASTUtils.hs+1−4
@@ -118,17 +118,14 @@ opt_detaggable = Field detaggable (\v opt -> opt{ detaggable = v })
118118ist_callgraph :: Name -> Field IState CGInfo
119119ist_callgraph n =
120120 maybe_default CGInfo
121− { argsdef = [], calls = [], scg = []
122− , argsused = [], usedpos = []
121+ { calls = [], scg = [], usedpos = []
123122 }
124123 . ctxt_lookup n
125124 . Field idris_callgraph (\v ist -> ist{ idris_callgraph = v })
126125
127−-- some fields of the CGInfo record
128126cg_usedpos :: Field CGInfo [(Int, [UsageReason])]
129127cg_usedpos = Field usedpos (\v cg -> cg{ usedpos = v })
130128
131−
132129-- Commandline flags
133130--------------------
134131
src/Idris/AbsSyntax.hs+47−11
@@ -96,6 +96,33 @@ addAutoImport fp = do i <- getIState
9696 put (i { idris_options = opts { opt_autoImport =
9797 fp : opt_autoImport opts } } )
9898
99+addDefinedName :: Name -> Idris ()
100+addDefinedName n = do ist <- getIState
101+ putIState $ ist { idris_inmodule = S.insert n (idris_inmodule ist) }
102+
103+getDefinedNames :: Idris [Name]
104+getDefinedNames = do ist <- getIState
105+ return (S.toList (idris_inmodule ist))
106+
107+addTT :: Term -> Idris (Maybe Term)
108+addTT t = do ist <- getIState
109+ case M.lookup t (idris_ttstats ist) of
110+ Nothing -> do let tt' = M.insert t (1, t) (idris_ttstats ist)
111+ putIState $ ist { idris_ttstats = tt' }
112+ return Nothing
113+ Just (i, t') -> do let tt' = M.insert t' (i + 1, t') (idris_ttstats ist)
114+ putIState $ ist { idris_ttstats = tt' }
115+ return (Just t')
116+
117+dumpTT :: Idris ()
118+dumpTT = do ist <- get
119+ let sts = sortBy count (M.toList (idris_ttstats ist))
120+ mapM_ dump sts
121+ return ()
122+ where
123+ count (_,x) (_,y) = compare y x
124+ dump (tm, val) = runIO $ putStrLn (show val ++ ": " ++ show tm)
125+
99126addHdr :: Codegen -> String -> Idris ()
100127addHdr tgt f = do i <- getIState; putIState $ i { idris_hdrs = nub $ (tgt, f) : idris_hdrs i }
101128
@@ -180,6 +207,11 @@ setAccessibility n a
180207 let ctxt = setAccess n a (tt_ctxt i)
181208 putIState $ i { tt_ctxt = ctxt }
182209
210+-- | get the accessibility of a name outside this module
211+getFromHideList :: Name -> Idris (Maybe Accessibility)
212+getFromHideList n = do i <- getIState
213+ return $ lookupCtxtExact n (hide_list i)
214+
183215setTotality :: Name -> Totality -> Idris ()
184216setTotality n a
185217 = do i <- getIState
@@ -213,6 +245,14 @@ addToCG n cg
213245 = do i <- getIState
214246 putIState $ i { idris_callgraph = addDef n cg (idris_callgraph i) }
215247
248+addCalls :: Name -> [Name] -> Idris ()
249+addCalls n calls
250+ = do i <- getIState
251+ case lookupCtxtExact n (idris_callgraph i) of
252+ Nothing -> addToCG n (CGInfo calls [] [])
253+ Just (CGInfo cs scg used) ->
254+ addToCG n (CGInfo (nub (calls ++ cs)) scg used)
255+
216256addTyInferred :: Name -> Idris ()
217257addTyInferred n
218258 = do i <- getIState
@@ -309,7 +349,7 @@ allNames :: [Name] -> Name -> Idris [Name]
309349allNames ns n | n `elem` ns = return []
310350allNames ns n = do i <- getIState
311351 case lookupCtxtExact n (idris_callgraph i) of
312− Just ns' -> do more <- mapM (allNames (n:ns)) (map fst (calls ns'))
352+ Just ns' -> do more <- mapM (allNames (n:ns)) (calls ns')
313353 return (nub (n : concat more))
314354 _ -> return [n]
315355
@@ -341,11 +381,6 @@ getNameHints i n =
341381 [ns] -> ns
342382 _ -> []
343383
344−-- Issue #1737 in the Issue Tracker.
345−-- https://github.com/idris-lang/Idris-dev/issues/1737
346−addToCalledG :: Name -> [Name] -> Idris ()
347−addToCalledG n ns = return () -- TODO
348−
349384addDeprecated :: Name -> String -> Idris ()
350385addDeprecated n reason = do i <- getIState
351386 putIState $ i { idris_deprecated = addDef n reason (idris_deprecated i) }
@@ -439,7 +474,8 @@ addIBC ibc@(IBCDef n)
439474addIBC ibc = do i <- getIState; putIState $ i { ibc_write = ibc : ibc_write i }
440475
441476clearIBC :: Idris ()
442−clearIBC = do i <- getIState; putIState $ i { ibc_write = [] }
477+clearIBC = do i <- getIState; putIState $ i { ibc_write = [],
478+ idris_inmodule = S.empty }
443479
444480resetNameIdx :: Idris ()
445481resetNameIdx = do i <- getIState
@@ -1227,10 +1263,10 @@ expandParamsD rhs ist dec ps ns (PClass doc info f cs n nfc params pDocs fds dec
12271263 (map (expandParamsD rhs ist dec ps ns) decls)
12281264 cn
12291265 cd
1230−expandParamsD rhs ist dec ps ns (PInstance doc argDocs info f cs n nfc params ty cn decls)
1266+expandParamsD rhs ist dec ps ns (PInstance doc argDocs info f cs acc n nfc params ty cn decls)
12311267 = PInstance doc argDocs info f
12321268 (map (\ (n, t) -> (n, expandParams dec ps ns [] t)) cs)
1233− n
1269+ acc n
12341270 nfc
12351271 (map (expandParams dec ps ns []) params)
12361272 (expandParams dec ps ns [] ty)
@@ -1537,9 +1573,9 @@ implicitise syn ignore ist tm = -- trace ("INCOMING " ++ showImp True tm) $
15371573 implNamesIn uv (PApp fc f args) = concatMap (implNamesIn uv) (map getTm args)
15381574 implNamesIn uv t = namesIn uv ist t
15391575
1540− imps top env (PApp _ f as)
1576+ imps top env ty@(PApp _ f as)
15411577 = do (decls, ns) <- get
1542− let isn = concatMap (namesIn uvars ist) (map getTm as)
1578+ let isn = nub (implNamesIn uvars ty)
15431579 put (decls, nub (ns ++ (isn `dropAll` (env ++ map fst (getImps decls)))))
15441580 imps top env (PPi (Imp l _ _ _) n _ ty sc)
15451581 = do let isn = nub (implNamesIn uvars ty) `dropAll` [n]
src/Idris/AbsSyntaxTree.hs+21−18
@@ -194,7 +194,6 @@ data IState = IState {
194194 -- ^ list of lhs/rhs, and a list of missing clauses
195195 idris_flags :: Ctxt [FnOpt],
196196 idris_callgraph :: Ctxt CGInfo, -- name, args used in each pos
197− idris_calledgraph :: Ctxt [Name],
198197 idris_docstrings :: Ctxt (Docstring DocTerm, [(Name, Docstring DocTerm)]),
199198 idris_moduledocs :: Ctxt (Docstring DocTerm),
200199 -- ^ module documentation is saved in a special MN so the context
@@ -235,7 +234,7 @@ data IState = IState {
235234 brace_stack :: [Maybe Int],
236235 lastTokenSpan :: Maybe FC, -- ^ What was the span of the latest token parsed?
237236 idris_parsedSpan :: Maybe FC,
238− hide_list :: [(Name, Maybe Accessibility)],
237+ hide_list :: Ctxt Accessibility,
239238 default_access :: Accessibility,
240239 default_total :: Bool,
241240 ibc_write :: [IBCWrite],
@@ -262,7 +261,9 @@ data IState = IState {
262261 idris_exports :: [Name], -- ^ Functions with ExportList
263262 idris_highlightedRegions :: [(FC, OutputAnnotation)], -- ^ Highlighting information to output
264263 idris_parserHighlights :: [(FC, OutputAnnotation)], -- ^ Highlighting information from the parser
265− idris_deprecated :: Ctxt String -- ^ Deprecated names and explanation
264+ idris_deprecated :: Ctxt String, -- ^ Deprecated names and explanation
265+ idris_inmodule :: S.Set Name, -- ^ Names defined in current module
266+ idris_ttstats :: M.Map Term (Int, Term)
266267 }
267268
268269-- Required for parsers library, and therefore trifecta
@@ -279,11 +280,10 @@ deriving instance NFData SizeChange
279280type SCGEntry = (Name, [Maybe (Int, SizeChange)])
280281type UsageReason = (Name, Int) -- fn_name, its_arg_number
281282
282−data CGInfo = CGInfo { argsdef :: [Name],
283− calls :: [(Name, [[Name]])],
283+data CGInfo = CGInfo { calls :: [Name],
284284 scg :: [SCGEntry],
285− argsused :: [Name],
286− usedpos :: [(Int, [UsageReason])] }
285+ usedpos :: [(Int, [UsageReason])]
286+ }
287287 deriving Show
288288{-!
289289deriving instance Binary CGInfo
@@ -348,12 +348,13 @@ idrisInit = IState initContext S.empty []
348348 emptyContext emptyContext emptyContext emptyContext
349349 emptyContext emptyContext emptyContext emptyContext
350350 emptyContext emptyContext emptyContext emptyContext
351− emptyContext emptyContext
351+ emptyContext
352352 [] [] [] defaultOpts 6 [] [] [] [] emptySyntaxRules [] [] [] [] [] [] []
353− [] [] Nothing [] Nothing [] [] Nothing Nothing [] Hidden False [] Nothing [] []
353+ [] [] Nothing [] Nothing [] [] Nothing Nothing emptyContext Hidden False [] Nothing [] []
354354 (RawOutput stdout) True defaultTheme [] (0, emptyContext) emptyContext M.empty
355355 AutomaticWidth S.empty S.empty [] Nothing Nothing [] [] M.empty [] [] []
356− emptyContext
356+ emptyContext S.empty M.empty
357+
357358
358359-- | The monad for the main REPL - reading and processing files and updating
359360-- global state (hence the IO inner monad).
@@ -393,6 +394,7 @@ data Command = Quit
393394 | DocStr (Either Name Const) HowMuchDocs
394395 | TotCheck Name
395396 | Reload
397+ | Watch
396398 | Load FilePath (Maybe Int) -- up to maximum line number
397399 | ChangeDirectory FilePath
398400 | ModImport String
@@ -716,6 +718,7 @@ data PDecl' t
716718 [(Name, Docstring (Either Err t))] -- Parameter docs
717719 SyntaxInfo
718720 FC [(Name, t)] -- constraints
721+ Accessibility
719722 Name -- class
720723 FC -- precise location of class
721724 [t] -- parameters
@@ -874,10 +877,10 @@ mapPDeclFC f g (PClass doc syn fc constrs n nfc params paramDocs det body ctor c
874877 (map (mapPDeclFC f g) body)
875878 (fmap (\(n, nfc) -> (n, g nfc)) ctor)
876879 ctorDoc
877−mapPDeclFC f g (PInstance doc paramDocs syn fc constrs cn cnfc params instTy instN body) =
880+mapPDeclFC f g (PInstance doc paramDocs syn fc constrs cn acc cnfc params instTy instN body) =
878881 PInstance doc paramDocs syn (f fc)
879882 (map (\(constrN, constrT) -> (constrN, mapPTermFC f g constrT)) constrs)
880− cn (g cnfc) (map (mapPTermFC f g) params)
883+ cn acc (g cnfc) (map (mapPTermFC f g) params)
881884 (mapPTermFC f g instTy)
882885 instN
883886 (map (mapPDeclFC f g) body)
@@ -917,7 +920,7 @@ declared (PParams _ _ ds) = concatMap declared ds
917920declared (PNamespace _ _ ds) = concatMap declared ds
918921declared (PRecord _ _ _ _ n _ _ _ _ cn _ _) = n : map fst (maybeToList cn)
919922declared (PClass _ _ _ _ n _ _ _ _ ms cn cd) = n : (map fst (maybeToList cn) ++ concatMap declared ms)
920−declared (PInstance _ _ _ _ _ _ _ _ _ _ _) = []
923+declared (PInstance _ _ _ _ _ _ _ _ _ _ _ _) = []
921924declared (PDSL n _) = [n]
922925declared (PSyntax _ _) = []
923926declared (PMutual _ ds) = concatMap declared ds
@@ -937,7 +940,7 @@ tldeclared (PParams _ _ ds) = []
937940tldeclared (PMutual _ ds) = concatMap tldeclared ds
938941tldeclared (PNamespace _ _ ds) = concatMap tldeclared ds
939942tldeclared (PClass _ _ _ _ n _ _ _ _ ms cn _) = n : (map fst (maybeToList cn) ++ concatMap tldeclared ms)
940−tldeclared (PInstance _ _ _ _ _ _ _ _ _ _ _) = []
943+tldeclared (PInstance _ _ _ _ _ _ _ _ _ _ _ _) = []
941944tldeclared _ = []
942945
943946defined :: PDecl -> [Name]
@@ -953,7 +956,7 @@ defined (PParams _ _ ds) = concatMap defined ds
953956defined (PNamespace _ _ ds) = concatMap defined ds
954957defined (PRecord _ _ _ _ n _ _ _ _ cn _ _) = n : map fst (maybeToList cn)
955958defined (PClass _ _ _ _ n _ _ _ _ ms cn _) = n : (map fst (maybeToList cn) ++ concatMap defined ms)
956−defined (PInstance _ _ _ _ _ _ _ _ _ _ _) = []
959+defined (PInstance _ _ _ _ _ _ _ _ _ _ _ _) = []
957960defined (PDSL n _) = [n]
958961defined (PSyntax _ _) = []
959962defined (PMutual _ ds) = concatMap defined ds
@@ -1737,7 +1740,7 @@ pprintPTerm ppo bnd docArgs infixes = prettySe (ppopt_depth ppo) startPrec bnd
17371740
17381741 st =
17391742 case s of
1740− Static -> text "[static]" <> space
1743+ Static -> text "%static" <> space
17411744 _ -> empty
17421745 prettySe d p bnd (PPi (Imp l s _ fa) n _ ty sc)
17431746 | ppopt_impl ppo =
@@ -1748,7 +1751,7 @@ pprintPTerm ppo bnd docArgs infixes = prettySe (ppopt_depth ppo) startPrec bnd
17481751 where
17491752 st =
17501753 case s of
1751− Static -> text "[static]" <> space
1754+ Static -> text "%static" <> space
17521755 _ -> empty
17531756 prettySe d p bnd (PPi (Constraint _ _) n _ ty sc) =
17541757 depth d . bracket p startPrec $
@@ -2108,7 +2111,7 @@ showDeclImp o (PNamespace n fc ps) = text "namespace" <+> text n <> braces (line
21082111showDeclImp _ (PSyntax _ syn) = text "syntax" <+> text (show syn)
21092112showDeclImp o (PClass _ _ _ cs n _ ps _ _ ds _ _)
21102113 = text "interface" <+> text (show cs) <+> text (show n) <+> text (show ps) <> line <> showDecls o ds
2111−showDeclImp o (PInstance _ _ _ _ cs n _ _ t _ ds)
2114+showDeclImp o (PInstance _ _ _ _ cs acc n _ _ t _ ds)
21122115 = text "implementation" <+> text (show cs) <+> text (show n) <+> prettyImp o t <> line <> showDecls o ds
21132116showDeclImp _ _ = text "..."
21142117-- showDeclImp (PImport o) = "import " ++ o
src/Idris/Core/CaseTree.hs+2−2
@@ -152,10 +152,10 @@ findCalls sc topargs = nub $ nu' topargs sc where
152152 nua ps (SucCase _ sc) = nu' ps sc
153153 nua ps (DefaultCase sc) = nu' ps sc
154154
155− nut ps (P Ref n _) | n `elem` ps = []
155+ nut ps (P _ n _) | n `elem` ps = []
156156 | otherwise = [(n, [])] -- tmp
157157 nut ps fn@(App _ f a)
158− | (P Ref n _, args) <- unApply fn
158+ | (P _ n _, args) <- unApply fn
159159 = if n `elem` ps then nut ps f ++ nut ps a
160160 else [(n, map argNames args)] ++ concatMap (nut ps) args
161161 | (P (TCon _ _) n _, _) <- unApply fn = []
src/Idris/Core/Evaluate.hs+13−10
@@ -12,7 +12,7 @@ module Idris.Core.Evaluate(normalise, normaliseTrace, normaliseC,
1212 addDatatype, addCasedef, simplifyCasedef, addOperator,
1313 lookupNames, lookupTyName, lookupTyNameExact, lookupTy, lookupTyExact,
1414 lookupP, lookupP_all, lookupDef, lookupNameDef, lookupDefExact, lookupDefAcc, lookupDefAccExact, lookupVal,
15− mapDefCtxt,
15+ mapDefCtxt,
1616 lookupTotal, lookupNameTotal, lookupMetaInformation, lookupTyEnv, isTCDict, isDConName, canBeDConName, isTConName, isConName, isFnName,
1717 Value(..), Quote(..), initEval, uniqueNameCtxt, uniqueBindersCtxt, definitions,
1818 isUniverse) where
@@ -247,18 +247,16 @@ eval traceon ctxt ntimes genv tm opts = ev ntimes [] True [] tm where
247247 | otherwise
248248 = do (u, ntimes) <- usable spec n ntimes_in
249249 if u then
250− do let val = lookupDefAcc n (spec || atRepl) ctxt
250+ do let val = lookupDefAcc n (spec || atRepl || runtime) ctxt
251251 case val of
252252 [(Function _ tm, _)] | sUN "assert_total" `elem` stk ->
253253 ev ntimes (n:stk) True env tm
254254 [(Function _ tm, Public)] ->
255255 ev ntimes (n:stk) True env tm
256− [(Function _ tm, Hidden)] ->
257− ev ntimes (n:stk) True env tm
258256 [(TyDecl nt ty, _)] -> do vty <- ev ntimes stk True env ty
259257 return $ VP nt n vty
260258 [(CaseOp ci _ _ _ _ cd, acc)]
261− | (acc /= Frozen || sUN "assert_total" `elem` stk) &&
259+ | (acc == Public || sUN "assert_total" `elem` stk) &&
262260 null (fst (cases_totcheck cd)) -> -- unoptimised version
263261 let (ns, tree) = getCases cd in
264262 if blockSimplify ci n stk
@@ -319,7 +317,7 @@ eval traceon ctxt ntimes genv tm opts = ev ntimes [] True [] tm where
319317 evApply ntimes' stk top env [l',t',arg'] d'
320318 -- Treat "assert_total" specially, as long as it's defined!
321319 ev ntimes stk top env (App _ (App _ (P _ n@(UN at) _) _) arg)
322− | [(CaseOp _ _ _ _ _ _, _)] <- lookupDefAcc n (spec || atRepl) ctxt,
320+ | [(CaseOp _ _ _ _ _ _, _)] <- lookupDefAcc n (spec || atRepl || runtime) ctxt,
323321 at == txt "assert_total" && not simpl
324322 = ev ntimes (n : stk) top env arg
325323 ev ntimes stk top env (App _ f a)
@@ -347,7 +345,7 @@ eval traceon ctxt ntimes genv tm opts = ev ntimes [] True [] tm where
347345 = apply ntimes stk top env f args
348346
349347 reapply ntimes stk top env f@(VP Ref n ty) args
350− = let val = lookupDefAcc n (spec || atRepl) ctxt in
348+ = let val = lookupDefAcc n (spec || atRepl || runtime) ctxt in
351349 case val of
352350 [(CaseOp ci _ _ _ _ cd, acc)] ->
353351 let (ns, tree) = getCases cd in
@@ -373,10 +371,10 @@ eval traceon ctxt ntimes genv tm opts = ev ntimes [] True [] tm where
373371 | otherwise
374372 = do (u, ntimes) <- usable spec n ntimes_in
375373 if u then
376− do let val = lookupDefAcc n (spec || atRepl) ctxt
374+ do let val = lookupDefAcc n (spec || atRepl || runtime) ctxt
377375 case val of
378376 [(CaseOp ci _ _ _ _ cd, acc)]
379− | acc /= Frozen || sUN "assert_total" `elem` stk ->
377+ | acc == Public || sUN "assert_total" `elem` stk ->
380378 -- unoptimised version
381379 let (ns, tree) = getCases cd in
382380 if blockSimplify ci n stk
@@ -746,11 +744,16 @@ instance Show Def where
746744-- Hidden => doesn't reduce and invisible to type checker
747745
748746data Accessibility = Public | Frozen | Hidden
749− deriving (Show, Eq)
747+ deriving (Eq, Ord)
750748{-!
751749deriving instance NFData Accessibility
752750!-}
753751
752+instance Show Accessibility where
753+ show Public = "public export"
754+ show Frozen = "export"
755+ show Hidden = "private"
756+
754757-- | The result of totality checking
755758data Totality = Total [Int] -- ^ well-founded arguments
756759 | Productive -- ^ productive
src/Idris/Core/TT.hs+1−1
@@ -588,7 +588,7 @@ tcname (SN (MethodN _)) = True
588588tcname (SN (ParentN _ _)) = True
589589tcname _ = False
590590
591−implicitable (NS n _) = implicitable n
591+implicitable (NS n _) = False
592592implicitable (UN xs) | T.null xs = False
593593 | otherwise = isLower (T.head xs) || T.head xs == '_'
594594implicitable (MN _ x) = not (tnull x) && thead x /= '_'
src/Idris/Coverage.hs+3−1
@@ -135,6 +135,7 @@ validCoverageCase ctxt (CantUnify _ (topx, _) (topy, _) e _ _)
135135 = case (unApply topx, unApply topy) of
136136 ((P _ x _, _), (P _ y _, _)) -> x == y
137137 _ -> False
138+validCoverageCase ctxt (InfiniteUnify _ _ _) = False
138139validCoverageCase ctxt (CantConvert _ _ _) = False
139140validCoverageCase ctxt (At _ e) = validCoverageCase ctxt e
140141validCoverageCase ctxt (Elaborating _ _ _ e) = validCoverageCase ctxt e
@@ -313,7 +314,7 @@ checkAllCovering fc done top n | not (n `elem` done)
313314 [Partial _] ->
314315 case lookupCtxt n (idris_callgraph i) of
315316 [cg] -> mapM_ (checkAllCovering fc (n : done) top)
316− (map fst (calls cg))
317+ (calls cg)
317318 _ -> return ()
318319 x -> return () -- stop if total
319320checkAllCovering _ _ _ _ = return ()
@@ -474,6 +475,7 @@ buildSCG (_, n) = do
474475 let newscg = buildSCG' ist (rights pats) args
475476 logCoverage 5 $ "SCG is: " ++ show newscg
476477 addToCG n ( cg { scg = newscg } )
478+ _ -> return () -- CG comes from a type declaration only
477479 [] -> logCoverage 5 $ "Could not build SCG for " ++ show n ++ "\n"
478480 x -> error $ "buildSCG: " ++ show (n, x)
479481
src/Idris/DeepSeq.hs+6−6
@@ -365,9 +365,9 @@ instance NFData LogCat where
365365 rnf _ = ()
366366
367367instance NFData CGInfo where
368− rnf (CGInfo x1 x2 x3 x4 x5)
368+ rnf (CGInfo x1 x2 x3)
369369 = rnf x1 `seq`
370− rnf x2 `seq` rnf x3 `seq` rnf x4 `seq` rnf x5 `seq` ()
370+ rnf x2 `seq` rnf x3 `seq` ()
371371
372372instance NFData Fixity where
373373 rnf (Infixl x1) = rnf x1 `seq` ()
@@ -466,7 +466,7 @@ instance (NFData t) => NFData (PDecl' t) where
466466 rnf x9 `seq`
467467 rnf x10 `seq`
468468 rnf x11 `seq` rnf x12 `seq` ()
469− rnf (PInstance x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11)
469+ rnf (PInstance x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12)
470470 = rnf x1 `seq`
471471 rnf x2 `seq`
472472 rnf x3 `seq`
@@ -475,7 +475,7 @@ instance (NFData t) => NFData (PDecl' t) where
475475 rnf x6 `seq`
476476 rnf x7 `seq`
477477 rnf x8 `seq`
478− rnf x9 `seq` rnf x10 `seq` rnf x11 `seq` ()
478+ rnf x9 `seq` rnf x10 `seq` rnf x11 `seq` rnf x12 `seq` ()
479479 rnf (PDSL x1 x2) = rnf x1 `seq` rnf x2 `seq` ()
480480 rnf (PSyntax x1 x2) = rnf x1 `seq` rnf x2 `seq` ()
481481 rnf (PMutual x1 x2) = rnf x1 `seq` rnf x2 `seq` ()
@@ -696,8 +696,8 @@ instance NFData IState where
696696 rnf (IState x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15 x16 x17 x18 x19 x20
697697 x21 x22 x23 x24 x25 x26 x27 x28 x29 x30 x31 x32 x33 x34 x35 x36 x37 x38 x39 x40
698698 x41 x42 x43 x44 x45 x46 x47 x48 x49 x50 x51 x52 x53 x54 x55 x56 x57 x58 x59 x60
699− x61 x62 x63 x64 x65 x66 x67 x68 x69 x70 x71 x72 x73 x74)
699+ x61 x62 x63 x64 x65 x66 x67 x68 x69 x70 x71 x72 x73 x74 x75)
700700 = rnf x1 `seq` rnf x2 `seq` rnf x3 `seq` rnf x4 `seq` rnf x5 `seq` rnf x6 `seq` rnf x7 `seq` rnf x8 `seq` rnf x9 `seq` rnf x10 `seq` () `seq` rnf x11 `seq` rnf x12 `seq` rnf x13 `seq` rnf x14 `seq` rnf x15 `seq` rnf x16 `seq` rnf x17 `seq` rnf x18 `seq` rnf x19 `seq` rnf x20 `seq`
701701 rnf x21 `seq` rnf x22 `seq` rnf x23 `seq` rnf x24 `seq` rnf x25 `seq` rnf x26 `seq` rnf x27 `seq` rnf x28 `seq` rnf x29 `seq` rnf x30 `seq` rnf x31 `seq` rnf x32 `seq` rnf x33 `seq` rnf x34 `seq` rnf x35 `seq` rnf x36 `seq` rnf x37 `seq` rnf x38 `seq` rnf x39 `seq` rnf x40 `seq`
702702 rnf x41 `seq` rnf x42 `seq` rnf x43 `seq` rnf x44 `seq` rnf x45 `seq` rnf x46 `seq` rnf x47 `seq` rnf x48 `seq` rnf x49 `seq` rnf x50 `seq` rnf x51 `seq` rnf x52 `seq` rnf x53 `seq` rnf x54 `seq` rnf x55 `seq` rnf x56 `seq` rnf x57 `seq` rnf x58 `seq` rnf x59 `seq` rnf x60 `seq`
703− rnf x61 `seq` rnf x62 `seq` rnf x63 `seq` rnf x64 `seq` rnf x65 `seq` rnf x66 `seq` rnf x67 `seq` rnf x68 `seq` rnf x69 `seq` rnf x70 `seq` rnf x71 `seq` rnf x72 `seq` rnf x73 `seq` rnf x74 `seq` ()
703+ rnf x61 `seq` rnf x62 `seq` rnf x63 `seq` rnf x64 `seq` rnf x65 `seq` rnf x66 `seq` rnf x67 `seq` rnf x68 `seq` rnf x69 `seq` rnf x70 `seq` rnf x71 `seq` rnf x72 `seq` rnf x73 `seq` rnf x74 `seq` rnf x75 `seq` ()
src/Idris/Delaborate.hs+2−2
@@ -346,11 +346,11 @@ pprintErr' i (NotInjective p x y) =
346346 text "Can't verify injectivity of" <+> annTm p (pprintTerm i (delabSugared i p)) <+>
347347 text " when unifying" <+> annTm x (pprintTerm i (delabSugared i x)) <+> text "and" <+>
348348 annTm y (pprintTerm i (delabSugared i y))
349−pprintErr' i (CantResolve _ c) = text "Can't resolve type class" <+> pprintTerm i (delabSugared i c)
349+pprintErr' i (CantResolve _ c) = text "Can't find implementation for" <+> pprintTerm i (delabSugared i c)
350350pprintErr' i (InvalidTCArg n t)
351351 = annTm t (pprintTerm i (delabSugared i t)) <+> text " cannot be a parameter of "
352352 <> annName n <$>
353− text "(Type class arguments must be injective)"
353+ text "(Implementation arguments must be injective)"
354354pprintErr' i (CantResolveAlts as) = text "Can't disambiguate name:" <+>
355355 align (cat (punctuate (comma <> space) (map (fmap (fancifyAnnots i True) . annName) as)))
356356pprintErr' i (NoValidAlts as) = text "Can't disambiguate since no name has a suitable type:" <+>
src/Idris/Docs.hs+3−3
@@ -19,7 +19,7 @@ import Data.Maybe
1919import Data.List
2020import qualified Data.Text as T
2121
22−-- TODO: Only include names with public/abstract accessibility
22+-- TODO: Only include names with public/export accessibility
2323--
2424-- Issue #1573 on the Issue tracker.
2525-- https://github.com/idris-lang/Idris-dev/issues/1573
@@ -319,8 +319,8 @@ docClass n ci
319319 namedInst n@(UN _) = Just n
320320 namedInst _ = Nothing
321321
322− getDInst (PInstance _ _ _ _ _ _ _ _ t _ _) = Just t
323− getDInst _ = Nothing
322+ getDInst (PInstance _ _ _ _ _ _ _ _ _ t _ _) = Just t
323+ getDInst _ = Nothing
324324
325325 isSubclass (PPi (Constraint _ _) _ _ (PApp _ _ args) (PApp _ (PRef _ _ nm) args'))
326326 = nm == n && map getTm args == map getTm args'
src/Idris/Elab/Class.hs+2−2
@@ -138,7 +138,7 @@ elabClass info syn_in doc fc constraints tn tnfc ps pDocs fds ds mcn cd
138138
139139 -- TODO: probably should normalise
140140 checkDefaultSuperclassInstance :: PDecl -> Idris ()
141− checkDefaultSuperclassInstance (PInstance _ _ _ fc cs n _ ps _ _ _)
141+ checkDefaultSuperclassInstance (PInstance _ _ _ fc cs _ n _ ps _ _ _)
142142 = do when (not $ null cs) . tclift
143143 $ tfail (At fc (Msg $ "Default superclass instances can't have constraints."))
144144 i <- getIState
@@ -184,7 +184,7 @@ elabClass info syn_in doc fc constraints tn tnfc ps pDocs fds ds mcn cd
184184
185185 tydecl (PTy _ _ _ _ _ _ _ _) = True
186186 tydecl _ = False
187− instdecl (PInstance _ _ _ _ _ _ _ _ _ _ _) = True
187+ instdecl (PInstance _ _ _ _ _ _ _ _ _ _ _ _) = True
188188 instdecl _ = False
189189 clause (PClauses _ _ _ _) = True
190190 clause _ = False
src/Idris/Elab/Clause.hs+32−18
@@ -80,10 +80,11 @@ elabClauses info' fc opts n_in cs =
8080 let atys = map snd (getArgTys fty)
8181 cs_elab <- mapM (elabClause info opts)
8282 (zip [0..] cs)
83+ ctxt <- getContext
8384 -- pats_raw is the version we'll work with at compile time:
8485 -- no simplification or PE
8586 let (pats_in, cs_full) = unzip cs_elab
86− let pats_raw = map (simple_lhs (tt_ctxt ist)) pats_in
87+ let pats_raw = map (simple_lhs ctxt) pats_in
8788 logElab 3 $ "Elaborated patterns:\n" ++ show pats_raw
8889
8990 solveDeferred n
@@ -93,6 +94,7 @@ elabClauses info' fc opts n_in cs =
9394 addIBC (IBCOpt n)
9495
9596 ist <- getIState
97+ ctxt <- getContext
9698 -- Don't apply rules if this is a partial evaluation definition,
9799 -- or we'll make something that just runs itself!
98100 let tpats = case specNames opts of
@@ -103,7 +105,7 @@ elabClauses info' fc opts n_in cs =
103105 -- RHS
104106 pe_tm <- doPartialEval ist tpats
105107 let pats_pe = if petrans
106− then map (simple_lhs (tt_ctxt ist)) pe_tm
108+ then map (simple_lhs ctxt) pe_tm
107109 else pats_raw
108110
109111 let tcase = opt_typecase (idris_options ist)
@@ -183,7 +185,8 @@ elabClauses info' fc opts n_in cs =
183185 -- pdef' is the version that gets compiled for run-time,
184186 -- so we start from the partially evaluated version
185187 pdef_in' <- applyOpts $ map (\(ns, lhs, rhs) -> (map fst ns, lhs, rhs)) pdef_pe
186− let pdef' = map (simple_rt (tt_ctxt ist)) pdef_in'
188+ ctxt <- getContext
189+ let pdef' = map (simple_rt ctxt) pdef_in'
187190
188191 logElab 5 $ "After data structure transformations:\n" ++ show pdef'
189192
@@ -241,24 +244,28 @@ elabClauses info' fc opts n_in cs =
241244 ctxt
242245 setContext ctxt'
243246 addIBC (IBCDef n)
247+ addDefinedName n
244248 setTotality n tot
245249 when (not reflect && PEGenerated `notElem` opts) $
246250 do totcheck (fc, n)
247251 defer_totcheck (fc, n)
248252 when (tot /= Unchecked) $ addIBC (IBCTotal n tot)
249253 i <- getIState
250− case lookupDef n (tt_ctxt i) of
254+ ctxt <- getContext
255+ case lookupDef n ctxt of
251256 (CaseOp _ _ _ _ _ cd : _) ->
252− let (scargs, sc) = cases_compiletime cd
253− (scargs', sc') = cases_runtime cd in
254− do let calls = findCalls sc' scargs'
255− let used = findUsedArgs sc' scargs'
257+ let (scargs, sc) = cases_compiletime cd in
258+ do let calls = map fst $ findCalls sc scargs
256259 -- let scg = buildSCG i sc scargs
257260 -- add SCG later, when checking totality
258− let cg = CGInfo scargs' calls [] used [] -- TODO: remove this, not needed anymore
259− logElab 2 $ "Called names: " ++ show cg
260− addToCG n cg
261− addToCalledG n (nub (map fst calls)) -- plus names in type!
261+ logElab 2 $ "Called names: " ++ show calls
262+ -- if the definition is public, make sure
263+ -- it only uses public names
264+ nvis <- getFromHideList n
265+ case nvis of
266+ Just Public -> mapM_ (checkVisibility fc n Public Public) calls
267+ _ -> return ()
268+ addCalls n calls
262269 addIBC (IBCCG n)
263270 _ -> return ()
264271 return ()
@@ -353,11 +360,12 @@ elabPE info fc caller r =
353360 mkSpecialised :: (Name, [(PEArgType, Term)]) -> Idris [(Term, Term)]
354361 mkSpecialised specapp_in = do
355362 ist <- getIState
363+ ctxt <- getContext
356364 let (specTy, specapp) = getSpecTy ist specapp_in
357365 let (n, newnm, specdecl) = getSpecClause ist specapp
358366 let lhs = pe_app specdecl
359367 let rhs = pe_def specdecl
360− let undef = case lookupDefExact newnm (tt_ctxt ist) of
368+ let undef = case lookupDefExact newnm ctxt of
361369 Nothing -> True
362370 _ -> False
363371 logElab 5 $ show (newnm, undef, map (concreteArg ist) (snd specapp))
@@ -370,7 +378,7 @@ elabPE info fc caller r =
370378 let cgns' = filter (\x -> x /= n &&
371379 notStatic ist x) cgns
372380 -- set small reduction limit on partial/productive things
373− let maxred = case lookupTotal n (tt_ctxt ist) of
381+ let maxred = case lookupTotal n ctxt of
374382 [Total _] -> 65536
375383 [Productive] -> 16
376384 _ -> 1
@@ -485,7 +493,7 @@ checkPossible info fc tcgen fname lhs_in
485493 processTacticDecls info newDecls
486494 sendHighlighting highlights
487495 let lhs_tm = orderPats (getInferTerm lhs')
488− case recheck ctxt [] (forget lhs_tm) lhs_tm of
496+ case recheck ctxt' [] (forget lhs_tm) lhs_tm of
489497 OK _ -> return True
490498 err -> return False
491499 -- if it's a recoverable error, the case may become possible
@@ -558,7 +566,7 @@ elabClause info opts (cnum, PClause fc fname lhs_in_as withs rhs_in_as wherebloc
558566 (Msg "unexpected patterns outside of \"with\" block")))
559567
560568 -- get the parameters first, to pass through to any where block
561− let fn_ty = case lookupTy fname (tt_ctxt i) of
569+ let fn_ty = case lookupTy fname ctxt of
562570 [t] -> t
563571 _ -> error "Can't happen (elabClause function type)"
564572 let fn_is = case lookupCtxt fname (idris_implicits i) of
@@ -602,6 +610,7 @@ elabClause info opts (cnum, PClause fc fname lhs_in_as withs rhs_in_as wherebloc
602610
603611 -- If we're inferring metavariables in the type, don't recheck,
604612 -- because we're only doing this to try to work out those metavariables
613+ ctxt <- getContext
605614 (clhs_c, clhsty) <- if not inf
606615 then recheckC_borrowing False (PEGenerated `notElem` opts)
607616 [] fc id [] lhs_tm
@@ -627,6 +636,8 @@ elabClause info opts (cnum, PClause fc fname lhs_in_as withs rhs_in_as wherebloc
627636 logElab 5 ("Checked " ++ show clhs ++ "\n" ++ show clhsty)
628637 -- Elaborate where block
629638 ist <- getIState
639+ ctxt <- getContext
640+
630641 windex <- getName
631642 let decls = nub (concatMap declared whereblock)
632643 let defs = nub (decls ++ concatMap defined whereblock)
@@ -635,7 +646,7 @@ elabClause info opts (cnum, PClause fc fname lhs_in_as withs rhs_in_as wherebloc
635646 -- Unique arguments must be passed to the where block explicitly
636647 -- (since we can't control "usage" easlily otherwise). Remove them
637648 -- from newargs here
638− let uniqargs = findUnique (tt_ctxt ist) [] lhs_tm
649+ let uniqargs = findUnique ctxt [] lhs_tm
639650 let newargs = filter (\(n,_) -> n `notElem` uniqargs) newargs_all
640651
641652 let winfo = (pinfo info newargs defs windex) { elabFC = Just fc }
@@ -798,7 +809,7 @@ elabClause info opts (_, PWith fc fname lhs_in withs wval_in pn_in withblock)
798809 -- pattern bindings
799810 i <- getIState
800811 -- get the parameters first, to pass through to any where block
801− let fn_ty = case lookupTy fname (tt_ctxt i) of
812+ let fn_ty = case lookupTy fname ctxt of
802813 [t] -> t
803814 _ -> error "Can't happen (elabClause function type)"
804815 let fn_is = case lookupCtxt fname (idris_implicits i) of
@@ -819,6 +830,7 @@ elabClause info opts (_, PWith fc fname lhs_in withs wval_in pn_in withblock)
819830 processTacticDecls info newDecls
820831 sendHighlighting highlights
821832
833+ ctxt <- getContext
822834 let lhs_tm = orderPats (getInferTerm lhs')
823835 let lhs_ty = getInferType lhs'
824836 let ret_ty = getRetTy (explicitNames (normalise ctxt [] lhs_ty))
@@ -852,6 +864,8 @@ elabClause info opts (_, PWith fc fname lhs_in withs wval_in pn_in withblock)
852864 addDeferred def''
853865 mapM_ (elabCaseBlock info opts) is
854866 logElab 5 ("Checked wval " ++ show wval')
867+
868+ ctxt <- getContext
855869 (cwval, cwvalty) <- recheckC fc id [] (getInferTerm wval')
856870 let cwvaltyN = explicitNames (normalise ctxt [] cwvalty)
857871 let cwvalN = explicitNames (normalise ctxt [] cwval)
src/Idris/Elab/Instance.hs+8−4
@@ -55,13 +55,14 @@ elabInstance :: ElabInfo -> SyntaxInfo ->
5555 [(Name, Docstring (Either Err PTerm))] ->
5656 ElabWhat -> -- phase
5757 FC -> [(Name, PTerm)] -> -- constraints
58+ Accessibility ->
5859 Name -> -- the class
5960 FC -> -- precise location of class name
6061 [PTerm] -> -- class parameters (i.e. instance)
6162 PTerm -> -- full instance type
6263 Maybe Name -> -- explicit name
6364 [PDecl] -> Idris ()
64−elabInstance info syn doc argDocs what fc cs n nfc ps t expn ds = do
65+elabInstance info syn doc argDocs what fc cs acc n nfc ps t expn ds = do
6566 i <- getIState
6667 (n, ci) <- case lookupCtxtName n (idris_classes i) of
6768 [c] -> return c
@@ -70,6 +71,9 @@ elabInstance info syn doc argDocs what fc cs n nfc ps t expn ds = do
7071 (CantResolveAlts (map fst cs))
7172 let constraint = PApp fc (PRef fc [] n) (map pexp ps)
7273 let iname = mkiname n (namespace info) ps expn
74+ putIState (i { hide_list = addDef iname acc (hide_list i) })
75+ i <- getIState
76+
7377 let emptyclass = null (class_methods ci)
7478 when (what /= EDefns) $ do
7579 nty <- elabType' True info syn doc argDocs fc [] iname NoFC t
@@ -159,10 +163,10 @@ elabInstance info syn doc argDocs what fc cs n nfc ps t expn ds = do
159163 Just m -> sNS (SN (sInstanceN n' (map show ps'))) m
160164 Just nm -> nm
161165
162− substInstance ips pnames (PInstance doc argDocs syn _ cs n nfc ps t expn ds)
163− = PInstance doc argDocs syn fc cs n nfc (map (substMatchesShadow ips pnames) ps) (substMatchesShadow ips pnames t) expn ds
166+ substInstance ips pnames (PInstance doc argDocs syn _ cs acc n nfc ps t expn ds)
167+ = PInstance doc argDocs syn fc cs acc n nfc (map (substMatchesShadow ips pnames) ps) (substMatchesShadow ips pnames t) expn ds
164168
165− isOverlapping i (PInstance doc argDocs syn _ _ n nfc ps t expn _)
169+ isOverlapping i (PInstance doc argDocs syn _ _ _ n nfc ps t expn _)
166170 = case lookupCtxtName n (idris_classes i) of
167171 [(n, ci)] -> let iname = (mkiname n (namespace info) ps expn) in
168172 case lookupTy iname (tt_ctxt i) of
src/Idris/Elab/Term.hs+6−8
@@ -2476,8 +2476,10 @@ withErrorReflection x = idrisCatch x (\ e -> handle e >>= ierror)
24762476 OK hs -> return hs
24772477
24782478 -- Normalize error handler terms to produce the new messages
2479+ -- Need to use 'normaliseAll' since we have to reduce private
2480+ -- names in error handlers too
24792481 ctxt <- getContext
2480− let results = map (normalise ctxt []) (map fst handlers)
2482+ let results = map (normaliseAll ctxt []) (map fst handlers)
24812483 logElab 3 $ "New error message info: " ++ concat (intersperse " and " (map show results))
24822484
24832485 -- For each handler term output, either discard it if it is Nothing or reify it the Haskell equivalent
@@ -2549,13 +2551,9 @@ processTacticDecls info steps =
25492551 -- we refer to, so that if they aren't total, the whole
25502552 -- thing won't be.
25512553 let (scargs, sc) = cases_compiletime cd
2552− (scargs', sc') = cases_runtime cd
2553− calls = findCalls sc' scargs
2554− used = findUsedArgs sc' scargs'
2555− cg = CGInfo scargs' calls [] used []
2556− in do logElab 2 $ "Called names in reflected elab: " ++ show cg
2557− addToCG n cg
2558− addToCalledG n (nub (map fst calls))
2554+ calls = map fst $ findCalls sc scargs
2555+ in do logElab 2 $ "Called names in reflected elab: " ++ show calls
2556+ addCalls n calls
25592557 addIBC $ IBCCG n
25602558 Just _ -> return () -- TODO throw internal error
25612559 Nothing -> return ()
src/Idris/Elab/Type.hs+13
@@ -102,6 +102,18 @@ buildType info syn fc opts n ty' = do
102102 logElab 3 ("Implicit " ++ show n ++ " " ++ show impls)
103103 addIBC (IBCImp n)
104104
105+ -- Add the names referenced to the call graph, and check we're not
106+ -- referring to anything less visible
107+ -- In particular, a public/export type can not refer to anything
108+ -- private, but can refer to any public/export
109+ let refs = freeNames cty
110+ nvis <- getFromHideList n
111+ case nvis of
112+ Nothing -> return ()
113+ Just acc -> mapM_ (checkVisibility fc n (max Frozen acc) acc) refs
114+ addCalls n refs
115+ addIBC (IBCCG n)
116+
105117 when (Constructor `notElem` opts) $ do
106118 let pnames = getParamsInType i [] impls cty
107119 let fninfo = FnInfo (param_pos 0 pnames cty)
@@ -163,6 +175,7 @@ elabType' norm info syn doc argDocs fc opts n nfc ty' = {- let ty' = piBind (par
163175 let usety = if norm then nty' else nty
164176 ds <- checkDef fc iderr [(n, (-1, Nothing, usety, []))]
165177 addIBC (IBCDef n)
178+ addDefinedName n
166179 let ds' = map (\(n, (i, top, fam, ns)) -> (n, (i, top, fam, ns, True))) ds
167180 addDeferred ds'
168181 setFlags n opts'
src/Idris/Elab/Utils.hs+16
@@ -314,3 +314,19 @@ mkStaticTy ns (PPi p n fc ty sc)
314314 | n `elem` ns = PPi (p { pstatic = Static }) n fc ty (mkStaticTy ns sc)
315315 | otherwise = PPi p n fc ty (mkStaticTy ns sc)
316316mkStaticTy ns t = t
317+
318+-- Check that a name has the minimum required accessibility
319+checkVisibility :: FC -> Name -> Accessibility -> Accessibility -> Name -> Idris ()
320+checkVisibility fc n minAcc acc ref
321+ = do nvis <- getFromHideList ref
322+ case nvis of
323+ Nothing -> return ()
324+ Just acc' -> if acc' > minAcc
325+ then tclift $ tfail (At fc
326+ (Msg $ show acc ++ " " ++ show n ++
327+ " can't refer to " ++
328+ show acc' ++ " " ++ show ref))
329+ else return ()
330+
331+
332+
src/Idris/ElabDecls.hs+2−2
@@ -242,9 +242,9 @@ elabDecl' what info (PClass doc s f cs n nfc ps pdocs fds ds cn cd)
242242 | what /= EDefns
243243 = do logElab 1 $ "Elaborating class " ++ show n
244244 elabClass info (s { syn_params = [] }) doc f cs n nfc ps pdocs fds ds cn cd
245−elabDecl' what info (PInstance doc argDocs s f cs n nfc ps t expn ds)
245+elabDecl' what info (PInstance doc argDocs s f cs acc n nfc ps t expn ds)
246246 = do logElab 1 $ "Elaborating instance " ++ show n
247− elabInstance info s doc argDocs what f cs n nfc ps t expn ds
247+ elabInstance info s doc argDocs what f cs acc n nfc ps t expn ds
248248elabDecl' what info (PRecord doc rsyn fc opts name nfc ps pdocs fs cname cdoc csyn)
249249 = do logElab 1 $ "Elaborating record " ++ show name
250250 elabRecord info what doc rsyn fc opts name nfc ps pdocs fs cname cdoc csyn
src/Idris/IBC.hs+88−62
@@ -3,7 +3,7 @@
33
44module Idris.IBC (loadIBC, loadPkgIndex,
55 writeIBC, writePkgIndex,
6− hasValidIBCVersion) where
6+ hasValidIBCVersion, IBCPhase(..)) where
77
88import Idris.Core.Evaluate
99import Idris.Core.TT
@@ -40,10 +40,18 @@ import System.Directory
4040import Codec.Archive.Zip
4141
4242ibcVersion :: Word16
43−ibcVersion = 128
43+ibcVersion = 132
44+
45+-- When IBC is being loaded - we'll load different things (and omit different
46+-- structures/definitions) depending on which phase we're in
47+data IBCPhase = IBC_Building -- ^ when building the module tree
48+ | IBC_REPL Bool -- ^ when loading modules for the REPL
49+ -- Bool = True for top level module
50+ deriving (Show, Eq)
4451
4552data IBCFile = IBCFile { ver :: Word16,
4653 sourcefile :: FilePath,
54+ ibc_reachablenames :: ![Name],
4755 ibc_imports :: ![(Bool, FilePath)],
4856 ibc_importdirs :: ![FilePath],
4957 ibc_implicits :: ![(Name, [PArg])],
@@ -62,13 +70,10 @@ data IBCFile = IBCFile { ver :: Word16,
6270 ibc_cgflags :: ![(Codegen, String)],
6371 ibc_dynamic_libs :: ![String],
6472 ibc_hdrs :: ![(Codegen, String)],
65− ibc_access :: ![(Name, Accessibility)],
66− ibc_total :: ![(Name, Totality)],
6773 ibc_totcheckfail :: ![(FC, String)],
6874 ibc_flags :: ![(Name, [FnOpt])],
6975 ibc_fninfo :: ![(Name, FnInfo)],
7076 ibc_cg :: ![(Name, CGInfo)],
71− ibc_defs :: ![(Name, Def)],
7277 ibc_docstrings :: ![(Name, (Docstring D.DocTerm, [(Name, Docstring D.DocTerm)]))],
7378 ibc_moduledocs :: ![(Name, Docstring D.DocTerm)],
7479 ibc_transforms :: ![(Name, (Term, Term))],
@@ -87,7 +92,10 @@ data IBCFile = IBCFile { ver :: Word16,
8792 ibc_usage :: ![(Name, Int)],
8893 ibc_exports :: ![Name],
8994 ibc_autohints :: ![(Name, Name)],
90− ibc_deprecated :: ![(Name, String)]
95+ ibc_deprecated :: ![(Name, String)],
96+ ibc_defs :: ![(Name, Def)],
97+ ibc_total :: ![(Name, Totality)],
98+ ibc_access :: ![(Name, Accessibility)]
9199 }
92100 deriving Show
93101{-!
@@ -95,7 +103,7 @@ deriving instance Binary IBCFile
95103!-}
96104
97105initIBC :: IBCFile
98−initIBC = IBCFile ibcVersion "" [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Nothing [] [] [] []
106+initIBC = IBCFile ibcVersion "" [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] Nothing [] [] [] [] [] [] []
99107
100108hasValidIBCVersion :: FilePath -> Idris Bool
101109hasValidIBCVersion fp = do
@@ -106,8 +114,9 @@ hasValidIBCVersion fp = do
106114 return (ver == ibcVersion)
107115
108116loadIBC :: Bool -- ^ True = reexport, False = make everything private
117+ -> IBCPhase
109118 -> FilePath -> Idris ()
110−loadIBC reexport fp
119+loadIBC reexport phase fp
111120 = do imps <- getImported
112121 let redo = case lookup fp imps of
113122 Nothing -> True
@@ -118,15 +127,16 @@ loadIBC reexport fp
118127 case toArchiveOrFail archiveFile of
119128 Left _ -> ifail $ fp ++ " isn't loadable, it may have an old ibc format.\n"
120129 ++ "Please clean and rebuild it."
121− Right archive -> do process reexport archive fp
130+ Right archive -> do process reexport phase archive fp
122131 addImported reexport fp
132+-- dumpTT
123133
124134-- | Load an entire package from its index file
125135loadPkgIndex :: String -> Idris ()
126136loadPkgIndex pkg = do ddir <- runIO $ getIdrisLibDir
127137 addImportDir (ddir </> pkg)
128138 fp <- findPkgIndex pkg
129− loadIBC True fp
139+ loadIBC True IBC_Building fp
130140
131141
132142makeEntry :: (Binary b) => String -> [b] -> Maybe Entry
@@ -156,13 +166,10 @@ entries i = catMaybes [Just $ toEntry "ver" 0 (encode $ ver i),
156166 makeEntry "ibc_cgflags" (ibc_cgflags i),
157167 makeEntry "ibc_dynamic_libs" (ibc_dynamic_libs i),
158168 makeEntry "ibc_hdrs" (ibc_hdrs i),
159− makeEntry "ibc_access" (ibc_access i),
160− makeEntry "ibc_total" (ibc_total i),
161169 makeEntry "ibc_totcheckfail" (ibc_totcheckfail i),
162170 makeEntry "ibc_flags" (ibc_flags i),
163171 makeEntry "ibc_fninfo" (ibc_fninfo i),
164172 makeEntry "ibc_cg" (ibc_cg i),
165− makeEntry "ibc_defs" (ibc_defs i),
166173 makeEntry "ibc_docstrings" (ibc_docstrings i),
167174 makeEntry "ibc_moduledocs" (ibc_moduledocs i),
168175 makeEntry "ibc_transforms" (ibc_transforms i),
@@ -181,7 +188,10 @@ entries i = catMaybes [Just $ toEntry "ver" 0 (encode $ ver i),
181188 makeEntry "ibc_usage" (ibc_usage i),
182189 makeEntry "ibc_exports" (ibc_exports i),
183190 makeEntry "ibc_autohints" (ibc_autohints i),
184− makeEntry "ibc_deprecated" (ibc_deprecated i)]
191+ makeEntry "ibc_deprecated" (ibc_deprecated i),
192+ makeEntry "ibc_defs" (ibc_defs i),
193+ makeEntry "ibc_total" (ibc_total i),
194+ makeEntry "ibc_access" (ibc_access i)]
185195
186196writeArchive :: FilePath -> IBCFile -> Idris ()
187197writeArchive fp i = do let a = L.foldl (\x y -> addEntryToArchive y x) emptyArchive (entries i)
@@ -315,8 +325,9 @@ getEntry alt f a = case findEntryByPath f a of
315325 Just e -> return $! (force . decode . fromEntry) e
316326
317327process :: Bool -- ^ Reexporting
328+ -> IBCPhase
318329 -> Archive -> FilePath -> Idris ()
319−process reexp i fn = do
330+process reexp phase i fn = do
320331 ver <- getEntry 0 "ver" i
321332 when (ver /= ibcVersion) $ do
322333 logIBC 1 "ibc out of date"
@@ -328,7 +339,7 @@ process reexp i fn = do
328339 srcok <- runIO $ doesFileExist source
329340 when srcok $ timestampOlder source fn
330341 pImportDirs =<< getEntry [] "ibc_importdirs" i
331− pImports reexp =<< getEntry [] "ibc_imports" i
342+ pImports reexp phase =<< getEntry [] "ibc_imports" i
332343 pImps =<< getEntry [] "ibc_implicits" i
333344 pFixes =<< getEntry [] "ibc_fixes" i
334345 pStatics =<< getEntry [] "ibc_statics" i
@@ -345,12 +356,9 @@ process reexp i fn = do
345356 pCGFlags =<< getEntry [] "ibc_cgflags" i
346357 pDyLibs =<< getEntry [] "ibc_dynamic_libs" i
347358 pHdrs =<< getEntry [] "ibc_hdrs" i
348− pDefs reexp =<< getEntry [] "ibc_defs" i
349359 pPatdefs =<< getEntry [] "ibc_patdefs" i
350− pAccess reexp =<< getEntry [] "ibc_access" i
351360 pFlags =<< getEntry [] "ibc_flags" i
352361 pFnInfo =<< getEntry [] "ibc_fninfo" i
353− pTotal =<< getEntry [] "ibc_total" i
354362 pTotCheckErr =<< getEntry [] "ibc_totcheckfail" i
355363 pCG =<< getEntry [] "ibc_cg" i
356364 pDocs =<< getEntry [] "ibc_docstrings" i
@@ -371,6 +379,9 @@ process reexp i fn = do
371379 pExports =<< getEntry [] "ibc_exports" i
372380 pAutoHints =<< getEntry [] "ibc_autohints" i
373381 pDeprecate =<< getEntry [] "ibc_deprecated" i
382+ pDefs reexp =<< getEntry [] "ibc_defs" i
383+ pTotal =<< getEntry [] "ibc_total" i
384+ pAccess reexp phase =<< getEntry [] "ibc_access" i
374385
375386timestampOlder :: FilePath -> FilePath -> Idris ()
376387timestampOlder src ibc = do srct <- runIO $ getModificationTime src
@@ -404,8 +415,8 @@ pDeprecate ns = mapM_ (\(n,reason) -> addDeprecated n reason) ns
404415pImportDirs :: [FilePath] -> Idris ()
405416pImportDirs fs = mapM_ addImportDir fs
406417
407−pImports :: Bool -> [(Bool, FilePath)] -> Idris ()
408−pImports reexp fs
418+pImports :: Bool -> IBCPhase -> [(Bool, FilePath)] -> Idris ()
419+pImports reexp phase fs
409420 = do mapM_ (\(re, f) ->
410421 do i <- getIState
411422 ibcsd <- valIBCSubDir i
@@ -414,6 +425,9 @@ pImports reexp fs
414425-- if (f `elem` imported i)
415426-- then logLvl 1 $ "Already read " ++ f
416427 putIState (i { imported = f : imported i })
428+ let phase' = case phase of
429+ IBC_REPL _ -> IBC_REPL False
430+ p -> p
417431 case fp of
418432 LIDR fn -> do
419433 logIBC 1 $ "Failed at " ++ fn
@@ -421,7 +435,7 @@ pImports reexp fs
421435 IDR fn -> do
422436 logIBC 1 $ "Failed at " ++ fn
423437 ifail "Must be an ibc"
424− IBC fn src -> loadIBC (reexp && re) fn)
438+ IBC fn src -> loadIBC (reexp && re) phase' fn)
425439 fs
426440
427441pImps :: [(Name, [PArg])] -> Idris ()
@@ -520,10 +534,7 @@ pDefs reexp ds
520534 _ -> do logIBC 1 $ "SOLVING " ++ show n
521535 solveDeferred n
522536 updateIState (\i -> i { tt_ctxt = addCtxtDef n d' (tt_ctxt i) })
523−-- logLvl 1 $ "Added " ++ show (n, d')
524− if (not reexp) then do logIBC 1 $ "Not exporting " ++ show n
525− setAccessibility n Hidden
526− else logIBC 1 $ "Exporting " ++ show n) ds
537+ ) ds
527538 where
528539 updateDef (CaseOp c t args o s cd)
529540 = do o' <- mapM updateOrig o
@@ -537,11 +548,9 @@ pDefs reexp ds
537548 return $ Right (l', r')
538549
539550 updateCD (CaseDefs (ts, t) (cs, c) (is, i) (rs, r))
540− = do t' <- updateSC t
541− c' <- updateSC c
542− i' <- updateSC i
551+ = do c' <- updateSC c
543552 r' <- updateSC r
544− return $ CaseDefs (ts, t') (cs, c') (is, i') (rs, r')
553+ return $ CaseDefs (cs, c') (cs, c') (cs, c') (rs, r')
545554
546555 updateSC (Case t n alts) = do alts' <- mapM updateAlt alts
547556 return (Case t n alts')
@@ -562,19 +571,28 @@ pDefs reexp ds
562571 updateAlt (DefaultCase t) = do t' <- updateSC t
563572 return (DefaultCase t')
564573
565− update (P t n ty) = do n' <- getSymbol n
566− return $ P t n' ty
567− update (App s f a) = liftM2 (App s) (update f) (update a)
568− update (Bind n b sc) = do b' <- updateB b
569− sc' <- update sc
570− return $ Bind n b' sc'
574+ -- We get a lot of repetition in sub terms and can save a fair chunk
575+ -- of memory if we make sure they're shared. addTT looks for a term
576+ -- and returns it if it exists already, while also keeping stats of
577+ -- how many times a subterm is repeated.
578+ update t = do tm <- addTT t
579+ case tm of
580+ Nothing -> update' t
581+ Just t' -> return t'
582+
583+ update' (P t n ty) = do n' <- getSymbol n
584+ return $ P t n' ty
585+ update' (App s f a) = liftM2 (App s) (update' f) (update' a)
586+ update' (Bind n b sc) = do b' <- updateB b
587+ sc' <- update sc
588+ return $ Bind n b' sc'
571589 where
572− updateB (Let t v) = liftM2 Let (update t) (update v)
573− updateB b = do ty' <- update (binderTy b)
590+ updateB (Let t v) = liftM2 Let (update' t) (update' v)
591+ updateB b = do ty' <- update' (binderTy b)
574592 return (b { binderTy = ty' })
575− update (Proj t i) = do t' <- update t
576− return $ Proj t' i
577− update t = return t
593+ update' (Proj t i) = do t' <- update' t
594+ return $ Proj t' i
595+ update' t = return t
578596
579597pDocs :: [(Name, (Docstring D.DocTerm, [(Name, Docstring D.DocTerm)]))] -> Idris ()
580598pDocs ds = mapM_ (\(n, a) -> addDocStr n (fst a) (snd a)) ds
@@ -584,12 +602,22 @@ pMDocs ds = mapM_ (\ (n, d) -> updateIState (\i ->
584602 i { idris_moduledocs = addDef n d (idris_moduledocs i) })) ds
585603
586604pAccess :: Bool -- ^ Reexporting?
605+ -> IBCPhase
587606 -> [(Name, Accessibility)] -> Idris ()
588−pAccess reexp ds
607+pAccess reexp phase ds
589608 = mapM_ (\ (n, a_in) ->
590609 do let a = if reexp then a_in else Hidden
591610 logIBC 3 $ "Setting " ++ show (a, n) ++ " to " ++ show a
592− updateIState (\i -> i { tt_ctxt = setAccess n a (tt_ctxt i) })) ds
611+ updateIState (\i -> i { tt_ctxt = setAccess n a (tt_ctxt i) })
612+
613+ if (not reexp) then do logIBC 1 $ "Not exporting " ++ show n
614+ setAccessibility n Hidden
615+ else logIBC 1 $ "Exporting " ++ show n
616+ -- Everything should be available at the REPL from
617+ -- things imported publicly
618+ when (phase == IBC_REPL True) $
619+ setAccessibility n Public
620+ ) ds
593621
594622pFlags :: [(Name, [FnOpt])] -> Idris ()
595623pFlags ds = mapM_ (\ (n, a) -> setFlags n a) ds
@@ -753,18 +781,14 @@ instance Binary SizeChange where
753781 _ -> error "Corrupted binary data for SizeChange"
754782
755783instance Binary CGInfo where
756− put (CGInfo x1 x2 x3 x4 x5)
784+ put (CGInfo x1 x2 x3)
757785 = do put x1
758− put x2
759786-- put x3 -- Already used SCG info for totality check
760− put x4
761− put x5
787+ put x3
762788 get
763789 = do x1 <- get
764− x2 <- get
765− x4 <- get
766− x5 <- get
767− return (CGInfo x1 x2 [] x4 x5)
790+ x3 <- get
791+ return (CGInfo x1 [] x3)
768792
769793instance Binary CaseType where
770794 put x = case x of
@@ -883,13 +907,13 @@ instance Binary Def where
883907 put x2
884908 -- all primitives just get added at the start, don't write
885909 Operator x1 x2 x3 -> do return ()
886− CaseOp x1 x2 x2a x3 x3a x4 -> do putWord8 3
887− put x1
888− put x2
889− put x2a
890− put x3
891− -- no x3a
892− put x4
910+ -- no need to add/load original patterns, because they're not
911+ -- used again after totality checking
912+ CaseOp x1 x2 x3 _ _ x4 -> do putWord8 3
913+ put x1
914+ put x2
915+ put x3
916+ put x4
893917 get
894918 = do i <- getWord8
895919 case i of
@@ -903,10 +927,10 @@ instance Binary Def where
903927 3 -> do x1 <- get
904928 x2 <- get
905929 x3 <- get
906− x4 <- get
930+-- x4 <- get
907931 -- x3 <- get always []
908932 x5 <- get
909− return (CaseOp x1 x2 x3 x4 [] x5)
933+ return (CaseOp x1 x2 x3 [] [] x5)
910934 _ -> error "Corrupted binary data for Def"
911935
912936instance Binary Accessibility where
@@ -1235,7 +1259,7 @@ instance (Binary t) => Binary (PDecl' t) where
12351259 put x10
12361260 put x11
12371261 put x12
1238− PInstance x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 ->
1262+ PInstance x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 ->
12391263 do putWord8 8
12401264 put x1
12411265 put x2
@@ -1248,6 +1272,7 @@ instance (Binary t) => Binary (PDecl' t) where
12481272 put x9
12491273 put x10
12501274 put x11
1275+ put x12
12511276 PDSL x1 x2 -> do putWord8 9
12521277 put x1
12531278 put x2
@@ -1362,7 +1387,8 @@ instance (Binary t) => Binary (PDecl' t) where
13621387 x9 <- get
13631388 x10 <- get
13641389 x11 <- get
1365− return (PInstance x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11)
1390+ x12 <- get
1391+ return (PInstance x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12)
13661392 9 -> do x1 <- get
13671393 x2 <- get
13681394 return (PDSL x1 x2)
src/Idris/IdrisDoc.hs+1−1
@@ -581,7 +581,7 @@ createOtherDoc ist (FunDoc fd) = createFunDoc ist fd
581581
582582createOtherDoc ist (ClassDoc n docstring fds _ _ _ _ c) = do
583583 H.dt ! (A.id $ toValue $ show n) $ do
584− H.span ! class_ "word" $ do "class"; nbsp
584+ H.span ! class_ "word" $ do "interface"; nbsp
585585 H.span ! class_ "name type"
586586 ! title (toValue $ show n)
587587 $ toHtml $ name $ nsroot n
src/Idris/Interactive.hs+28−11
@@ -238,7 +238,7 @@ doProofSearch fn updatefile rec l n hints (Just depth)
238238 let body t = PProof [Try (TSeq Intros (ProofSearch rec False depth t psnames hints))
239239 (ProofSearch rec False depth t psnames hints)]
240240 let def = PClause fc mn (PRef fc [] mn) [] (body top) []
241− newmv <- idrisCatch
241+ newmv_pre <- idrisCatch
242242 (do elabDecl' EAll recinfo (PClauses fc [] mn [def])
243243 (tm, ty) <- elabVal recinfo ERHS (PRef fc [] mn)
244244 ctxt <- getContext
@@ -249,10 +249,11 @@ doProofSearch fn updatefile rec l n hints (Just depth)
249249 (dropCtxt envlen
250250 (delab i (fst (specialise ctxt [] [(mn, 1)] tm))))))
251251 (\e -> return ("?" ++ show n))
252+ let newmv = guessBrackets False tyline (show n) newmv_pre
252253 if updatefile then
253254 do let fb = fn ++ "~"
254255 runIO $ writeSource fb (unlines before ++
255− updateMeta False tyline (show n) newmv ++ "\n"
256+ updateMeta tyline (show n) newmv ++ "\n"
256257 ++ unlines later)
257258 runIO $ copyFile fb fn
258259 else iPrintResult newmv
@@ -270,18 +271,34 @@ doProofSearch fn updatefile rec l n hints (Just depth)
270271 nsroot (SN (WhereN _ _ n)) = nsroot n
271272 nsroot n = n
272273
273−updateMeta brack ('?':cs) n new
274+updateMeta ('?':cs) n new
274275 | length cs >= length n
275276 = case splitAt (length n) cs of
276277 (mv, c:cs) ->
277278 if ((isSpace c || c == ')' || c == '}') && mv == n)
278− then addBracket brack new ++ (c : cs)
279− else '?' : mv ++ c : updateMeta True cs n new
279+ then new ++ (c : cs)
280+ else '?' : mv ++ c : updateMeta cs n new
281+ (mv, []) -> if (mv == n) then new else '?' : mv
282+updateMeta ('=':'>':cs) n new = '=':'>':updateMeta cs n new
283+updateMeta ('=':cs) n new = '=':updateMeta cs n new
284+updateMeta (c:cs) n new
285+ = c : updateMeta cs n new
286+updateMeta [] n new = ""
287+
288+guessBrackets brack ('?':cs) n new
289+ | length cs >= length n
290+ = case splitAt (length n) cs of
291+ (mv, c:cs) ->
292+ if ((isSpace c || c == ')' || c == '}') && mv == n)
293+ then addBracket brack new
294+ else guessBrackets True cs n new
280295 (mv, []) -> if (mv == n) then addBracket brack new else '?' : mv
281−updateMeta brack ('=':cs) n new = '=':updateMeta False cs n new
282−updateMeta brack (c:cs) n new
283− = c : updateMeta (brack || not (isSpace c)) cs n new
284−updateMeta brack [] n new = ""
296+guessBrackets brack ('=':'>':cs) n new = guessBrackets False cs n new
297+guessBrackets brack ('-':'>':cs) n new = guessBrackets False cs n new
298+guessBrackets brack ('=':cs) n new = guessBrackets False cs n new
299+guessBrackets brack (c:cs) n new
300+ = guessBrackets (brack || not (isSpace c)) cs n new
301+guessBrackets brack [] n new = ""
285302
286303checkProv line n = isProv' False line n
287304 where
@@ -326,7 +343,7 @@ makeLemma fn updatefile l n
326343 constraints i classes mty ++
327344 showTmOpts (defaultPPOption { ppopt_pinames = True })
328345 (stripMNBind skip margs (delab i mty))
329− let lem_app = show n ++ appArgs skip margs mty
346+ let lem_app = guessBrackets False tyline (show n) (show n ++ appArgs skip margs mty)
330347
331348 if updatefile then
332349 do let fb = fn ++ "~"
@@ -454,7 +471,7 @@ makeLemma fn updatefile l n
454471 = case span (not . blank) (reverse before) of
455472 (bef, []) -> (bef, "" : [])
456473 x -> x
457− mvline = updateMeta False tyline (show n) lem_app in
474+ mvline = updateMeta tyline (show n) lem_app in
458475 unlines $ reverse bef_start ++
459476 [blankline, lem, blankline] ++
460477 reverse bef_end ++ mvline : later
src/Idris/ParseData.hs+8−8
@@ -48,7 +48,7 @@ record syn = do (doc, paramDocs, acc, opts) <- try (do
4848 let doc' = annotCode (tryFullExpr syn ist) doc
4949 paramDocs' = [ (n, annotCode (tryFullExpr syn ist) d)
5050 | (n, d) <- paramDocs ]
51− acc <- optional accessibility
51+ acc <- accessibility
5252 opts <- dataOpts []
5353 co <- recordI
5454 return (doc', paramDocs', acc, opts ++ co))
@@ -59,8 +59,9 @@ record syn = do (doc, paramDocs, acc, opts) <- try (do
5959 syn_namespace syn }
6060 params <- manyTill (recordParameter rsyn) (reservedHL "where")
6161 (fields, cname, cdoc) <- indentedBlockS $ recordBody rsyn tyn
62+ let fnames = map (expandNS rsyn) (mapMaybe getName fields)
6263 case cname of
63− Just cn' -> accData acc tyn [fst cn']
64+ Just cn' -> accData acc tyn (fst cn' : fnames)
6465 Nothing -> return ()
6566 return $ PRecord doc rsyn fc opts tyn nfc params paramDocs fields cname cdoc syn
6667 <?> "record type declaration"
@@ -70,6 +71,9 @@ record syn = do (doc, paramDocs, acc, opts) <- try (do
7071 ++ getRecNames syn sc
7172 getRecNames _ _ = []
7273
74+ getName (Just (n, _), _, _, _) = Just n
75+ getName _ = Nothing
76+
7377 toFreeze :: Maybe Accessibility -> Maybe Accessibility
7478 toFreeze (Just Frozen) = Just Hidden
7579 toFreeze x = x
@@ -167,11 +171,7 @@ dataOpts opts
167171 <|> return opts
168172 <?> "data options"
169173 where warnElim fc =
170− do ist <- get
171− let cmdline = opt_cmdline (idris_options ist)
172− unless (NoElimDeprecationWarnings `elem` cmdline) $
173− put ist { parserWarnings =
174− (fc, Msg "Eliminator generation is deprecated. Use an eliminator generator in a library instead.") : parserWarnings ist }
174+ parserWarning fc (Just NoElimDeprecationWarnings) (Msg "The 'class' keyword is deprecated. Use 'interface' instead.")
175175
176176{- | Parses a data type declaration
177177Data ::= DocComment? Accessibility? DataI DefaultEliminator FnName TypeSig ExplicitTypeDataRest?
@@ -192,7 +192,7 @@ data_ :: SyntaxInfo -> IdrisParser PDecl
192192data_ syn = do (doc, argDocs, acc, dataOpts) <- try (do
193193 (doc, argDocs) <- option noDocs docComment
194194 pushIndent
195− acc <- optional accessibility
195+ acc <- accessibility
196196 elim <- dataOpts []
197197 co <- dataI
198198 ist <- get
src/Idris/ParseExpr.hs+6−6
@@ -333,11 +333,7 @@ caseOption syn = do lhs <- expr (syn { inPattern = True })
333333
334334warnTacticDeprecation :: FC -> IdrisParser ()
335335warnTacticDeprecation fc =
336− do ist <- get
337− let cmdline = opt_cmdline (idris_options ist)
338− unless (NoOldTacticDeprecationWarnings `elem` cmdline) $
339− put ist { parserWarnings =
340− (fc, Msg "This style of tactic proof is deprecated. See %runElab for the replacement.") : parserWarnings ist }
336+ parserWarning fc (Just NoOldTacticDeprecationWarnings) (Msg "This style of tactic proof is deprecated. See %runElab for the replacement.")
341337
342338{- | Parses a proof block
343339@
@@ -1389,7 +1385,11 @@ Static ::=
13891385@
13901386-}
13911387static :: IdrisParser Static
1392−static = do reserved "[static]"; return Static
1388+static = do reserved "%static"; return Static
1389+ <|> do reserved "[static]"
1390+ fc <- getFC
1391+ parserWarning fc Nothing (Msg "The use of [static] is deprecated, use %static instead.")
1392+ return Static
13931393 <|> return Dynamic
13941394 <?> "static modifier"
13951395
src/Idris/ParseHelpers.hs+45−12
@@ -7,7 +7,7 @@ module Idris.ParseHelpers where
77import Prelude hiding (pi)
88
99import Text.Trifecta.Delta
10−import Text.Trifecta hiding (span, stringLiteral, charLiteral, natural, symbol, char, string, whiteSpace)
10+import Text.Trifecta hiding (span, stringLiteral, charLiteral, natural, symbol, char, string, whiteSpace, Err)
1111import Text.Parser.LookAhead
1212import Text.Parser.Expression
1313import qualified Text.Parser.Token as Tok
@@ -105,6 +105,14 @@ reportParserWarnings = do ist <- getIState
105105 parserWarnings ist)
106106 clearParserWarnings
107107
108+
109+parserWarning :: FC -> Maybe Opt -> Err -> IdrisParser ()
110+parserWarning fc warnOpt warnErr = do
111+ ist <- get
112+ let cmdline = opt_cmdline (idris_options ist)
113+ unless (maybe False (`elem` cmdline) warnOpt) $
114+ put ist { parserWarnings = (fc, warnErr) : parserWarnings ist }
115+
108116{- * Space, comments and literals (token/lexing like parsers) -}
109117
110118-- | Consumes any simple whitespace (any character which satisfies Char.isSpace)
@@ -248,7 +256,7 @@ idrisStyle = IdentifierStyle _styleName _styleStart _styleLetter _styleReserved
248256 "where", "with", "syntax", "proof", "postulate",
249257 "using", "namespace", "class", "instance",
250258 "interface", "implementation", "parameters",
251− "public", "private", "abstract", "implicit",
259+ "public", "private", "export", "abstract", "implicit",
252260 "quoteGoal", "constructor",
253261 "if", "then", "else"]
254262
@@ -612,22 +620,47 @@ notOpenBraces = do ist <- get
612620 hasNothing = any isNothing
613621
614622{- | Parses an accessibilty modifier (e.g. public, private) -}
615−accessibility :: IdrisParser Accessibility
616−accessibility = do reserved "public"; return Public
617− <|> do reserved "abstract"; return Frozen
623+accessibility' :: IdrisParser Accessibility
624+accessibility'
625+ = do reserved "public";
626+ gotexp <- optional (reserved "export")
627+ case gotexp of
628+ Just _ -> return ()
629+ Nothing -> do
630+ ist <- get
631+ fc <- getFC
632+ put ist { parserWarnings =
633+ (fc, Msg "'public' is deprecated. Use 'public export' instead.")
634+ : parserWarnings ist }
635+ return Public
636+ <|> do reserved "abstract";
637+ ist <- get
638+ fc <- getFC
639+ put ist { parserWarnings =
640+ (fc, Msg "The 'abstract' keyword is deprecated. Use 'export' instead.")
641+ : parserWarnings ist }
642+ return Frozen
643+ <|> do reserved "export"; return Frozen
618644 <|> do reserved "private"; return Hidden
619645 <?> "accessibility modifier"
620646
647+accessibility :: IdrisParser Accessibility
648+accessibility = do acc <- optional accessibility'
649+ case acc of
650+ Just a -> return a
651+ Nothing -> do ist <- get
652+ return (default_access ist)
653+
621654-- | Adds accessibility option for function
622−addAcc :: Name -> Maybe Accessibility -> IdrisParser ()
655+addAcc :: Name -> Accessibility -> IdrisParser ()
623656addAcc n a = do i <- get
624− put (i { hide_list = (n, a) : hide_list i })
657+ put (i { hide_list = addDef n a (hide_list i) })
625658
626659{- | Add accessbility option for data declarations
627660 (works for classes too - 'abstract' means the data/class is visible but members not) -}
628−accData :: Maybe Accessibility -> Name -> [Name] -> IdrisParser ()
629−accData (Just Frozen) n ns = do addAcc n (Just Frozen)
630− mapM_ (\n -> addAcc n (Just Hidden)) ns
661+accData :: Accessibility -> Name -> [Name] -> IdrisParser ()
662+accData Frozen n ns = do addAcc n Public -- so that it can be used in public definitions
663+ mapM_ (\n -> addAcc n Hidden) ns -- so that they are invisible
631664accData a n ns = do addAcc n a
632665 mapM_ (`addAcc` a) ns
633666
@@ -662,7 +695,7 @@ collect (PMutual f ms : ds) = PMutual f (collect ms) : collect ds
662695collect (PNamespace ns fc ps : ds) = PNamespace ns fc (collect ps) : collect ds
663696collect (PClass doc f s cs n nfc ps pdocs fds ds cn cd : ds')
664697 = PClass doc f s cs n nfc ps pdocs fds (collect ds) cn cd : collect ds'
665−collect (PInstance doc argDocs f s cs n nfc ps t en ds : ds')
666− = PInstance doc argDocs f s cs n nfc ps t en (collect ds) : collect ds'
698+collect (PInstance doc argDocs f s cs acc n nfc ps t en ds : ds')
699+ = PInstance doc argDocs f s cs acc n nfc ps t en (collect ds) : collect ds'
667700collect (d : ds) = d : collect ds
668701collect [] = []
src/Idris/Parser.hs+40−41
@@ -337,8 +337,8 @@ declExtension syn ns rules =
337337 (map (updateNs ns) ds)
338338 (updateRecCon ns cname)
339339 cdocs
340− updateNs ns (PInstance docs pdocs s fc cs cn fc' ps ity ni ds)
341− = PInstance docs pdocs s fc cs (updateB ns cn) fc'
340+ updateNs ns (PInstance docs pdocs s fc cs acc cn fc' ps ity ni ds)
341+ = PInstance docs pdocs s fc cs acc (updateB ns cn) fc'
342342 ps ity (fmap (updateB ns) ni)
343343 (map (updateNs ns) ds)
344344 updateNs ns (PMutual fc ds) = PMutual fc (map (updateNs ns) ds)
@@ -584,7 +584,7 @@ fnDecl' syn = checkFixity $
584584 then [TotalFn]
585585 else []
586586 opts <- fnOpts initOpts
587− acc <- optional accessibility
587+ acc <- accessibility
588588 opts' <- fnOpts opts
589589 (n_in, nfc) <- fnName
590590 let n = expandNS syn n_in
@@ -698,7 +698,7 @@ postulate syn = do (doc, ext)
698698 then [TotalFn]
699699 else []
700700 opts <- fnOpts initOpts
701− acc <- optional accessibility
701+ acc <- accessibility
702702 opts' <- fnOpts opts
703703 (n_in, nfc) <- fnName
704704 let n = expandNS syn n_in
@@ -856,7 +856,7 @@ Class ::=
856856class_ :: SyntaxInfo -> IdrisParser [PDecl]
857857class_ syn = do (doc, argDocs, acc)
858858 <- try (do (doc, argDocs) <- docstring syn
859− acc <- optional accessibility
859+ acc <- accessibility
860860 classKeyword
861861 return (doc, argDocs, acc))
862862 fc <- getFC
@@ -878,10 +878,7 @@ class_ syn = do (doc, argDocs, acc)
878878 classKeyword = reservedHL "interface"
879879 <|> do reservedHL "class"
880880 fc <- getFC
881− ist <- get
882− put ist { parserWarnings =
883− (fc, Msg "The 'class' keyword is deprecated. Use 'interface' instead.")
884− : parserWarnings ist }
881+ parserWarning fc Nothing (Msg "The 'class' keyword is deprecated. Use 'interface' instead.")
885882
886883 carg :: IdrisParser (Name, FC, PTerm)
887884 carg = do lchar '('; (i, ifc) <- name; lchar ':'; ty <- expr syn; lchar ')'
@@ -904,7 +901,8 @@ InstanceName ::= '[' Name ']';
904901-}
905902instance_ :: Bool -> SyntaxInfo -> IdrisParser [PDecl]
906903instance_ kwopt syn
907− = do (doc, argDocs)
904+ = do acc <- accessibility
905+ (doc, argDocs)
908906 <- try (docstring syn <* if kwopt then optional instanceKeyword
909907 else do instanceKeyword
910908 return (Just ()))
@@ -917,7 +915,7 @@ instance_ kwopt syn
917915 let sc = PApp fc (PRef cnfc [cnfc] cn) (map pexp args)
918916 let t = bindList (PPi constraint) cs sc
919917 ds <- instanceBlock syn
920− return [PInstance doc argDocs syn fc cs' cn cnfc args t en ds]
918+ return [PInstance doc argDocs syn fc cs' acc cn cnfc args t en ds]
921919 <?> "implementation declaration"
922920 where instanceName :: IdrisParser Name
923921 instanceName = do lchar '['; n_in <- fst <$> fnName; lchar ']'
@@ -928,11 +926,7 @@ instance_ kwopt syn
928926 instanceKeyword = reservedHL "implementation"
929927 <|> do reservedHL "instance"
930928 fc <- getFC
931− ist <- get
932− put ist { parserWarnings =
933− (fc, Msg "The 'instance' keyword is deprecated. Use 'implementation' instead.")
934− : parserWarnings ist }
935−
929+ parserWarning fc Nothing (Msg "The 'instance' keyword is deprecated. Use 'implementation' (or omit it) instead.")
936930
937931-- | Parse a docstring
938932docstring :: SyntaxInfo
@@ -1321,7 +1315,10 @@ directive syn = do try (lchar '%' *> reserved "lib")
13211315 return [PDirective (DHide n)]
13221316 <|> do try (lchar '%' *> reserved "freeze"); n <- fst <$> iName []
13231317 return [PDirective (DFreeze n)]
1324− <|> do try (lchar '%' *> reserved "access"); acc <- accessibility
1318+ <|> do try (lchar '%' *> reserved "access")
1319+ acc <- accessibility
1320+ ist <- get
1321+ put ist { default_access = acc }
13251322 return [PDirective (DAccess acc)]
13261323 <|> do try (lchar '%' *> reserved "default"); tot <- totality
13271324 i <- get
@@ -1491,14 +1488,23 @@ parseImports fname input
14911488 [(FC, OutputAnnotation)], IState)
14921489 imports = do whiteSpace
14931490 (mdoc, mname, annots) <- moduleHeader
1494− ps <- many import_
1491+ ps_exp <- many import_
14951492 mrk <- mark
14961493 isEof <- lookAheadMatches eof
14971494 let mrk' = if isEof
14981495 then Nothing
14991496 else Just mrk
15001497 i <- get
1498+ -- add Builtins and Prelude, unless options say
1499+ -- not to
1500+ let ps = ps_exp -- imp "Builtins" : imp "Prelude" : ps_exp
15011501 return ((mdoc, mname, ps, mrk'), annots, i)
1502+
1503+ imp m = ImportInfo False (toPath m)
1504+ Nothing [] NoFC NoFC
1505+ ns = Spl.splitOn "."
1506+ toPath = foldl1' (</>) . ns
1507+
15021508 addPath :: [(FC, OutputAnnotation)] -> FilePath -> [(FC, OutputAnnotation)]
15031509 addPath [] _ = []
15041510 addPath ((fc, AnnNamespace ns Nothing) : annots) path =
@@ -1556,17 +1562,17 @@ parseProg syn fname input mrk
15561562 return (ds, i')
15571563
15581564{- | Load idris module and show error if something wrong happens -}
1559−loadModule :: FilePath -> Idris (Maybe String)
1560−loadModule f
1561− = idrisCatch (loadModule' f)
1565+loadModule :: FilePath -> IBCPhase -> Idris (Maybe String)
1566+loadModule f phase
1567+ = idrisCatch (loadModule' f phase)
15621568 (\e -> do setErrSpan (getErrSpan e)
15631569 ist <- getIState
15641570 iWarn (getErrSpan e) $ pprintErr ist e
15651571 return Nothing)
15661572
15671573{- | Load idris module -}
1568−loadModule' :: FilePath -> Idris (Maybe String)
1569−loadModule' f
1574+loadModule' :: FilePath -> IBCPhase -> Idris (Maybe String)
1575+loadModule' f phase
15701576 = do i <- getIState
15711577 let file = takeWhile (/= ' ') f
15721578 ibcsd <- valIBCSubDir i
@@ -1580,7 +1586,7 @@ loadModule' f
15801586 IDR fn -> loadSource False fn Nothing
15811587 LIDR fn -> loadSource True fn Nothing
15821588 IBC fn src ->
1583− idrisCatch (loadIBC True fn)
1589+ idrisCatch (loadIBC True phase fn)
15841590 (\c -> do logParser 1 $ fn ++ " failed " ++ pshow i c
15851591 case src of
15861592 IDR sfn -> loadSource False sfn Nothing
@@ -1588,18 +1594,18 @@ loadModule' f
15881594 return $ Just file
15891595
15901596{- | Load idris code from file -}
1591−loadFromIFile :: Bool -> IFileType -> Maybe Int -> Idris ()
1592−loadFromIFile reexp i@(IBC fn src) maxline
1597+loadFromIFile :: Bool -> IBCPhase -> IFileType -> Maybe Int -> Idris ()
1598+loadFromIFile reexp phase i@(IBC fn src) maxline
15931599 = do logParser 1 $ "Skipping " ++ getSrcFile i
1594− idrisCatch (loadIBC reexp fn)
1600+ idrisCatch (loadIBC reexp phase fn)
15951601 (\err -> ierror $ LoadingFailed fn err)
15961602 where
15971603 getSrcFile (IDR fn) = fn
15981604 getSrcFile (LIDR fn) = fn
15991605 getSrcFile (IBC f src) = getSrcFile src
16001606
1601−loadFromIFile _ (IDR fn) maxline = loadSource' False fn maxline
1602−loadFromIFile _ (LIDR fn) maxline = loadSource' True fn maxline
1607+loadFromIFile _ _ (IDR fn) maxline = loadSource' False fn maxline
1608+loadFromIFile _ _ (LIDR fn) maxline = loadSource' True fn maxline
16031609
16041610{-| Load idris source code and show error if something wrong happens -}
16051611loadSource' :: Bool -> FilePath -> Maybe Int -> Idris ()
@@ -1630,7 +1636,7 @@ loadSource lidr f toline
16301636 LIDR fn -> ifail $ "No ibc for " ++ f
16311637 IDR fn -> ifail $ "No ibc for " ++ f
16321638 IBC fn src ->
1633− do loadIBC True fn
1639+ do loadIBC True IBC_Building fn
16341640 let srcFn = case src of
16351641 IDR fn -> Just fn
16361642 LIDR fn -> Just fn
@@ -1760,7 +1766,7 @@ loadSource lidr f toline
17601766 clearHighlights
17611767 i <- getIState
17621768 putIState (i { default_total = def_total,
1763− hide_list = [] })
1769+ hide_list = emptyContext })
17641770 return ()
17651771 where
17661772 namespaces :: [String] -> [PDecl] -> [PDecl]
@@ -1790,16 +1796,9 @@ loadSource lidr f toline
17901796 parsedDocs ist = annotCode (tryFullExpr syn ist) docs
17911797
17921798{- | Adds names to hide list -}
1793−addHides :: [(Name, Maybe Accessibility)] -> Idris ()
1799+addHides :: Ctxt Accessibility -> Idris ()
17941800addHides xs = do i <- getIState
17951801 let defh = default_access i
1796− let (hs, as) = partition isNothing xs
1797− unless (null as) $
1798− mapM_ doHide
1799− (map (\ (n, _) -> (n, defh)) hs ++
1800− map (\ (n, Just a) -> (n, a)) as)
1801− where isNothing (_, Nothing) = True
1802− isNothing _ = False
1803−
1804− doHide (n, a) = do setAccessibility n a
1802+ mapM_ doHide (toAlist xs)
1803+ where doHide (n, a) = do setAccessibility n a
18051804 addIBC (IBCAccess n a)
src/Idris/ProofSearch.hs+32−35
@@ -48,13 +48,13 @@ trivialHoles psnames ok elab ist
4848 then try' (elab (PRef (fileFC "prf") [] x))
4949 (tryAll xs) True
5050 else tryAll xs
51−
51+
5252 holesOK hs ap@(App _ _ _)
5353 | (P _ n _, args) <- unApply ap
5454 = holeArgsOK hs n 0 args
5555 holesOK hs (App _ f a) = holesOK hs f && holesOK hs a
5656 holesOK hs (P _ n _) = not (n `elem` hs)
57− holesOK hs (Bind n b sc) = holesOK hs (binderTy b) &&
57+ holesOK hs (Bind n b sc) = holesOK hs (binderTy b) &&
5858 holesOK hs sc
5959 holesOK hs _ = True
6060
@@ -85,8 +85,8 @@ trivialTCs ok elab ist
8585 then try' (elab (PRef (fileFC "prf") [] x))
8686 (tryAll xs) True
8787 else tryAll xs
88−
89− tcArg env ty
88+
89+ tcArg env ty
9090 | (P _ n _, args) <- unApply (getRetTy (normalise (tt_ctxt ist) env ty))
9191 = case lookupCtxtExact n (idris_classes ist) of
9292 Just _ -> True
@@ -98,7 +98,7 @@ trivialTCs ok elab ist
9898 = holeArgsOK hs n 0 args
9999 holesOK hs (App _ f a) = holesOK hs f && holesOK hs a
100100 holesOK hs (P _ n _) = not (n `elem` hs)
101− holesOK hs (Bind n b sc) = holesOK hs (binderTy b) &&
101+ holesOK hs (Bind n b sc) = holesOK hs (binderTy b) &&
102102 holesOK hs sc
103103 holesOK hs _ = True
104104
@@ -111,16 +111,16 @@ cantSolveGoal :: ElabD a
111111cantSolveGoal = do g <- goal
112112 env <- get_env
113113 lift $ tfail $
114− CantSolveGoal g (map (\(n,b) -> (n, binderTy b)) env)
114+ CantSolveGoal g (map (\(n,b) -> (n, binderTy b)) env)
115115
116−proofSearch :: Bool -> -- recursive search (False for 'refine')
116+proofSearch :: Bool -> -- recursive search (False for 'refine')
117117 Bool -> -- invoked from a tactic proof. If so, making
118118 -- new metavariables is meaningless, and there shoudl
119119 -- be an error reported instead.
120120 Bool -> -- ambiguity ok
121121 Bool -> -- defer on failure
122122 Int -> -- maximum depth
123− (PTerm -> ElabD ()) -> Maybe Name -> Name ->
123+ (PTerm -> ElabD ()) -> Maybe Name -> Name ->
124124 [Name] ->
125125 [Name] ->
126126 IState -> ElabD ()
@@ -131,7 +131,7 @@ proofSearch False fromProver ambigok deferonfail depth elab _ nroot psnames [fn]
131131 tryAllFns all_imps
132132 where
133133 -- if nothing worked, make a new metavariable
134− tryAllFns [] | fromProver = cantSolveGoal
134+ tryAllFns [] | fromProver = cantSolveGoal
135135 tryAllFns [] = do attack; defer [] nroot; solve
136136 tryAllFns (f : fs) = try' (tryFn f) (tryAllFns fs) True
137137
@@ -142,20 +142,20 @@ proofSearch False fromProver ambigok deferonfail depth elab _ nroot psnames [fn]
142142 (match_apply (Var f) imps) True
143143 ps' <- get_probs
144144-- when (length ps < length ps') $ fail "Can't apply constructor"
145− -- Make metavariables for new holes
145+ -- Make metavariables for new holes
146146 hs' <- get_holes
147147 ptm <- get_term
148148 if fromProver then cantSolveGoal
149149 else do
150150 mapM_ (\ h -> do focus h
151− attack; defer [] nroot; solve)
151+ attack; defer [] nroot; solve)
152152 (hs' \\ hs)
153153-- (filter (\ (x, y) -> not x) (zip (map fst imps) args))
154154 solve
155155
156156 isImp (PImp p _ _ _ _) = (True, p)
157157 isImp arg = (True, priority arg) -- try to get all of them by unification
158−proofSearch rec fromProver ambigok deferonfail maxDepth elab fn nroot psnames hints ist
158+proofSearch rec fromProver ambigok deferonfail maxDepth elab fn nroot psnames hints ist
159159 = do compute
160160 ty <- goal
161161 hs <- get_holes
@@ -172,7 +172,7 @@ proofSearch rec fromProver ambigok deferonfail maxDepth elab fn nroot psnames hi
172172 (autoArg (sUN "auto"))
173173 else autoArg (sUN "auto") -- not enough info in the type yet
174174 where
175− findInferredTy (t : _) = elab (delab ist (toUN t))
175+ findInferredTy (t : _) = elab (delab ist (toUN t))
176176
177177 cantsolve (InternalMsg _) = True
178178 cantsolve (CantSolveGoal _ _) = True
@@ -185,12 +185,12 @@ proofSearch rec fromProver ambigok deferonfail maxDepth elab fn nroot psnames hi
185185 conArgsOK ty
186186 = let (f, as) = unApply ty in
187187 case f of
188− P _ n _ ->
188+ P _ n _ ->
189189 let autohints = case lookupCtxtExact n (idris_autohints ist) of
190190 Nothing -> []
191191 Just hs -> hs in
192192 case lookupCtxtExact n (idris_datatypes ist) of
193− Just t -> do rs <- mapM (conReady as)
193+ Just t -> do rs <- mapM (conReady as)
194194 (autohints ++ con_names t)
195195 return (and rs)
196196 Nothing -> -- local variable, go for it
@@ -199,7 +199,7 @@ proofSearch rec fromProver ambigok deferonfail maxDepth elab fn nroot psnames hi
199199 _ -> typeNotSearchable ty
200200
201201 conReady :: [Term] -> Name -> ElabD Bool
202− conReady as n
202+ conReady as n
203203 = case lookupTyExact n (tt_ctxt ist) of
204204 Just ty -> do let (_, cs) = unApply (getRetTy ty)
205205 -- if any metavariables in 'as' correspond to
@@ -223,7 +223,7 @@ proofSearch rec fromProver ambigok deferonfail maxDepth elab fn nroot psnames hi
223223 inHS hs (P _ n _) = n `elem` hs
224224 isHS _ _ = False
225225
226− toUN t@(P nt (MN i n) ty)
226+ toUN t@(P nt (MN i n) ty)
227227 | ('_':xs) <- str n = t
228228 | otherwise = P nt (UN n) ty
229229 toUN (App s f a) = App s (toUN f) (toUN a)
@@ -239,7 +239,7 @@ proofSearch rec fromProver ambigok deferonfail maxDepth elab fn nroot psnames hi
239239 psRec :: Bool -> Int -> [Name] -> S.Set Type -> ElabD ()
240240 psRec _ 0 locs tys | fromProver = cantSolveGoal
241241 psRec rec 0 locs tys = do attack; defer [] nroot; solve --fail "Maximum depth reached"
242− psRec False d locs tys = tryCons d locs tys hints
242+ psRec False d locs tys = tryCons d locs tys hints
243243 psRec True d locs tys
244244 = do compute
245245 ty <- goal
@@ -248,11 +248,11 @@ proofSearch rec fromProver ambigok deferonfail maxDepth elab fn nroot psnames hi
248248 try' (try' (trivialHoles psnames [] elab ist)
249249 (resolveTC False False 20 ty nroot elab ist)
250250 True)
251− (try' (try' (resolveByCon (d - 1) locs tys')
251+ (try' (try' (resolveByCon (d - 1) locs tys')
252252 (resolveByLocals (d - 1) locs tys')
253253 True)
254254 -- if all else fails, make a new metavariable
255− (if fromProver
255+ (if fromProver
256256 then fail "cantSolveGoal"
257257 else do attack; defer [] nroot; solve) True) True
258258
@@ -269,7 +269,7 @@ proofSearch rec fromProver ambigok deferonfail maxDepth elab fn nroot psnames hi
269269 = do t <- goal
270270 let (f, _) = unApply t
271271 case f of
272− P _ n _ ->
272+ P _ n _ ->
273273 do let autohints = case lookupCtxtExact n (idris_autohints ist) of
274274 Nothing -> []
275275 Just hs -> hs
@@ -292,26 +292,26 @@ proofSearch rec fromProver ambigok deferonfail maxDepth elab fn nroot psnames hi
292292 tryLocals d locs tys env
293293
294294 tryLocals d locs tys [] = fail "Locals failed"
295− tryLocals d locs tys ((x, t) : xs)
295+ tryLocals d locs tys ((x, t) : xs)
296296 | x `elem` locs || x `notElem` psnames = tryLocals d locs tys xs
297− | otherwise = try' (tryLocal d (x : locs) tys x t)
297+ | otherwise = try' (tryLocal d (x : locs) tys x t)
298298 (tryLocals d locs tys xs) True
299299
300300 tryCons d locs tys [] = fail "Constructors failed"
301− tryCons d locs tys (c : cs)
301+ tryCons d locs tys (c : cs)
302302 = try' (tryCon d locs tys c) (tryCons d locs tys cs) True
303303
304− tryLocal d locs tys n t
304+ tryLocal d locs tys n t
305305 = do let a = getPArity (delab ist (binderTy t))
306306 tryLocalArg d locs tys n a
307307
308308 tryLocalArg d locs tys n 0 = elab (PRef (fileFC "prf") [] n)
309− tryLocalArg d locs tys n i
309+ tryLocalArg d locs tys n i
310310 = simple_app False (tryLocalArg d locs tys n (i - 1))
311311 (psRec True d locs tys) "proof search local apply"
312312
313313 -- Like type class resolution, but searching with constructors
314− tryCon d locs tys n =
314+ tryCon d locs tys n =
315315 do ty <- goal
316316 let imps = case lookupCtxtExact n (idris_implicits ist) of
317317 Nothing -> []
@@ -341,7 +341,7 @@ proofSearch rec fromProver ambigok deferonfail maxDepth elab fn nroot psnames hi
341341 (Bind _ (Pi _ _ _) _) -> [TextPart "In particular, function types are not supported."]
342342 _ -> []
343343
344−-- In interactive mode, only search for things if there is some
344+-- In interactive mode, only search for things if there is some
345345-- index to help pick a relevant constructor
346346checkConstructor :: IState -> [Name] -> ElabD ()
347347checkConstructor ist [] = return ()
@@ -397,7 +397,7 @@ resTC' tcs defaultOn topholes depth topg fn elab ist
397397 _ -> []
398398
399399 traceWhen ulog ("Resolving class " ++ show g ++ "\nin" ++ show env ++ "\n" ++ show okholes) $
400− try' (trivialTCs okholes elab ist)
400+ try' (trivialTCs okholes elab ist)
401401 (do addDefault t tc ttypes
402402 let stk = map fst (filter snd $ elab_stack ist)
403403 let insts = findInstances ist t
@@ -432,7 +432,7 @@ resTC' tcs defaultOn topholes depth topg fn elab ist
432432 tcDetArgsOK _ _ _ [] = Just []
433433
434434 isMeta :: [Name] -> Term -> Bool
435− isMeta ns (P _ n _) = n `elem` ns
435+ isMeta ns (P _ n _) = n `elem` ns
436436 isMeta _ _ = False
437437
438438 notHole hs (P _ n _, c)
@@ -449,7 +449,7 @@ resTC' tcs defaultOn topholes depth topg fn elab ist
449449 chaser (NS n _) = chaser n
450450 chaser _ = False
451451
452− numclass = sNS (sUN "Num") ["Classes","Prelude"]
452+ numclass = sNS (sUN "Num") ["Interfaces","Prelude"]
453453
454454 addDefault t num@(P _ nc _) [P Bound a _] | nc == numclass && defaultOn
455455 = do focus a
@@ -478,8 +478,7 @@ resTC' tcs defaultOn topholes depth topg fn elab ist
478478 return (num + 1)
479479 _ -> return 0
480480
481− solven 0 = return ()
482− solven n = do solve; solven (n - 1)
481+ solven n = replicateM_ n solve
483482
484483 resolve n depth
485484 | depth == 0 = fail $ "Can't resolve type class"
@@ -531,5 +530,3 @@ findInstances ist t
531530 where accessible n = case lookupDefAccExact n False (tt_ctxt ist) of
532531 Just (_, Hidden) -> False
533532 _ -> True
534−
535−
src/Idris/REPL.hs+67−41
@@ -12,6 +12,7 @@ import Idris.REPLParser
1212import Idris.ElabDecls
1313import Idris.Erasure
1414import Idris.Error
15+import Idris.IBC
1516import Idris.ErrReverse
1617import Idris.Delaborate
1718import Idris.Docstrings (Docstring, overview, renderDocstring, renderDocTerm)
@@ -94,6 +95,10 @@ import Data.Word (Word)
9495import Data.Either (partitionEithers)
9596import Control.DeepSeq
9697
98+import Control.Concurrent.Async (race)
99+import System.FSNotify (withManager, watchDir)
100+import System.FSNotify.Devel (allEvents, doAllEvents)
101+
97102import Numeric ( readHex )
98103
99104import Debug.Trace
@@ -126,10 +131,8 @@ repl orig mods efile
126131 do ms <- H.catch (lift $ processInput input orig mods efile)
127132 (ctrlC (return (Just mods)))
128133 case ms of
129− Just mods -> let efile' = case mods of
130− [] -> efile
131− (e:_) -> e in
132− repl orig mods efile'
134+ Just mods -> let efile' = fromMaybe efile (listToMaybe mods)
135+ in repl orig mods efile'
133136 Nothing -> return ()
134137-- ctrlC)
135138-- ctrlC
@@ -154,15 +157,13 @@ repl orig mods efile
154157
155158-- | Run the REPL server
156159startServer :: PortID -> IState -> [FilePath] -> Idris ()
157−startServer port orig fn_in = do tid <- runIO $ forkOS (serverLoop port)
160+startServer port orig fn_in = do tid <- runIO $ forkIO (serverLoop port)
158161 return ()
159162 where serverLoop port = withSocketsDo $
160163 do sock <- listenOnLocalhost port
161164 loop fn orig { idris_colourRepl = False } sock
162165
163− fn = case fn_in of
164− (f:_) -> f
165− _ -> ""
166+ fn = fromMaybe "" (listToMaybe fn_in)
166167
167168 loop fn ist sock
168169 = do (h,_,_) <- accept sock
@@ -276,9 +277,7 @@ idemode h orig mods
276277 i <- getIState
277278 putIState $ i { idris_outputmode = (IdeMode id h) }
278279 idrisCatch -- to report correct id back!
279− (do let fn = case mods of
280− (f:_) -> f
281− _ -> ""
280+ (do let fn = fromMaybe "" (listToMaybe mods)
282281 case IdeMode.sexpToCommand sexp of
283282 Just cmd -> runIdeModeCommand h id orig fn mods cmd
284283 Nothing -> iPrintError "did not understand" )
@@ -677,30 +676,54 @@ lit f = case splitExtension f of
677676 (_, ".lidr") -> True
678677 _ -> False
679678
679+reload :: IState -> [FilePath] -> Idris (Maybe [FilePath])
680+reload orig inputs = do
681+ i <- getIState
682+ -- The $!! here prevents a space leak on reloading.
683+ -- This isn't a solution - but it's a temporary stopgap.
684+ -- See issue #2386
685+ putIState $!! orig { idris_options = idris_options i
686+ , idris_colourTheme = idris_colourTheme i
687+ , imported = imported i
688+ }
689+ clearErr
690+ fmap Just $ loadInputs inputs Nothing
691+
692+watch :: IState -> [FilePath] -> Idris (Maybe [FilePath])
693+watch orig inputs = do
694+ let inputSet = S.fromList inputs
695+ let dirs = nub $ map takeDirectory inputs
696+ resp <- runIO $ do
697+ signal <- newEmptyMVar
698+ withManager $ \mgr -> do
699+ forM_ dirs $ \dir ->
700+ watchDir mgr dir (allEvents $ flip S.member inputSet) (doAllEvents $ putMVar signal)
701+ race getLine (takeMVar signal)
702+ case resp of
703+ Left _ -> return (Just inputs) -- canceled, so nop
704+ Right _ -> reload orig inputs >> watch orig inputs
705+
680706processInput :: String ->
681707 IState -> [FilePath] -> FilePath -> Idris (Maybe [FilePath])
682708processInput cmd orig inputs efile
683709 = do i <- getIState
684710 let opts = idris_options i
685711 let quiet = opt_quiet opts
686− let fn = case inputs of
687− (f:_) -> f
688− _ -> ""
712+ let fn = fromMaybe "" (listToMaybe inputs)
689713 c <- colourise
690714 case parseCmd i "(input)" cmd of
691715 Failure err -> do iputStrLn $ show (fixColour c err)
692716 return (Just inputs)
693717 Success (Right Reload) ->
694− -- The $!! here prevents a space leak on reloading.
695− -- This isn't a solution - but it's a temporary stopgap.
696− -- See issue #2386
697− do putIState $!! orig { idris_options = idris_options i
698− , idris_colourTheme = idris_colourTheme i
699− , imported = imported i
700− }
701− clearErr
702− mods <- loadInputs inputs Nothing
703− return (Just mods)
718+ reload orig inputs
719+ Success (Right Watch) ->
720+ if null inputs then
721+ do iputStrLn "No loaded files to watch."
722+ return (Just inputs)
723+ else
724+ do iputStrLn efile
725+ iputStrLn $ "Watching for .idr changes in " ++ show inputs ++ ", press enter to cancel."
726+ watch orig inputs
704727 Success (Right (Load f toline)) ->
705728 -- The $!! here prevents a space leak on reloading.
706729 -- This isn't a solution - but it's a temporary stopgap.
@@ -713,7 +736,7 @@ processInput cmd orig inputs efile
713736 return (Just mod)
714737 Success (Right (ModImport f)) ->
715738 do clearErr
716− fmod <- loadModule f
739+ fmod <- loadModule f (IBC_REPL True)
717740 return (Just (inputs ++ maybe [] (:[]) fmod))
718741 Success (Right Edit) -> do -- takeMVar stvar
719742 edit efile orig
@@ -795,7 +818,7 @@ process fn Warranty = iPrintResult warranty
795818process fn (ChangeDirectory f)
796819 = do runIO $ setCurrentDirectory f
797820 return ()
798−process fn (ModImport f) = do fmod <- loadModule f
821+process fn (ModImport f) = do fmod <- loadModule f (IBC_REPL True)
799822 case fmod of
800823 Just pr -> isetPrompt pr
801824 Nothing -> iPrintError $ "Can't find import " ++ f
@@ -879,8 +902,8 @@ process fn (NewDefn decls) = do
879902 fixClauses :: PDecl' t -> PDecl' t
880903 fixClauses (PClauses fc opts _ css@(clause:cs)) =
881904 PClauses fc opts (getClauseName clause) css
882− fixClauses (PInstance doc argDocs syn fc constraints cls nfc parms ty instName decls) =
883− PInstance doc argDocs syn fc constraints cls nfc parms ty instName (map fixClauses decls)
905+ fixClauses (PInstance doc argDocs syn fc constraints acc cls nfc parms ty instName decls) =
906+ PInstance doc argDocs syn fc constraints acc cls nfc parms ty instName (map fixClauses decls)
884907 fixClauses decl = decl
885908
886909process fn (Undefine names) = undefine names
@@ -1067,7 +1090,7 @@ process fn (DebugInfo n)
10671090 when (not (null di)) $ iputStrLn (show di)
10681091 let imps = lookupCtxt n (idris_implicits i)
10691092 when (not (null imps)) $ iputStrLn (show imps)
1070− let d = lookupDef n (tt_ctxt i)
1093+ let d = lookupDefAcc n False (tt_ctxt i)
10711094 when (not (null d)) $ iputStrLn $ "Definition: " ++ (show (head d))
10721095 let cg = lookupCtxtName n (idris_callgraph i)
10731096 i <- getIState
@@ -1216,12 +1239,15 @@ process fn (Compile codegen f)
12161239 iPrintError $ "Invalid filename for compiler output \"" ++ f ++"\""
12171240 | otherwise = do opts <- getCmdLine
12181241 let iface = Interface `elem` opts
1242+ let mainname = sNS (sUN "main") ["Main"]
1243+
12191244 m <- if iface then return Nothing else
12201245 do (m', _) <- elabVal recinfo ERHS
12211246 (PApp fc (PRef fc [] (sUN "run__IO"))
1222− [pexp $ PRef fc [] (sNS (sUN "main") ["Main"])])
1247+ [pexp $ PRef fc [] mainname])
12231248 return (Just m')
12241249 ir <- compile codegen f m
1250+
12251251 i <- getIState
12261252 runIO $ generate codegen (fst (head (idris_imported i))) ir
12271253 where fc = fileFC "main"
@@ -1537,7 +1563,7 @@ loadInputs inputs toline -- furthest line to read in input source files
15371563 logParser 1 ("MODULE TREE : " ++ show modTree)
15381564 logParser 1 ("RELOAD: " ++ show ifiles)
15391565 when (not (all ibc ifiles) || loadCode) $
1540− tryLoad False (filter (not . ibc) ifiles)
1566+ tryLoad False IBC_Building (filter (not . ibc) ifiles)
15411567 -- return the files that need rechecking
15421568 return (input, ifiles))
15431569 ninputs
@@ -1548,7 +1574,8 @@ loadInputs inputs toline -- furthest line to read in input source files
15481574 Nothing ->
15491575 do putIState $!! ist { idris_tyinfodata = tidata }
15501576 ibcfiles <- mapM findNewIBC (nub (concat (map snd ifiles)))
1551− tryLoad True (mapMaybe id ibcfiles)
1577+-- logLvl 0 $ "Loading from " ++ show ibcfiles
1578+ tryLoad True (IBC_REPL True) (mapMaybe id ibcfiles)
15521579 _ -> return ()
15531580 exports <- findExports
15541581
@@ -1568,9 +1595,9 @@ loadInputs inputs toline -- furthest line to read in input source files
15681595 iWarn emptyFC $ pprintErr i e
15691596 return [])
15701597 where -- load all files, stop if any fail
1571− tryLoad :: Bool -> [IFileType] -> Idris ()
1572− tryLoad keepstate [] = warnTotality >> return ()
1573− tryLoad keepstate (f : fs)
1598+ tryLoad :: Bool -> IBCPhase -> [IFileType] -> Idris ()
1599+ tryLoad keepstate phase [] = warnTotality >> return ()
1600+ tryLoad keepstate phase (f : fs)
15741601 = do ist <- getIState
15751602 let maxline
15761603 = case toline of
@@ -1583,7 +1610,7 @@ loadInputs inputs toline -- furthest line to read in input source files
15831610 then Just l
15841611 else Nothing
15851612 _ -> Nothing
1586− loadFromIFile True f maxline
1613+ loadFromIFile True phase f maxline
15871614 inew <- getIState
15881615 -- FIXME: Save these in IBC to avoid this hack! Need to
15891616 -- preserve it all from source inputs
@@ -1601,7 +1628,7 @@ loadInputs inputs toline -- furthest line to read in input source files
16011628 ist <- getIState
16021629 putIState $!! ist { idris_tyinfodata = tidata,
16031630 idris_patdefs = patdefs }
1604− tryLoad keepstate fs
1631+ tryLoad keepstate phase fs
16051632
16061633 ibc (IBC _ _) = True
16071634 ibc _ = False
@@ -1705,13 +1732,12 @@ idrisMain opts =
17051732 addPkgDir "base"
17061733 mapM_ addPkgDir pkgdirs
17071734 elabPrims
1708− when (not (NoBuiltins `elem` opts)) $ do x <- loadModule "Builtins"
1735+ when (not (NoBuiltins `elem` opts)) $ do x <- loadModule "Builtins" (IBC_REPL True)
17091736 addAutoImport "Builtins"
17101737 return ()
1711− when (not (NoPrelude `elem` opts)) $ do x <- loadModule "Prelude"
1738+ when (not (NoPrelude `elem` opts)) $ do x <- loadModule "Prelude" (IBC_REPL True)
17121739 addAutoImport "Prelude"
17131740 return ()
1714−
17151741 when (runrepl && not idesl) initScript
17161742
17171743 nobanner <- getNoBanner
@@ -1772,7 +1798,7 @@ idrisMain opts =
17721798 when (runrepl && not idesl) $ do
17731799-- clearOrigPats
17741800 startServer port orig mods
1775− runInputT (replSettings (Just historyFile)) $ repl orig mods efile
1801+ runInputT (replSettings (Just historyFile)) $ repl (force orig) mods efile
17761802 let idesock = IdemodeSocket `elem` opts
17771803 when (idesl) $ idemodeStart idesock orig inputs
17781804 ok <- noErrors
src/Idris/REPLParser.hs+2−1
@@ -67,6 +67,7 @@ parserCommandsForHelp =
6767 , namespaceArgCmd ["browse"] Browse "List the contents of some namespace"
6868 , nameArgCmd ["total"] TotCheck "Check the totality of a name"
6969 , noArgCmd ["r", "reload"] Reload "Reload current file"
70+ , noArgCmd ["w", "watch"] Watch "Watch the current file for changes"
7071 , (["l", "load"], FileArg, "Load a new file"
7172 , strArg (\f -> Load f Nothing))
7273 , (["cd"], FileArg, "Change working directory"
@@ -98,7 +99,7 @@ parserCommandsForHelp =
9899 , (["consolewidth"], ConsoleWidthArg, "Set the width of the console", cmd_consolewidth)
99100 , (["printerdepth"], OptionalArg NumberArg, "Set the maximum pretty-printer depth (no arg for infinite)", cmd_printdepth)
100101 , noArgCmd ["q", "quit"] Quit "Exit the Idris system"
101− , noArgCmd ["w", "warranty"] Warranty "Displays warranty information"
102+ , noArgCmd ["warranty"] Warranty "Displays warranty information"
102103 , (["let"], ManyArgs DeclArg
103104 , "Evaluate a declaration, such as a function definition, instance implementation, or fixity declaration"
104105 , cmd_let)
src/Idris/Reflection.hs+4−4
@@ -364,10 +364,10 @@ reifyArithTy (P _ n _) | n == reflm "ATDouble" = return ATFloat
364364reifyArithTy x = fail ("Couldn't reify reflected ArithTy: " ++ show x)
365365
366366reifyNativeTy :: Term -> ElabD NativeTy
367−reifyNativeTy (P _ n _) | n == reflm "IT8" = return IT8
368−reifyNativeTy (P _ n _) | n == reflm "IT8" = return IT8
369−reifyNativeTy (P _ n _) | n == reflm "IT8" = return IT8
370−reifyNativeTy (P _ n _) | n == reflm "IT8" = return IT8
367+reifyNativeTy (P _ n _) | n == reflm "IT8" = return IT8
368+reifyNativeTy (P _ n _) | n == reflm "IT16" = return IT16
369+reifyNativeTy (P _ n _) | n == reflm "IT32" = return IT32
370+reifyNativeTy (P _ n _) | n == reflm "IT64" = return IT64
371371reifyNativeTy x = fail $ "Couldn't reify reflected NativeTy " ++ show x
372372
373373reifyIntTy :: Term -> ElabD IntTy
src/Pkg/PParser.hs+2−2
@@ -5,7 +5,7 @@
55module Pkg.PParser where
66
77import Text.Trifecta hiding (span, charLiteral, natural, symbol, char, string, whiteSpace)
8−
8+import qualified Text.PrettyPrint.ANSI.Leijen as PP
99import Idris.Core.TT
1010import Idris.REPL
1111import Idris.AbsSyntaxTree
@@ -51,7 +51,7 @@ parseDesc :: FilePath -> IO PkgDesc
5151parseDesc fp = do
5252 p <- readFile fp
5353 case runparser pPkg defaultPkg fp p of
54− Failure err -> fail (show err)
54+ Failure err -> fail (show $ PP.plain err)
5555 Success x -> return x
5656
5757pPkg :: PParser PkgDesc
src/Pkg/Package.hs+1−1
@@ -142,7 +142,7 @@ documentPkg fp =
142142 setCurrentDirectory pkgDir
143143 let run l = runExceptT . execStateT l
144144 load [] = return ()
145− load (f:fs) = do loadModule f; load fs
145+ load (f:fs) = do loadModule f IBC_Building; load fs
146146 loader = do idrisMain opts; addImportDir (sourcedir pkgdesc); load fs
147147 idrisInstance <- run loader idrisInit
148148 setCurrentDirectory cd
stack.yaml+4−1
@@ -1,4 +1,4 @@
1−resolver: lts-3.16
1+resolver: lts-4.2
22packages:
33- '.'
44flags:
@@ -11,3 +11,6 @@ extra-deps:
1111- cheapskate-0.1.0.4
1212- hscurses-1.4.2.0
1313- libffi-0.1
14+nix:
15+ enable: false
16+ packages: [ libffi, zlib, ncurses, gmp, pkgconfig ]
test/Makefile+22−13
@@ -1,24 +1,33 @@
1−.PHONY: test test_java test_js time update diff distclean $(TESTS)
1+.PHONY: test test_js time update diff distclean $(TESTS)
2+
3+runtest:
4+ @ghc --make runtest.hs
5+ @rm runtest.o runtest.hi
26
37TESTS = $(sort $(patsubst %/,%.test,$(wildcard */)))
48
59test: $(TESTS)
610
7−%.test:
8− @perl ./runtest.pl $(patsubst %.test,%,$@)
911
10−test_js:
11− @perl ./runtest.pl without sugar004 reg029 reg052 io001 dsl002 io003 effects001 effects002 basic007 basic011 ffi006 --codegen node
12+info: runtest
13+ @./runtest all
14+
15+%.test: runtest
16+ @./runtest $(patsubst %.test,%,$@) -q
17+
18+test_js: runtest
19+ @./runtest without sugar004 reg029 reg052 io001 dsl002 io003 effects001 effects002 basic007 basic011 ffi006 opts --codegen node
1220
13−update:
14− /usr/bin/env perl ./runtest.pl all -u
21+update: runtest
22+ @./runtest all -u
1523
16−diff:
17− /usr/bin/env perl ./runtest.pl all -d
24+diff: runtest
25+ @./runtest all -d
1826
19−time:
20− /usr/bin/env perl ./runtest.pl all -t
27+time: runtest
28+ @./runtest all -t
2129
2230distclean:
23− rm -f *~
24− rm -f */output
31+ @rm runtest
32+ @rm -f *~
33+ @rm -f */output
test/basic001/run+2−2
@@ -1,6 +1,6 @@
11#!/usr/bin/env bash
2−idris $@ reg005.idr -o reg005
3−idris $@ basic001a.idr -o basic001a
2+${IDRIS:-idris} $@ reg005.idr -o reg005
3+${IDRIS:-idris} $@ basic001a.idr -o basic001a
44./reg005
55./basic001a
66rm -f reg005 basic001a *.ibc
test/basic002/run+1−1
@@ -1,4 +1,4 @@
11#!/usr/bin/env bash
2−idris $@ --nocolour --consolewidth 80 test006.idr -o test006
2+${IDRIS:-idris} $@ --nocolour --consolewidth 80 test006.idr -o test006
33./test006
44rm -f test006 test006.ibc
test/basic003/run+1−1
@@ -1,4 +1,4 @@
11#!/usr/bin/env bash
2−idris $@ test027.idr -o test027
2+${IDRIS:-idris} $@ test027.idr -o test027
33./test027
44rm -f test027 *.ibc
test/basic004/run+1−1
@@ -1,4 +1,4 @@
11#!/usr/bin/env bash
2−idris $@ test016.idr -o test016
2+${IDRIS:-idris} $@ test016.idr -o test016
33./test016
44rm -f test016 *.ibc
test/basic005/run+1−1
@@ -1,4 +1,4 @@
11#!/usr/bin/env bash
2−idris $@ test019.lidr -o test019
2+${IDRIS:-idris} $@ test019.lidr -o test019
33./test019
44rm -f test019 *.ibc
test/basic006/run+2−2
@@ -1,6 +1,6 @@
11#!/usr/bin/env bash
22
3−idris --consolewidth 80 $@ test020.idr -o test020
4−idris --consolewidth 80 $@ test020a.idr --check --nocolor
3+${IDRIS:-idris} --consolewidth 80 $@ test020.idr -o test020
4+${IDRIS:-idris} --consolewidth 80 $@ test020a.idr --check --nocolor
55./test020
66rm -f test020 *.ibc
test/basic007/run+1−1
@@ -1,4 +1,4 @@
11#!/usr/bin/env bash
2−idris $@ -o test033 test033.idr
2+${IDRIS:-idris} $@ -o test033 test033.idr
33./test033
44rm -f *.ibc test033
test/basic008/run+1−1
@@ -1,4 +1,4 @@
11#!/usr/bin/env bash
2−idris $@ test036.idr -o test036
2+${IDRIS:-idris} $@ test036.idr -o test036
33./test036
44rm -f test036 *.ibc
test/basic009/A.idr+1
@@ -1,4 +1,5 @@
11module A
22
3+public export
34num : Nat
45num = 0
test/basic009/B/C.idr+1
@@ -1,4 +1,5 @@
11module B.C
22
3+public export
34num : Nat
45num = 1
test/basic009/run+3−3
@@ -1,8 +1,8 @@
11#!/usr/bin/env bash
22
3−idris --consolewidth 80 $@ Main.idr --nocolour --check && echo MAIN-PASS
4−idris --consolewidth 80 $@ Faulty.idr --nocolour --check && echo FAULTY-PASS
5−idris --consolewidth 80 $@ Multiple.idr --nocolour --check && echo MULTIPLE-PASS
3+${IDRIS:-idris} --consolewidth 80 $@ Main.idr --nocolour --check && echo MAIN-PASS
4+${IDRIS:-idris} --consolewidth 80 $@ Faulty.idr --nocolour --check && echo FAULTY-PASS
5+${IDRIS:-idris} --consolewidth 80 $@ Multiple.idr --nocolour --check && echo MULTIPLE-PASS
66
77
88rm -f *.ibc B/*.ibc
test/basic011/run+1−1
@@ -1,4 +1,4 @@
11#!/usr/bin/env bash
2−idris $@ basic011.idr -p contrib -o basic011
2+${IDRIS:-idris} $@ basic011.idr -p contrib -o basic011
33./basic011
44rm -f basic011 *.ibc
test/basic012/run+1−1
@@ -1,4 +1,4 @@
11#!/usr/bin/env bash
2−idris $@ basic012.idr -o basic012
2+${IDRIS:-idris} $@ basic012.idr -o basic012
33./basic012
44rm -f basic012 *.ibc
test/basic013/run+1−1
@@ -1,4 +1,4 @@
11#!/usr/bin/env bash
2−idris $@ basic013.idr -o basic013
2+${IDRIS:-idris} $@ basic013.idr -o basic013
33./basic013
44rm -f basic013 *.ibc
test/basic014/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris $@ basic014.idr --check
2+${IDRIS:-idris} $@ basic014.idr --check
33rm -f *.ibc
test/basic015/run+1−1
@@ -1,4 +1,4 @@
11#!/usr/bin/env bash
2−idris $@ basic015.idr -o basic015
2+${IDRIS:-idris} $@ basic015.idr -o basic015
33./basic015
44rm -f basic015 *.ibc
test/basic016/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris $@ CycleA.idr --consolewidth 80 --nocolour --check
2+${IDRIS:-idris} $@ CycleA.idr --consolewidth 80 --nocolour --check
33rm -f *.ibc
test/bignum001/run+1−1
@@ -1,4 +1,4 @@
11#!/usr/bin/env bash
2−idris $@ bignum001.idr -o bignum001
2+${IDRIS:-idris} $@ bignum001.idr -o bignum001
33./bignum001
44rm -f bignum001 *.ibc
test/bignum002/run+1−1
@@ -1,4 +1,4 @@
11#!/usr/bin/env bash
2−idris $@ bignum002.idr -o bignum002
2+${IDRIS:-idris} $@ bignum002.idr -o bignum002
33./bignum002
44rm -f bignum002 *.ibc
test/bounded001/run+1−1
@@ -1,4 +1,4 @@
11#!/usr/bin/env bash
2−idris $@ bounded001.idr -o bounded001
2+${IDRIS:-idris} $@ bounded001.idr -o bounded001
33./bounded001
44rm -f bounded001 *.ibc
test/classes001/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris $@ --quiet --nocolour --consolewidth 70 ClassName.idr < input
2+${IDRIS:-idris} $@ --quiet --nocolour --consolewidth 70 ClassName.idr < input
33rm -f bounded001 *.ibc
test/corecords001/run+1−1
@@ -1,4 +1,4 @@
11#!/usr/bin/env bash
2−idris $@ corecords001.idr -o corecords001
2+${IDRIS:-idris} $@ corecords001.idr -o corecords001
33./corecords001
44rm -f corecords001 corecords001.ibc
test/corecords002/run+1−1
@@ -1,4 +1,4 @@
11#!/usr/bin/env bash
2−idris $@ corecords002.idr -o corecords002
2+${IDRIS:-idris} $@ corecords002.idr -o corecords002
33./corecords002
44rm -f corecords002 corecords002.ibc
test/delab001/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris $@ --quiet --nocolor delab001.idr < input
2+${IDRIS:-idris} $@ --quiet --nocolor delab001.idr < input
33rm -f *.ibc
test/disambig002/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris $@ disambig002.idr --check
2+${IDRIS:-idris} $@ disambig002.idr --check
33rm -f *.ibc
test/docs001/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris --quiet --nocolor --consolewidth 80 docs001.idr < input
2+${IDRIS:-idris} --quiet --nocolor --consolewidth 80 docs001.idr < input
33rm *.ibc
test/docs002/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris --consolewidth 80 --nobanner --nocolor --quiet docs002.idr < input
2+${IDRIS:-idris} --consolewidth 80 --nobanner --nocolor --quiet docs002.idr < input
33rm *.ibc
test/docs003/expected+1−1
@@ -5,7 +5,7 @@ Parameters:
55 f -- a parameterised type
66
77Methods:
8− map : Functor f => (m : a -> b) -> f a -> f b
8+ map : Functor f => (func : a -> b) -> f a -> f b
99 Apply a function across everything of type 'a' in a
1010 parameterised type
1111
test/docs003/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris --consolewidth 80 --quiet --nocolor docs003.idr < input
2+${IDRIS:-idris} --consolewidth 80 --quiet --nocolor docs003.idr < input
33rm *.ibc
test/docs004/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris --quiet --nocolor --consolewidth 80 docs004.idr < input
2+${IDRIS:-idris} --quiet --nocolor --consolewidth 80 docs004.idr < input
33rm *.ibc
test/dsl001/run+1−1
@@ -1,4 +1,4 @@
11#!/usr/bin/env bash
2−idris $@ test001.idr -o test001
2+${IDRIS:-idris} $@ test001.idr -o test001
33./test001
44rm -f test001 test001.ibc
test/dsl001/test001.idr+1−1
@@ -45,7 +45,7 @@ using (G : Vect n Ty)
4545 index_next = Pop
4646
4747 total
48− interp : Env G -> [static] (e : Expr G t) -> interpTy t
48+ interp : Env G -> %static (e : Expr G t) -> interpTy t
4949 interp env (Var i) = lookup i env
5050 interp env (Val x) = x
5151 interp env (Lam sc) = \x => interp (x :: env) sc
test/dsl002/Resimp.idr+3−1
@@ -3,6 +3,8 @@ module Resimp
33import public Data.Vect
44import public Data.Fin
55
6+%access public export
7+
68-- IO operations which read a resource
79data Reader : Type -> Type where
810 MkReader : IO a -> Reader a
@@ -122,7 +124,7 @@ using (i: Fin n, gam : Vect n Ty, gam' : Vect n Ty, gam'' : Vect n Ty)
122124 ioret : a -> IO a
123125 ioret = return
124126
125− interp : Env gam -> [static] (e : Res gam gam' t) ->
127+ interp : Env gam -> %static (e : Res gam gam' t) ->
126128 (Env gam' -> interpTy t -> IO u) -> IO u
127129
128130 interp env (Let val scope) k
test/dsl002/run+1−1
@@ -1,4 +1,4 @@
11#!/usr/bin/env bash
2−idris $@ test014.idr -o test014
2+${IDRIS:-idris} $@ test014.idr -o test014
33./test014
44rm -f test014 Resimp.ibc test014.ibc
test/dsl003/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris $@ --nocolour --check DSLPi.idr -e test1 -e test2
2+${IDRIS:-idris} $@ --nocolour --check DSLPi.idr -e test1 -e test2
33rm -f *.ibc
test/dsl004/run+3−3
@@ -1,5 +1,5 @@
11#!/usr/bin/env bash
2−idris $@ Door0.idr --check
3−idris $@ Door1.idr --check
4−idris $@ Door2.idr --check
2+${IDRIS:-idris} $@ Door0.idr --check
3+${IDRIS:-idris} $@ Door1.idr --check
4+${IDRIS:-idris} $@ Door2.idr --check
55rm -f *.ibc
test/effects001/run+2−2
@@ -1,6 +1,6 @@
11#!/usr/bin/env bash
2−idris -p effects $@ test021.idr -o test021
3−idris -p effects $@ test021a.idr -o test021a
2+${IDRIS:-idris} -p effects $@ test021.idr -o test021
3+${IDRIS:-idris} -p effects $@ test021a.idr -o test021a
44./test021
55./test021a
66rm -f test021 test021a *.ibc
test/effects002/run+1−1
@@ -1,4 +1,4 @@
11#!/usr/bin/env bash
2−idris -p effects $@ test025.idr -o test025
2+${IDRIS:-idris} -p effects $@ test025.idr -o test025
33./test025
44rm -f test025 *.ibc
test/effects003/VectMissing.idr+1
@@ -6,6 +6,7 @@ import Data.Vect
66implementation Uninhabited (Elem x []) where
77 uninhabited Here impossible
88
9+export
910shrink : (xs : Vect (S n) a) -> Elem x xs -> Vect n a
1011shrink (x :: ys) Here = ys
1112shrink (y :: []) (There p) = absurd p
test/effects003/run+1−1
@@ -1,4 +1,4 @@
11#!/usr/bin/env bash
2−idris $@ hangman.idr --consolewidth 80 --nocolour -p effects -o hangman
2+${IDRIS:-idris} $@ hangman.idr --consolewidth 80 --nocolour -p effects -o hangman
33./hangman < input
44rm -f hangman *.ibc
test/effects004/run+1−1
@@ -1,4 +1,4 @@
11#!/usr/bin/env bash
2−idris $@ effects004.idr -o effects004 -p effects
2+${IDRIS:-idris} $@ effects004.idr -o effects004 -p effects
33./effects004 < input
44rm -f effects004 *.ibc
test/effects005/run+2−2
@@ -1,6 +1,6 @@
11#!/usr/bin/env bash
2−idris $@ defaultLogger.idr -o default -p effects
2+${IDRIS:-idris} $@ defaultLogger.idr -o default -p effects
33./default
4−idris $@ categoryLogger.idr -o category -p effects
4+${IDRIS:-idris} $@ categoryLogger.idr -o category -p effects
55./category
66rm -f default category *.ibc
test/error001/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris $@ test002.idr --check --noprelude --consolewidth 70
2+${IDRIS:-idris} $@ test002.idr --check --noprelude --consolewidth 70
33rm -f *.ibc
test/error002/run+1−1
@@ -1,4 +1,4 @@
11#!/usr/bin/env bash
2−idris $@ test031.idr -o test031
2+${IDRIS:-idris} $@ test031.idr -o test031
33./test031
44rm -f test031 *.ibc
test/error003/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris --consolewidth 80 $@ ErrorReflection.idr --nocolour --check
2+${IDRIS:-idris} --consolewidth 80 $@ ErrorReflection.idr --nocolour --check
33rm -f *.ibc
test/error004/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris --consolewidth 80 $@ FunErrTest.idr --nocolour --check
2+${IDRIS:-idris} --consolewidth 80 $@ FunErrTest.idr --nocolour --check
33rm -f *.ibc
test/error005/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris --consolewidth 80 $@ --check --nocolour error005.idr
2+${IDRIS:-idris} --consolewidth 80 $@ --check --nocolour error005.idr
33rm -f *.ibc
test/error006/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris --consolewidth 80 $@ --check --nocolour WithPatsNoWith.idr
2+${IDRIS:-idris} --consolewidth 80 $@ --check --nocolour WithPatsNoWith.idr
33rm -f *.ibc
test/ffi001/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris --quiet --nocolour test022.idr --exec main
2+${IDRIS:-idris} --quiet --nocolour test022.idr --exec main
33rm -f *.ibc
test/ffi002/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris --consolewidth 80 --quiet test023.idr -o test023
2+${IDRIS:-idris} --consolewidth 80 --quiet test023.idr -o test023
33rm -f test023 *.ibc
test/ffi003/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris --quiet --nocolour test024.idr --exec main < input
2+${IDRIS:-idris} --quiet --nocolour test024.idr --exec main < input
33rm -f *.ibc
test/ffi004/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris --quiet --nocolour --check test026.idr
2+${IDRIS:-idris} --quiet --nocolour --check test026.idr
33rm -f *.ibc
test/ffi005/run+1−1
@@ -1,5 +1,5 @@
11#!/usr/bin/env bash
22
3−idris $@ Postulate.idr -o postulate
3+${IDRIS:-idris} $@ Postulate.idr -o postulate
44./postulate
55rm -f postulate *.ibc
test/ffi006/run+1−1
@@ -1,5 +1,5 @@
11#!/usr/bin/env bash
2−idris $@ ffi006.idr --interface -o ffi006.o
2+${IDRIS:-idris} $@ ffi006.idr --interface -o ffi006.o
33${CC:=cc} ffi006.c ffi006.o `idris --include` `idris --link` -o ffi006
44./ffi006
55rm -f ffi006 *.ibc *.o *.h
test/folding001/run+1−1
@@ -1,4 +1,4 @@
11#!/usr/bin/env bash
2−idris $@ folding001.idr -o folding001
2+${IDRIS:-idris} $@ folding001.idr -o folding001
33./folding001
44rm -f folding001 *.ibc
test/idrisdoc001/run+1−1
@@ -1,4 +1,4 @@
11#!/usr/bin/env bash
22# Tests that no documentation is built for empty and/or private-only namespaces
3−idris --mkdoc test_empty.ipkg
3+${IDRIS:-idris} --mkdoc test_empty.ipkg
44rm -rf *.ibc *_doc
test/idrisdoc002/TestFunctions.idr+2−1
@@ -1,5 +1,6 @@
11module TestFunctions
22
33||| Test function
4+public export
45test : ()
5−test = ()
6+test = ()
test/idrisdoc002/run+1−1
@@ -1,5 +1,5 @@
11#!/usr/bin/env bash
22# Tests that documentation is generated for functions
3−idris --mkdoc test_functions.ipkg
3+${IDRIS:-idris} --mkdoc test_functions.ipkg
44[ -d test_functions_doc ] && echo "Functions are documented"
55rm -rf *.ibc *_doc
test/idrisdoc003/TestDatatypes.idr+2−1
@@ -1,6 +1,7 @@
11module TestDatatypes
22
33||| This is another test
4+public export
45data Test : Type where
56 ||| Test constructor
6− ATest : Test
7+ ATest : Test
test/idrisdoc003/run+1−1
@@ -1,5 +1,5 @@
11#!/usr/bin/env bash
22# Tests that documentation is generated for data types
3−idris --mkdoc test_datatypes.ipkg
3+${IDRIS:-idris} --mkdoc test_datatypes.ipkg
44[ -d test_datatypes_doc ] && echo "Data types are documented"
55rm -rf *.ibc *_doc
test/idrisdoc004/TestTypeclasses.idr+1
@@ -3,6 +3,7 @@ module TestTypeclasses
33||| This is a test
44|||
55||| @ a Test arg
6+public export
67interface Test a where
78 ||| Test function
89 test : a -> Int
test/idrisdoc004/run+1−1
@@ -1,5 +1,5 @@
11#!/usr/bin/env bash
22# Tests that documentation is generated for typeclasses
3−idris --mkdoc test_typeclasses.ipkg
3+${IDRIS:-idris} --mkdoc test_typeclasses.ipkg
44[ -d test_typeclasses_doc ] && echo "Typeclasses are documented"
55rm -rf *.ibc *_doc
test/idrisdoc005/TestTracing.idr+2−1
@@ -1,4 +1,5 @@
11module TestTracing
22
3+public export
34test : Bool
4−test = True
5+test = True
test/idrisdoc005/run+1−1
@@ -1,6 +1,6 @@
11#!/usr/bin/env bash
22# Tests that references to other namespaces are traced
3−idris --mkdoc test_tracing.ipkg
3+${IDRIS:-idris} --mkdoc test_tracing.ipkg
44[ -f test_tracing_doc/docs/TestTracing.html ] && echo "TestTracing: Check"
55[ -f test_tracing_doc/docs/Prelude.Bool.html ] && echo "Prelude.Bool: Check"
66rm -rf *.ibc *_doc
test/idrisdoc006/A/fully/Qualified/NAME.idr+2−2
@@ -1,6 +1,6 @@
11module A.fully.Qualified.NAME
22
33||| This is another test
4−data Test : Type where
4+public export data Test : Type where
55 ||| Test constructor
6− ATest : Test
6+ ATest : Test
test/idrisdoc006/B.idr+2−1
@@ -1,5 +1,6 @@
11module B
22
33||| Test function
4+public export
45test : ()
5−test = ()
6+test = ()
test/idrisdoc006/run+2−2
@@ -1,8 +1,8 @@
11#!/usr/bin/env bash
22# Tests that documentation properly is merged with existent.
3−idris --mkdoc package_a.ipkg
3+${IDRIS:-idris} --mkdoc package_a.ipkg
44[ -f test_merge_doc/IdrisDoc ] && echo "IdrisDoc file written"
5−idris --mkdoc package_b.ipkg
5+${IDRIS:-idris} --mkdoc package_b.ipkg
66ls -1p test_merge_doc/docs
77if grep -q "href\\=\"docs/A.fully.Qualified.NAME\\.html\"" test_merge_doc/index.html; then
88 echo A.fully.Qualified.NAME is in the index
test/idrisdoc007/run+1−1
@@ -1,6 +1,6 @@
11#!/usr/bin/env bash
22# Tests that documentation only is written when safe
33mkdir do_not_delete_doc
4−idris --mkdoc package.ipkg > nowhere
4+${IDRIS:-idris} --mkdoc package.ipkg > nowhere
55echo Exit status \(expects 1\): $?
66rm -rf do_not_delete_doc *.ibc nowhere
test/idrisdoc008/Abstract.idr+2−2
@@ -1,5 +1,5 @@
11module Abstract
22
3−abstract
3+export
44frozen : ()
5−frozen = ()
5+frozen = ()
test/idrisdoc008/Visible.idr+2−2
@@ -1,5 +1,5 @@
11module Visible
22
3−public
3+public export
44visible : ()
5−visible = ()
5+visible = ()
test/idrisdoc008/run+1−1
@@ -1,6 +1,6 @@
11#!/usr/bin/env bash
22# Tests that documentation is generated for both public and abstract members.
3−idris --mkdoc visibility.ipkg
3+${IDRIS:-idris} --mkdoc visibility.ipkg
44[ -f visibility_doc/docs/Abstract.html ] && echo "Abstract members are documented"
55[ -f visibility_doc/docs/Visible.html ] && echo "Public members are documented"
66rm -rf *.ibc *_doc
test/idrisdoc009/Test.idr+2
@@ -23,6 +23,8 @@
2323module Test
2424import Data.Complex
2525
26+%access public export
27+
2628myplus : Nat -> Nat -> Nat
2729myplus Z j = j
2830myplus (S k) j = S (myplus k j)
test/idrisdoc009/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris $@ --nocolour --quiet Test.idr < input
2+${IDRIS:-idris} $@ --nocolour --quiet Test.idr < input
33rm -f *.ibc
test/interactive001/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris --quiet test032.idr < input
2+${IDRIS:-idris} --quiet test032.idr < input
33rm -f *.ibc
test/interactive002/expected+1−1
@@ -5,6 +5,6 @@ Nat
55Vect (n + m) a
66Nat
77Nat
8−S n
8+(S n)
99String
1010()
test/interactive002/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris --quiet interactive002.idr < input
2+${IDRIS:-idris} --quiet interactive002.idr < input
33rm -f *.ibc
test/interactive003/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris --quiet interactive003.idr < input
2+${IDRIS:-idris} --quiet interactive003.idr < input
33rm -f *.ibc
test/interactive004/expected+1−1
@@ -1,2 +1,2 @@
11plus ?foo_rhs2 ?foo_rhs3
2−append k m ?append_rhs2 ?append_rhs3
2+(append k m ?append_rhs2 ?append_rhs3)
test/interactive004/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris --quiet interactive004.idr < input
2+${IDRIS:-idris} --quiet interactive004.idr < input
33rm -f *.ibc
test/interactive005/run+1−1
@@ -1,5 +1,5 @@
11#!/usr/bin/env bash
2−idris --nocolour --quiet interactive005.idr --consolewidth 70 < input
2+${IDRIS:-idris} --nocolour --quiet interactive005.idr --consolewidth 70 < input
33rm -f *.ibc
44rm -f hello.bytecode
55rm -f hello
test/interactive006/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris --quiet --port 5000 interactive006.idr < input
2+${IDRIS:-idris} --quiet --port 5000 interactive006.idr < input
33rm -f *.ibc
test/interactive007/run+1−1
@@ -1,2 +1,2 @@
11#!/usr/bin/env bash
2−idris -p contrib --nobanner --nocolor < input
2+${IDRIS:-idris} -p contrib --nobanner --nocolor < input
test/interactive008/run+1−1
@@ -1,2 +1,2 @@
11#!/usr/bin/env bash
2−idris --nobanner --nocolor < input
2+${IDRIS:-idris} --nobanner --nocolor < input
test/interactive009/expected+1−1
@@ -1 +1 @@
1−IsSetCons pf prfRec
1+(IsSetCons pf prfRec)
test/interactive009/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris --quiet interactive009.idr < input
2+${IDRIS:-idris} --quiet interactive009.idr < input
33rm -f *.ibc
test/interactive010/expected+4−4
@@ -1,12 +1,12 @@
11Prelude.List.(++) : List a -> List a -> List a
22Prelude.Strings.(++) : String -> String -> String
3−a is not an implicit argument of Prelude.Classes./
3+a is not an implicit argument of Prelude.Interfaces./
44Usage is :doc <functionname>
55Usage is :wc <functionname>
66Usage is :printdef <functionname>
7−pat {ty504} : Type u. pat {__class505} : Prelude.Classes.Fractional {ty504}. Prelude.Classes./ {ty504} {__class505}
7+pat {ty504} : Type u. pat {__class505} : Prelude.Interfaces.Fractional {ty504}. Prelude.Interfaces./ {ty504} {__class505}
88
9− : pty {ty504} : Type u. pty {__class505} : Prelude.Classes.Fractional {ty504}. {ty504} -> {ty504} -> {ty504}
9+ : pty {ty504} : Type u. pty {__class505} : Prelude.Interfaces.Fractional {ty504}. {ty504} -> {ty504} -> {ty504}
1010(input):1:1: error: expected: ":",
1111 dependent type signature,
1212 end of input
@@ -17,4 +17,4 @@ pat {ty504} : Type u. pat {__class505} : Prelude.Classes.Fractional {ty504}. Pre
1717 end of input
1818++<EOF>
1919^
20−Can't resolve type class Fractional ty
20+Can't find implementation for Fractional ty
test/interactive010/run+1−1
@@ -1,2 +1,2 @@
11#!/usr/bin/env bash
2−idris --quiet --nobanner --nocolor --consolewidth 80 < input
2+${IDRIS:-idris} --quiet --nobanner --nocolor --consolewidth 80 < input
test/interactive011/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris --quiet interactive011.idr < input
2+${IDRIS:-idris} --quiet interactive011.idr < input
33rm -f *.ibc
test/interactive012/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris --nocolour --consolewidth 70 --quiet interactive012.idr < input
2+${IDRIS:-idris} --nocolour --consolewidth 70 --quiet interactive012.idr < input
33rm -f *.ibc
test/io001/run+1−1
@@ -1,4 +1,4 @@
11#!/usr/bin/env bash
2−idris $@ test004.idr -o test004
2+${IDRIS:-idris} $@ test004.idr -o test004
33./test004
44rm -f test004 test004.ibc testfile
test/io002/run+1−1
@@ -1,4 +1,4 @@
11#!/usr/bin/env bash
2−idris $@ test008.idr -o test008
2+${IDRIS:-idris} $@ test008.idr -o test008
33./test008
44rm -f test008 test008.ibc
test/io003/run+2−2
@@ -1,6 +1,6 @@
11#!/usr/bin/env bash
2−idris $@ test018.idr -p contrib -o test018
3−idris $@ test018a.idr -p contrib -o test018a
2+${IDRIS:-idris} $@ test018.idr -p contrib -o test018
3+${IDRIS:-idris} $@ test018a.idr -p contrib -o test018a
44./test018
55#./test018a
66rm -f test018 test018a *.ibc
test/literate001/Lit.lidr+2−2
@@ -2,12 +2,12 @@
22
33Test some string primitives while we're at it
44
5−> st : String
5+> export st : String
66> st = "abcdefg"
77
88Literate main program
99
10−> main : IO ()
10+> export main : IO ()
1111> main = do { putStrLn (show (strHead st))
1212> putStrLn (show (strIndex st 3))
1313> putStrLn (strCons 'z' st)
test/literate001/run+2−2
@@ -1,5 +1,5 @@
11#!/usr/bin/env bash
2−idris --consolewidth 80 $@ test003a.lidr --check
3−idris --consolewidth 80 $@ test003.lidr -o test003
2+${IDRIS:-idris} --consolewidth 80 $@ test003a.lidr --check
3+${IDRIS:-idris} --consolewidth 80 $@ test003.lidr -o test003
44./test003
55rm -f test003 test003.ibc Lit.ibc
test/meta001/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris $@ --check --nocolour --consolewidth 70 Finite.idr
2+${IDRIS:-idris} $@ --check --nocolour --consolewidth 70 Finite.idr
33rm -f *.ibc
test/meta002/run+2−2
@@ -1,6 +1,6 @@
11#!/usr/bin/env bash
2−idris $@ -p pruviloj --nocolour --check --consolewidth 70 Tacs.idr
3−idris $@ -p pruviloj --nocolour --check --consolewidth 70 AgdaStyleReflection.idr
2+${IDRIS:-idris} $@ -p pruviloj --nocolour --check --consolewidth 70 Tacs.idr
3+${IDRIS:-idris} $@ -p pruviloj --nocolour --check --consolewidth 70 AgdaStyleReflection.idr
44# Disabled due to excess memory consumption
55# idris $@ -p pruviloj --nocolour --check --consolewidth 70 Deriving.idr
66rm -f *.ibc
test/meta003/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris $@ --nocolour --check --consolewidth 70 BadDef.idr
2+${IDRIS:-idris} $@ --nocolour --check --consolewidth 70 BadDef.idr
33rm -f *.ibc
test/meta004/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris $@ -p pruviloj --nocolour --check --consolewidth 70 meta004.idr
2+${IDRIS:-idris} $@ -p pruviloj --nocolour --check --consolewidth 70 meta004.idr
33rm -f *.ibc
test/mktest.pl+1−1
@@ -13,7 +13,7 @@ chdir($test);
1313open(FOO,">run");
1414
1515print FOO "#!/usr/bin/env bash\n";
16−print FOO "idris \$@ $test.idr -o $test\n";
16+print FOO "${IDRIS:-idris} \$@ $test.idr -o $test\n";
1717print FOO "./$test\n";print FOO "rm -f $test *.ibc\n";
1818
1919close(FOO);
test/pkg001/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris $@ --build test.ipkg
2+${IDRIS:-idris} $@ --build test.ipkg
33rm -f *.ibc
test/pkg002/run+1−1
@@ -1,5 +1,5 @@
11#!/usr/bin/env bash
22### Test: IPKG executable names can be any namespaced identifier.
3−idris $@ --build test.ipkg
3+${IDRIS:-idris} $@ --build test.ipkg
44rm -f *.ibc
55rm -f some.namespaced.identifier
test/pkg003/run+1−1
@@ -1,6 +1,6 @@
11#!/usr/bin/env bash
22### Test: IPKG executable names can be a quoted string
33### containing a valid filename.
4−idris $@ --build test.ipkg
4+${IDRIS:-idris} $@ --build test.ipkg
55rm -f *.ibc
66rm -f 'quoting-allows-hyphens and spaces and fun stuff!'
test/pkg004/expected+3−3
@@ -1,5 +1,5 @@
1−Uncaught error: user error (test.ipkg:10:1: error: filename
1+Uncaught error: user error (test.ipkg:9:1: error: filename
22 must contain no directory
33 component, expected: space
4−<EOF>
5−^ )
4+<EOF>
5+^ )
test/pkg004/run+1−1
@@ -2,5 +2,5 @@
22### Test: IPKG executable names CANNOT include a directory separator.
33# TODO: Verify that a name like "a/b\c" is rejected by both *NIX and Windows
44# (assuming these tests get run on Windows).
5−idris $@ --consolewidth 80 --nobanner --nocolor --build test.ipkg
5+${IDRIS:-idris} $@ --build test.ipkg
66rm -f *.ibc
test/pkg004/test.ipkg−1
@@ -2,7 +2,6 @@ package test
22
33modules = Main
44
5−
65opts = "--warnpartial --warnreach --nocolour --quiet --consolewidth 80"
76
87main = Main
test/primitives001/run+2−2
@@ -1,6 +1,6 @@
11#!/usr/bin/env bash
2−idris $@ test005.idr -o test005
2+${IDRIS:-idris} $@ test005.idr -o test005
33./test005
4−idris $@ substring.idr -o substring
4+${IDRIS:-idris} $@ substring.idr -o substring
55./substring < input
66rm -f test005 substring *.ibc
test/primitives003/run+1−1
@@ -1,5 +1,5 @@
11#!/usr/bin/env bash
2−idris $@ -o test038 test038.idr --nocolour
2+${IDRIS:-idris} $@ -o test038 test038.idr --nocolour
33./test038
44rm -f test038 *.ibc
55
test/primitives004-disabled/run+1−1
@@ -1,4 +1,4 @@
11#!/usr/bin/env bash
2−idris $@ -o primitives004 primitives004.idr --nocolour
2+${IDRIS:-idris} $@ -o primitives004 primitives004.idr --nocolour
33./primitives004
44rm -f primitives004 *.ibc
test/proof001/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris $@ test029.idr --consolewidth 80 --nocolour --check test029
2+${IDRIS:-idris} $@ test029.idr --consolewidth 80 --nocolour --check test029
33rm -f *.ibc
test/proof002/Reflect.idr+1
@@ -2,6 +2,7 @@ module Reflect
22
33import Decidable.Equality
44
5+%access public export
56%default total
67
78using (xs : List a, ys : List a, G : List (List a))
test/proof002/expected+3−3
@@ -1,8 +1,8 @@
1−Reflect.idr:173:21-26:
1+Reflect.idr:174:21-26:
22This style of tactic proof is deprecated. See %runElab for the replacement.
3−Reflect.idr:182:21-26:
3+Reflect.idr:183:21-26:
44This style of tactic proof is deprecated. See %runElab for the replacement.
5−Reflect.idr:190:15-20:
5+Reflect.idr:191:15-20:
66This style of tactic proof is deprecated. See %runElab for the replacement.
77test030a.idr:12:26-14:1:
88When checking right hand side of testReflect1 with expected type
test/proof002/run+2−2
@@ -1,4 +1,4 @@
11#!/usr/bin/env bash
2−idris --consolewidth 80 $@ test030.idr --check --nocolour
3−idris --consolewidth 80 $@ test030a.idr --check --nocolour
2+${IDRIS:-idris} --consolewidth 80 $@ test030.idr --check --nocolour
3+${IDRIS:-idris} --consolewidth 80 $@ test030a.idr --check --nocolour
44rm -f *.ibc
test/proof003/Parity.idr+2
@@ -1,5 +1,7 @@
11module Parity
22
3+%access public export
4+
35data Parity : Nat -> Type where
46 Even : {n : Nat} -> Parity (n + n)
57 Odd : {n : Nat} -> Parity (S (n + n))
test/proof003/expected+2−2
@@ -1,6 +1,6 @@
1−Parity.idr:15:18-23:
1+Parity.idr:17:18-23:
22This style of tactic proof is deprecated. See %runElab for the replacement.
3−Parity.idr:22:18-23:
3+Parity.idr:24:18-23:
44This style of tactic proof is deprecated. See %runElab for the replacement.
55test015.idr:88:15-20:
66This style of tactic proof is deprecated. See %runElab for the replacement.
test/proof003/run+1−1
@@ -1,4 +1,4 @@
11#!/usr/bin/env bash
2−idris $@ test015.idr --nocolour --consolewidth 80 -o test015
2+${IDRIS:-idris} $@ test015.idr --nocolour --consolewidth 80 -o test015
33./test015
44rm -f test015 Parity.ibc test015.ibc
test/proof004/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris --check $@ test035.idr
2+${IDRIS:-idris} --check $@ test035.idr
33rm -f *.ibc
test/proof005/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris --check $@ DefaultArgSubstitutionSuccess.idr
2+${IDRIS:-idris} --check $@ DefaultArgSubstitutionSuccess.idr
33rm -f *.ibc
test/proof006/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris --check $@ DefaultArgSubstitutionSyntax.idr
2+${IDRIS:-idris} --check $@ DefaultArgSubstitutionSyntax.idr
33rm -f *.ibc
test/proof007/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris --nocolour --consolewidth 80 --check $@ DefaultArgUnknownName.idr
2+${IDRIS:-idris} --nocolour --consolewidth 80 --check $@ DefaultArgUnknownName.idr
33rm -f *.ibc
test/proof008/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris --nocolour --consolewidth 80 --check $@ ClaimAndUnfocus.idr
2+${IDRIS:-idris} --nocolour --consolewidth 80 --check $@ ClaimAndUnfocus.idr
33rm -f *.ibc
test/proof009/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris $@ --consolewidth 70 --quiet proof009.idr < input
2+${IDRIS:-idris} $@ --consolewidth 70 --quiet proof009.idr < input
33rm -f *.ibc
test/proof010/run+1−1
@@ -1,4 +1,4 @@
11#!/usr/bin/env bash
2−idris $@ proof010.idr -o proof010
2+${IDRIS:-idris} $@ proof010.idr -o proof010
33./proof010
44rm -f proof010 *.ibc
test/proofsearch001/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris $@ --check proofsearch001.idr
2+${IDRIS:-idris} $@ --check proofsearch001.idr
33rm -f *.ibc
test/proofsearch002/Process.idr+1−1
@@ -3,7 +3,7 @@ module Process
33import System.Concurrency.Raw
44import public Data.List -- public, to get proof search machinery
55
6−%access public
6+%access public export
77
88-- Process IDs are parameterised by their interface. A request of type
99-- 'iface t' will get a response of type 't'
test/proofsearch002/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris $@ --check proofsearch002.idr
2+${IDRIS:-idris} $@ --check proofsearch002.idr
33rm -f *.ibc
test/proofsearch003/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris --check proofsearch003.idr
2+${IDRIS:-idris} --check proofsearch003.idr
33rm -f *.ibc
test/pruviloj001/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris $@ -p pruviloj --check --nocolour --consolewidth 70 pruviloj001.idr
2+${IDRIS:-idris} $@ -p pruviloj --check --nocolour --consolewidth 70 pruviloj001.idr
33rm -f *.ibc
test/quasiquote001/run+1−1
@@ -1,4 +1,4 @@
11#!/usr/bin/env bash
2−idris $@ QuasiquoteBasics.idr -o quasiquote001
2+${IDRIS:-idris} $@ QuasiquoteBasics.idr -o quasiquote001
33./quasiquote001
44rm -f quasiquote001 *.ibc
test/quasiquote002/run+1−1
@@ -1,4 +1,4 @@
11#!/usr/bin/env bash
2−idris $@ GoalQQuote.idr -o quasiquote002
2+${IDRIS:-idris} $@ GoalQQuote.idr -o quasiquote002
33./quasiquote002
44rm -f quasiquote002 *.ibc
test/quasiquote003/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris --consolewidth 80 $@ --check NoInfer.idr
2+${IDRIS:-idris} --consolewidth 80 $@ --check NoInfer.idr
33rm -f *.ibc
test/quasiquote004/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris --consolewidth 80 $@ --check --nocolour Quasiquote004.idr
2+${IDRIS:-idris} --consolewidth 80 $@ --check --nocolour Quasiquote004.idr
33rm -f *.ibc
test/quasiquote005/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris $@ --check --nocolour Quasiquote005.idr
2+${IDRIS:-idris} $@ --check --nocolour Quasiquote005.idr
33rm -f *.ibc
test/quasiquote006/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris $@ --check --nocolour --quiet --consolewidth 70 quasiquote006.idr
2+${IDRIS:-idris} $@ --check --nocolour --quiet --consolewidth 70 quasiquote006.idr
33rm -f *.ibc
test/records001/run+1−1
@@ -1,4 +1,4 @@
11#!/usr/bin/env bash
2−idris $@ test011.idr -o test011
2+${IDRIS:-idris} $@ test011.idr -o test011
33./test011
44rm -f test011 test011.ibc
test/records002/run+1−1
@@ -1,4 +1,4 @@
11#!/usr/bin/env bash
2−idris $@ record002.idr -o record002
2+${IDRIS:-idris} $@ record002.idr -o record002
33./record002
44rm -f record002 *.ibc
test/records003/run+1−1
@@ -1,4 +1,4 @@
11#!/usr/bin/env bash
2−idris $@ records003.idr -o records003
2+${IDRIS:-idris} $@ records003.idr -o records003
33./records003
44rm -f records003 *.ibc
test/records004/run+1−1
@@ -1,4 +1,4 @@
11#!/usr/bin/env bash
2−idris $@ records004.idr -o records004
2+${IDRIS:-idris} $@ records004.idr -o records004
33./records004
44rm -f records004 *.ibc
test/reg001/run+1−1
@@ -1,4 +1,4 @@
11#!/usr/bin/env bash
2−idris reg001.idr --check
2+${IDRIS:-idris} reg001.idr --check
33rm -rf reg001.ibc
44
test/reg002/run+1−1
@@ -1,4 +1,4 @@
11#!/usr/bin/env bash
2−idris reg012.idr -o reg012
2+${IDRIS:-idris} reg012.idr -o reg012
33./reg012
44rm -f reg012 *.ibc
test/reg003/run+2−2
@@ -1,4 +1,4 @@
11#!/usr/bin/env bash
2−idris --consolewidth 80 --check reg003.idr
3−idris --consolewidth 80 --check reg003a.idr
2+${IDRIS:-idris} --consolewidth 80 --check reg003.idr
3+${IDRIS:-idris} --consolewidth 80 --check reg003a.idr
44rm -f *.ibc
test/reg004/run+1−1
@@ -1,4 +1,4 @@
11#!/usr/bin/env bash
2−idris $@ reg004.idr -o reg004
2+${IDRIS:-idris} $@ reg004.idr -o reg004
33./reg004
44rm -f reg004 *.ibc
test/reg005/expectednew file+3
@@ -0,0 +1,3 @@
1+hey
2+you
3+[(), ()]
test/reg005/reg005.idrnew file+9
@@ -0,0 +1,9 @@
1+module UPIO
2+
3+foo : List (IO ())
4+foo = [putStrLn "hey", putStrLn "you"]
5+
6+namespace Main
7+ main : IO ()
8+ main = let stuff = map unsafePerformIO foo in putStrLn (show stuff)
9+
test/reg005/runnew file+4
@@ -0,0 +1,4 @@
1+#!/usr/bin/env bash
2+${IDRIS:-idris} $@ reg005.idr -o reg005
3+./reg005
4+rm -f reg005 *.ibc
test/reg006/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris --consolewidth 80 $@ reg006.idr --check
2+${IDRIS:-idris} --consolewidth 80 $@ reg006.idr --check
33rm -f *.ibc
test/reg007/A.lidr+1−1
@@ -1,5 +1,5 @@
11> module A
22
3−> n : Nat
3+> public export n : Nat
44> n = ?lala
55
test/reg007/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris --consolewidth 80 --nocolour --check $@ reg007.lidr
2+${IDRIS:-idris} --consolewidth 80 --nocolour --check $@ reg007.lidr
33rm -f *.ibc
test/reg010/run+1−1
@@ -1,2 +1,2 @@
11#!/usr/bin/env bash
2−idris --consolewidth 80 $@ reg010.idr --check --nocolour
2+${IDRIS:-idris} --consolewidth 80 $@ reg010.idr --check --nocolour
test/reg013/run+1−1
@@ -1,4 +1,4 @@
11#!/usr/bin/env bash
2−idris $@ reg013.idr -o reg013
2+${IDRIS:-idris} $@ reg013.idr -o reg013
33./reg013
44rm -f reg013 *.ibc
test/reg016/run+1−1
@@ -1,4 +1,4 @@
11#!/usr/bin/env bash
2−idris $@ reg016.idr -o reg016
2+${IDRIS:-idris} $@ reg016.idr -o reg016
33./reg016
44rm -f reg016 *.ibc
test/reg017/run+1−1
@@ -1,4 +1,4 @@
11#!/usr/bin/env bash
2−idris $@ --nocolour --consolewidth 80 reg017.idr -o reg017
2+${IDRIS:-idris} $@ --nocolour --consolewidth 80 reg017.idr -o reg017
33./reg017
44rm -f reg017 *.ibc
test/reg018/run+4−4
@@ -1,6 +1,6 @@
11#!/usr/bin/env bash
2−idris --consolewidth 80 $@ reg018a.idr --check
3−idris --consolewidth 80 $@ reg018b.idr --check
4−idris --consolewidth 80 $@ reg018c.idr --check
5−idris --consolewidth 80 $@ reg018d.idr --check
2+${IDRIS:-idris} --consolewidth 80 $@ reg018a.idr --check
3+${IDRIS:-idris} --consolewidth 80 $@ reg018b.idr --check
4+${IDRIS:-idris} --consolewidth 80 $@ reg018c.idr --check
5+${IDRIS:-idris} --consolewidth 80 $@ reg018d.idr --check
66rm *.ibc
test/reg020/run+1−1
@@ -1,4 +1,4 @@
11#!/usr/bin/env bash
2−idris $@ reg020.idr -o reg020
2+${IDRIS:-idris} $@ reg020.idr -o reg020
33./reg020
44rm -f reg020 *.ibc
test/reg023/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris --nocolour --consolewidth 80 $@ reg023.idr --check
2+${IDRIS:-idris} --nocolour --consolewidth 80 $@ reg023.idr --check
33rm -f *.ibc
test/reg024/run+1−1
@@ -1,4 +1,4 @@
11#!/usr/bin/env bash
2−idris $@ reg024.idr -o reg024
2+${IDRIS:-idris} $@ reg024.idr -o reg024
33./reg024
44rm -f reg024 *.ibc
test/reg025/run+1−1
@@ -1,4 +1,4 @@
11#!/usr/bin/env bash
2−idris $@ reg025.idr -o reg025
2+${IDRIS:-idris} $@ reg025.idr -o reg025
33./reg025
44rm -f reg025 *.ibc
test/reg027/run+2−2
@@ -1,5 +1,5 @@
11#!/usr/bin/env bash
2−idris --consolewidth 80 $@ reg027.idr -o reg027
2+${IDRIS:-idris} --consolewidth 80 $@ reg027.idr -o reg027
33./reg027
4−idris --consolewidth 80 $@ reg027a.idr --check
4+${IDRIS:-idris} --consolewidth 80 $@ reg027a.idr --check
55rm -f reg027 *.ibc
test/reg028/run+2−2
@@ -1,4 +1,4 @@
11#!/usr/bin/env bash
2−idris --consolewidth 80 $@ reg028.idr --check
3−idris --consolewidth 80 $@ reg028a.idr --check
2+${IDRIS:-idris} --consolewidth 80 $@ reg028.idr --check
3+${IDRIS:-idris} --consolewidth 80 $@ reg028a.idr --check
44rm -f *.ibc
test/reg029/run+2−2
@@ -1,6 +1,6 @@
11#!/usr/bin/env bash
22
3−idris $@ reg029.idr -o reg029
3+${IDRIS:-idris} $@ reg029.idr -o reg029
44unset IDRIS_REG029_NONEXISTENT_VAR
55export IDRIS_REG029_EXISTENT_VAR='exists!'
66
@@ -12,6 +12,6 @@ else
1212 javac -cp reg029:. Reg029Wrapper.java
1313 java -cp reg029:. Reg029Wrapper
1414fi
15−idris $@ reg029.idr --execute
15+${IDRIS:-idris} $@ reg029.idr --execute
1616rm -f reg029 *.ibc *.class
1717
test/reg031/run+1−1
@@ -1,4 +1,4 @@
11#!/usr/bin/env bash
2−idris $@ reg031.idr -o reg031
2+${IDRIS:-idris} $@ reg031.idr -o reg031
33./reg031
44rm -f *.ibc reg031
test/reg032/run+1−1
@@ -1,4 +1,4 @@
11#!/usr/bin/env bash
2−idris $@ test028.idr -o test028
2+${IDRIS:-idris} $@ test028.idr -o test028
33./test028
44rm -f test028 test028.ibc
test/reg034/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris --nocolour --consolewidth 80 --check reg034.idr
2+${IDRIS:-idris} --nocolour --consolewidth 80 --check reg034.idr
33rm -f reg034 *.ibc
test/reg035/run+3−3
@@ -1,5 +1,5 @@
11#!/usr/bin/env bash
2−idris --nocolour --consolewidth 80 --check reg035.idr
3−idris --nocolour --consolewidth 80 --check reg035a.lidr
4−idris --nocolour --consolewidth 80 --check reg035b.idr
2+${IDRIS:-idris} --nocolour --consolewidth 80 --check reg035.idr
3+${IDRIS:-idris} --nocolour --consolewidth 80 --check reg035a.lidr
4+${IDRIS:-idris} --nocolour --consolewidth 80 --check reg035b.idr
55rm -f *.ibc
test/reg036/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris --check reg036.idr
2+${IDRIS:-idris} --check reg036.idr
33rm -f reg036 *.ibc
test/reg037/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris --check reg037.idr
2+${IDRIS:-idris} --check reg037.idr
33rm -f reg037 *.ibc
test/reg038/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris --check reg038.idr
2+${IDRIS:-idris} --check reg038.idr
33rm -f *.ibc
test/reg040/run+1−1
@@ -1,6 +1,6 @@
11#!/usr/bin/env bash
22
3−idris --warnreach reg040.idr -o reg040
3+${IDRIS:-idris} --warnreach reg040.idr -o reg040
44./reg040
55
66rm -f reg040 *.ibc
test/reg041/run+2−2
@@ -1,5 +1,5 @@
11#!/usr/bin/env bash
2−idris $@ --quiet ott.idr -e example
3−idris $@ showu.idr -o reg040
2+${IDRIS:-idris} $@ --quiet ott.idr -e example
3+${IDRIS:-idris} $@ showu.idr -o reg040
44./reg040
55rm -f reg040 *.ibc
test/reg042/run+1−1
@@ -1,4 +1,4 @@
11#!/usr/bin/env bash
2−idris $@ reg042 -o reg042 --warnreach
2+${IDRIS:-idris} $@ reg042 -o reg042 --warnreach
33./reg042
44rm -f reg042 *.ibc
test/reg044/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris --nocolour --consolewidth 80 reg044.idr --check
2+${IDRIS:-idris} --nocolour --consolewidth 80 reg044.idr --check
33rm -f *.ibc
test/reg045/run+1−1
@@ -1,4 +1,4 @@
11#!/usr/bin/env bash
2−idris $@ reg045.idr -o reg045
2+${IDRIS:-idris} $@ reg045.idr -o reg045
33./reg045
44rm -f reg045 *.ibc
test/reg046/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris $@ reg046.idr --check
2+${IDRIS:-idris} $@ reg046.idr --check
33rm -f reg046 *.ibc
test/reg047/run+2−2
@@ -1,4 +1,4 @@
11#!/usr/bin/env bash
2−idris $@ reg047.idr --check --nobuiltins
3−idris $@ reg047a.idr --check
2+${IDRIS:-idris} $@ reg047.idr --check --nobuiltins
3+${IDRIS:-idris} $@ reg047a.idr --check
44rm -f *.ibc
test/reg048/run+1−1
@@ -1,4 +1,4 @@
11#!/usr/bin/env bash
2−idris $@ reg048.idr -p contrib -o reg048
2+${IDRIS:-idris} $@ reg048.idr -p contrib -o reg048
33./reg048
44rm -f reg048 *.ibc
test/reg049/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris --consolewidth 80 --nocolour --check $@ reg049.idr
2+${IDRIS:-idris} --consolewidth 80 --nocolour --check $@ reg049.idr
33rm -f *.ibc
test/reg050/run+3−3
@@ -1,5 +1,5 @@
11#!/usr/bin/env bash
2−idris --nocolour --check $@ working.idr
3−idris --nocolour --check $@ badbangop.idr
4−idris --nocolour --check $@ baddoublebang.idr
2+${IDRIS:-idris} --nocolour --check $@ working.idr
3+${IDRIS:-idris} --nocolour --check $@ badbangop.idr
4+${IDRIS:-idris} --nocolour --check $@ baddoublebang.idr
55rm -f *.ibc
test/reg051-disabled/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris $@ reg051.idr --check
2+${IDRIS:-idris} $@ reg051.idr --check
33rm -f *.ibc
test/reg052/run+1−1
@@ -1,4 +1,4 @@
11#!/usr/bin/env bash
2−idris $@ -o reg052 reg052.idr
2+${IDRIS:-idris} $@ -o reg052 reg052.idr
33./reg052
44rm -f reg052 *.ibc
test/reg053/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris $@ --check four.idr
2+${IDRIS:-idris} $@ --check four.idr
33rm -f *.ibc
test/reg054/run+1−1
@@ -1,2 +1,2 @@
11#!/usr/bin/env bash
2−idris --nocolour --consolewidth 80 $@ reg054.idr --check
2+${IDRIS:-idris} --nocolour --consolewidth 80 $@ reg054.idr --check
test/reg055/run+2−2
@@ -1,5 +1,5 @@
11#!/usr/bin/env bash
2−idris --nocolour --consolewidth 80 $@ reg055.idr --check
3−idris --nocolour --consolewidth 80 $@ reg055a.idr --check
2+${IDRIS:-idris} --nocolour --consolewidth 80 $@ reg055.idr --check
3+${IDRIS:-idris} --nocolour --consolewidth 80 $@ reg055a.idr --check
44rm -f *.ibc
55
test/reg056/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris --consolewidth 80 $@ reg056.idr -o reg056
2+${IDRIS:-idris} --consolewidth 80 $@ reg056.idr -o reg056
33rm -f *.ibc
test/reg057/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris $@ reg057.idr --check
2+${IDRIS:-idris} $@ reg057.idr --check
33rm -f *.ibc
test/reg058/run+2−2
@@ -1,5 +1,5 @@
11#!/usr/bin/env bash
2−idris $@ implicits.idr --check
3−idris $@ implicits2.idr --check
2+${IDRIS:-idris} $@ implicits.idr --check
3+${IDRIS:-idris} $@ implicits2.idr --check
44
55rm -f *.ibc
test/reg059/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris $@ reg059.idr --check
2+${IDRIS:-idris} $@ reg059.idr --check
33rm -f *.ibc
test/reg060/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris $@ reg060.idr --check
2+${IDRIS:-idris} $@ reg060.idr --check
33rm -f *.ibc
test/reg061/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris $@ Capture.idr --check
2+${IDRIS:-idris} $@ Capture.idr --check
33rm -f *.ibc
test/reg062/run+2−2
@@ -1,4 +1,4 @@
11#!/usr/bin/env bash
2−idris $@ reg062.idr --check --nocolour
3−idris $@ reg062.lidr --check --nocolour
2+${IDRIS:-idris} $@ reg062.idr --check --nocolour
3+${IDRIS:-idris} $@ reg062.lidr --check --nocolour
44rm -f *.ibc
test/reg063/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris $@ Cmp.idr --check --nocolour --quiet
2+${IDRIS:-idris} $@ Cmp.idr --check --nocolour --quiet
33rm *.ibc
test/reg064/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris $@ reg064.idr --check
2+${IDRIS:-idris} $@ reg064.idr --check
33rm -f *.ibc
test/reg065/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris $@ reg065.idr --check
2+${IDRIS:-idris} $@ reg065.idr --check
33rm -f *.ibc
test/reg066/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris $@ reg066.idr --check --nocolor
2+${IDRIS:-idris} $@ reg066.idr --check --nocolor
33rm -f *.ibc
test/reg067/run+1−1
@@ -1,5 +1,5 @@
11#!/usr/bin/env bash
22rm -f *.ibc reg067
3−idris $@ reg067.idr -o reg067 --warnreach
3+${IDRIS:-idris} $@ reg067.idr -o reg067 --warnreach
44./reg067
55rm -f *.ibc reg067
test/runtest.hsnew file+218
@@ -0,0 +1,218 @@
1+{-# LANGUAGE CPP #-}
2+module Main where
3+
4+import Control.Monad
5+import Data.Char
6+import Data.List
7+import Data.Maybe
8+import qualified Data.Set as S
9+import Data.Time.Clock
10+import System.Directory
11+import System.Environment
12+import System.FilePath
13+import System.Exit
14+import System.Info
15+import System.IO
16+import System.Process
17+
18+-- Because GHC earlier than 7.8 lacks setEnv
19+-- Install the setenv package on Windows.
20+#if __GLASGOW_HASKELL__ < 708
21+#ifndef mingw32_HOST_OS
22+import qualified System.Posix.Env as PE(setEnv)
23+
24+setEnv k v = PE.setEnv k v True
25+#else
26+import System.SetEnv(setEnv)
27+#endif
28+#endif
29+
30+data Flag = Update | Diff | ShowOutput | Quiet | Time deriving (Eq, Show, Ord)
31+
32+type Flags = S.Set Flag
33+
34+data Status = Success | Failure | Updated deriving (Eq, Show)
35+
36+data Config = Config {
37+ flags :: Flags,
38+ idrOpts :: [String],
39+ tests :: [String]
40+} deriving (Show, Eq)
41+
42+isQuiet conf = Quiet `S.member` (flags conf)
43+showOutput conf = ShowOutput `S.member` (flags conf)
44+showTime conf = Time `S.member` (flags conf)
45+showDiff conf = Diff `S.member` (flags conf)
46+doUpdate conf = Update `S.member` (flags conf)
47+
48+checkTestName :: String -> Bool
49+checkTestName d = (all isDigit $ take 3 $ reverse d)
50+ && (not $ isInfixOf "disabled" d)
51+
52+enumTests :: IO [String]
53+enumTests = do
54+ cd <- getCurrentDirectory
55+ dirs <- getDirectoryContents cd
56+ return $ sort $ filter checkTestName dirs
57+
58+parseFlag :: String -> Maybe Flag
59+parseFlag s = case s of
60+ "-u" -> Just Update
61+ "-d" -> Just Diff
62+ "-s" -> Just ShowOutput
63+ "-t" -> Just Time
64+ "-q" -> Just Quiet
65+ _ -> Nothing
66+
67+parseFlags :: [String] -> (S.Set Flag, [String])
68+parseFlags xs = (S.fromList f, i)
69+ where
70+ f = catMaybes $ map parseFlag fl
71+ (fl, i) = partition (\s -> parseFlag s /= Nothing) xs
72+
73+parseArgs :: [String] -> IO Config
74+parseArgs args = do
75+ (tests, rest) <- case args of
76+ ("all":xs) -> do
77+ et <- enumTests
78+ return (et, xs)
79+ ("without":xs) -> do
80+ t <- enumTests
81+ (blacklist, ys) <- return $ break (== "opts") xs
82+ return (t \\ blacklist, ys \\ ["opts"])
83+ (x:xs) -> do
84+ exists <- doesDirectoryExist x
85+ return (if checkTestName x && exists then [x] else [], xs)
86+ [] -> do
87+ et <- enumTests
88+ return (et, [])
89+ let (testOpts, idOpts) = parseFlags rest
90+ return $ Config testOpts idOpts tests
91+
92+-- "bash" needed because Haskell has cmd as the default shell on windows, and
93+-- we also want to run the process with another current directory, so we get
94+-- this thing.
95+runInShell :: String -> [String] -> IO (ExitCode, String)
96+runInShell test opts = do
97+ (ec, output, _) <- readCreateProcessWithExitCode
98+ ((proc "bash" ("run":opts)) { cwd = Just test,
99+ std_out = CreatePipe })
100+ ""
101+ return (ec, output)
102+
103+runTest :: Config -> String -> IO Status
104+runTest conf test = do
105+ -- don't touch the current directory as we want to run these things
106+ -- in parallel in the future
107+ let inTest s = test ++ "/" ++ s
108+ t1 <- getCurrentTime
109+ (exitCode, output) <- runInShell test (idrOpts conf)
110+ t2 <- getCurrentTime
111+ expected <- readFile $ inTest "expected"
112+ writeFile (inTest "output") output
113+ res <- if (norm output == norm expected)
114+ then do putStrLn $ test ++ " finished...success"
115+ return Success
116+ else if doUpdate conf
117+ then do putStrLn $ test ++ " finished...UPDATE"
118+ writeFile (inTest "expected") output
119+ return Updated
120+ else do putStrLn $ test ++ " finished...FAILURE"
121+ _ <- rawSystem "diff" [inTest "output", inTest "expected"]
122+ return Failure
123+ when (showTime conf) $ do
124+ let dt = diffUTCTime t2 t1
125+ putStrLn $ "Duration of " ++ test ++ " was " ++ show dt
126+ return res
127+ where
128+ -- just pretend that backslashes are slashes for comparison
129+ -- purposes to avoid path problems, so don't write any tests
130+ -- that depend on that distinction in other contexts.
131+ -- Also rewrite newlines for consistency.
132+ norm ('\r':'\n':xs) = '\n' : norm xs
133+ norm ('\\':xs) = '/' : norm xs
134+ norm (x : xs) = x : norm xs
135+ norm [] = []
136+
137+printStats :: Config -> [Status] -> IO ()
138+printStats conf stats = do
139+ let total = length stats
140+ let successful = length $ filter (== Success) stats
141+ let failures = length $ filter (== Failure) stats
142+ let updates = length $ filter (== Updated) stats
143+ putStrLn "\n----"
144+ putStrLn $ show total ++ " tests run: " ++ show successful ++ " succesful, "
145+ ++ show failures ++ " failed, " ++ show updates ++ " updated."
146+ let failed = map fst $ filter ((== Failure) . snd) $ zip (tests conf) stats
147+ when (failed /= []) $ do
148+ putStrLn "\nFailed tests:"
149+ mapM_ putStrLn failed
150+ putStrLn ""
151+
152+runTests :: Config -> IO Bool
153+runTests conf = do
154+ stats <- mapM (runTest conf) (tests conf)
155+ unless (isQuiet conf) $ printStats conf stats
156+ return $ all (== Success) stats
157+
158+runShow :: Config -> IO Bool
159+runShow conf = do
160+ mapM_ (\t -> callProcess "cat" [t++"/output"]) (tests conf)
161+ return True
162+
163+runDiff :: Config -> IO Bool
164+runDiff conf = do
165+ mapM_ (\t -> do putStrLn $ "Differences in " ++ t ++ ":"
166+ ec <- rawSystem "diff" [t++"/output", t++"/expected"]
167+ when (ec == ExitSuccess) $ putStrLn "No differences found.")
168+ (tests conf)
169+ return True
170+
171+whisper :: Config -> String -> IO ()
172+whisper conf s = do unless (isQuiet conf) $ putStrLn s
173+
174+setPath :: Config -> IO ()
175+setPath conf = do
176+ maybeEnv <- lookupEnv "IDRIS"
177+ idrisEnv <- return $ fromMaybe "" maybeEnv
178+ if (idrisEnv /= "")
179+ then do
180+ idrisAbs <- makeAbsolute idrisEnv
181+ setEnv "IDRIS" idrisAbs
182+ whisper conf $ "Using " ++ idrisAbs
183+ else do
184+ path <- getEnv "PATH"
185+ let sandbox = "../.cabal-sandbox/bin"
186+ hasBox <- doesDirectoryExist sandbox
187+ bindir <- if hasBox
188+ then do
189+ whisper conf $ "Using Cabal sandbox at " ++ sandbox
190+ makeAbsolute sandbox
191+ else do
192+ stackExe <- findExecutable "stack"
193+ case stackExe of
194+ Just stack -> do
195+ out <- readProcess stack ["path", "--dist-dir"] []
196+ stackDistDir <- return $ takeWhile (/= '\n') out
197+ let stackDir = "../" ++ stackDistDir ++ "/build/idris"
198+ whisper conf $ "Using stack work dir at " ++ stackDir
199+ makeAbsolute stackDir
200+ Nothing -> return ""
201+ when (bindir /= "") $ setEnv "PATH" (bindir ++ [searchPathSeparator] ++ path)
202+
203+main = do
204+ hSetBuffering stdout LineBuffering
205+ args <- getArgs
206+ conf <- parseArgs args
207+ setPath conf
208+ t1 <- getCurrentTime
209+ res <- case tests conf of
210+ [] -> return True
211+ xs | showOutput conf -> runShow conf
212+ xs | showDiff conf -> runDiff conf
213+ xs -> runTests conf
214+ t2 <- getCurrentTime
215+ when (showTime conf) $ do
216+ let dt = diffUTCTime t2 t1
217+ putStrLn $ "Duration of Entire Test Suite was " ++ show dt
218+ unless res exitFailure
test/runtest.pldeleted−214
@@ -1,214 +0,0 @@
1−#!/usr/bin/env perl
2−
3−use strict;
4−use Cwd;
5−use Cwd 'abs_path';
6−use Env;
7−
8−my $exitstatus = 0;
9−my @idrOpts = ();
10−
11−
12−# Determines how idris was built locally, returning a PATH modifier.
13−#
14−# Order of checking is:
15−#
16−# 1. Cabal Sandboxing
17−# 2. Stack
18−# 3. Pure cabal.
19−#
20−sub sandbox_path {
21− my ($test_dir,) = @_;
22− my $sandbox = "$test_dir/../../.cabal-sandbox/bin";
23−
24− my $stack_bin_path = `stack path --dist-dir`;
25− $stack_bin_path =~ s/\n//g;
26− my $stack_work_dir = "$test_dir/../../$stack_bin_path/build/idris";
27−
28− if ( -d $sandbox ) {
29−
30− my $sandbox_abs = abs_path($sandbox);
31− print "Using Cabal Sandbox\n";
32− printf("Sandbox located at: %s\n", $sandbox_abs);
33− return "PATH=\"$sandbox_abs:$PATH\"";
34−
35− } elsif ( -d $stack_work_dir ) {
36−
37− my $stack_work_abs = abs_path($stack_work_dir);
38− print "Using Stack Work\n";
39− printf("Stack work located at: %s\n", $stack_work_abs);
40− return "PATH=\"$stack_work_abs:$PATH\"";
41−
42− } else {
43− print "Using Default Cabal.\n";
44− return "";
45− }
46−}
47−
48−# Run an individual test, and compare expected output with given
49−# output and report results.
50−#
51−sub runtest {
52− my ($test, $update, $showTime) = @_;
53−
54− my $sandbox = sandbox_path($test);
55−
56− chdir($test);
57−
58− my $startTime = time();
59− print "Running $test...\n";
60− my $got = `$sandbox ./run @idrOpts`;
61− my $exp = `cat expected`;
62−
63− my $endTime = time();
64− my $elapsedTime = $endTime - $startTime;
65−
66− if ($showTime == 1 ){
67− printf("Duration of $test was %d\n", $elapsedTime);
68− }
69−
70− # Allow for variant expected output for tests by overriding expected
71− # when there is an expected.<os> file in the test.
72− # This should be the exception but there are sometimes valid reasons
73− # for os-dependent output.
74− # The endings are msys for windows, darwin for osx and linux for linux
75− if ( -e "expected.$^O") {
76− $exp = `cat expected.$^O`;
77− }
78− open my $out, '>', 'output';
79− print $out $got;
80− close $out;
81−
82− # $ok = system("diff output expected &> /dev/null");
83− # Mangle newlines in $got and $exp
84− $got =~ s/\r\n/\n/g;
85− $exp =~ s/\r\n/\n/g;
86−
87− # Normalize paths in $got and $exp, so the expected outcomes don't
88− # change between platforms
89− while($got =~ /(^|.*?\n)(.*?)\\(.*?):(\d+):(.*)/ms) {
90− $got = "$1$2/$3:$4:$5";
91− }
92− while($exp =~ /(^|.*?\n)(.*?)\\(.*?):(\d+):(.*)/ms) {
93− $exp = "$1$2/$3:$4:$5";
94− }
95−
96− if ($got eq $exp) {
97− print "Ran $test...success\n";
98− }
99− else {
100− if ($update == 0) {
101− $exitstatus = 1;
102− print "Ran $test...FAILURE\n";
103− system "diff output expected";
104− } else {
105− system("cp output expected");
106− print "Ran $test...UPDATED\n";
107− }
108− }
109− chdir "..";
110−}
111−
112−# Main test running program to sort test input, and execute individual
113−# tests.
114−#
115−
116−my ( @without, @args, @tests, @opts );
117−
118−# Deal with the Args.
119−if ($#ARGV>=0) {
120− my $test = shift @ARGV;
121− if ($test eq "all") {
122− opendir my $dir, ".";
123− my @list = readdir $dir;
124− foreach my $file (@list) {
125− if ($file =~ /[0-9][0-9][0-9]$/) {
126− push @tests, $file;
127− }
128− }
129− @tests = sort @tests;
130−
131− } elsif ($test eq "without") {
132− @args = @ARGV;
133− foreach my $file (@args) {
134− last if ($file =~ /--/);
135− push @without, shift @ARGV;
136− }
137−
138− opendir my $dir, ".";
139− my @list = readdir $dir;
140− foreach my $file (@list) {
141− if ($file =~ /[0-9][0-9][0-9]$/) {
142− if (!(grep ($_ eq $file, @without))) {
143− push @tests, $file;
144− }
145− else {
146− print "Omitting $file\n";
147− }
148− }
149− }
150− @tests = sort @tests;
151− }
152− else {
153− if ($test =~ /[0-9][0-9][0-9]$/) {
154− push @tests, $test;
155− }
156− }
157− @opts = @ARGV;
158−}
159−else {
160− print "Give a test name, or 'all' to run all.\n";
161− exit;
162−}
163−
164−# Run the tests.
165−
166−my $update = 0;
167−my $diff = 0;
168−my $show = 0;
169−my $usejava = 0;
170−my $showTime = 0;
171−
172−while (my $opt = shift @opts) {
173− if ($opt eq "-u") { $update = 1; }
174− elsif ($opt eq "-d") { $diff = 1; }
175− elsif ($opt eq "-s") { $show = 1; }
176− elsif ($opt eq "-t") { $showTime = 1; }
177− else { push(@idrOpts, $opt); }
178−}
179−
180−my $idris = $ENV{IDRIS};
181−my $path = $ENV{PATH};
182−$ENV{PATH} = cwd() . "/" . $idris . ":" . $path;
183−
184−my $startTime = time();
185−
186−foreach my $test (@tests) {
187− if ($diff == 0 && $show == 0) {
188− runtest($test,$update,$showTime);
189− }
190− else {
191− chdir $test;
192−
193− if ($show == 1) {
194− system "cat output";
195− }
196− if ($diff == 1) {
197− print "Differences in $test:\n";
198− my $ok = system "diff output expected";
199− if ($ok == 0) {
200− print "No differences found.\n";
201− }
202− }
203− chdir "..";
204− }
205−}
206−
207−my $endTime = time();
208−my $elapsedTime = $endTime - $startTime;
209−
210−if ($showTime == 1) {
211− printf("Duration of Entire Test Suite was %d\n", $elapsedTime);
212−}
213−
214−exit $exitstatus;
test/sourceLocation001/run+1−1
@@ -1,4 +1,4 @@
11#!/usr/bin/env bash
2−idris $@ --nocolour --consolewidth 80 SourceLoc.idr -o sourceLocation001
2+${IDRIS:-idris} $@ --nocolour --consolewidth 80 SourceLoc.idr -o sourceLocation001
33./sourceLocation001
44rm -f sourceLocation001 *.ibc
test/sugar001/run+1−1
@@ -1,4 +1,4 @@
11#!/usr/bin/env bash
2−idris $@ test007.idr -o test007
2+${IDRIS:-idris} $@ test007.idr -o test007
33./test007
44rm -f test007 test007.ibc
test/sugar002/run+1−1
@@ -1,4 +1,4 @@
11#!/usr/bin/env bash
2−idris $@ test009.idr -o test009
2+${IDRIS:-idris} $@ test009.idr -o test009
33./test009
44rm -f test009 test009.ibc
test/sugar003/run+1−1
@@ -1,4 +1,4 @@
11#!/usr/bin/env bash
2−idris $@ test013.idr -o test013
2+${IDRIS:-idris} $@ test013.idr -o test013
33./test013
44rm -f test013 test013.ibc
test/sugar004/run+1−1
@@ -1,5 +1,5 @@
11#!/usr/bin/env bash
2−idris $@ sugar004.idr -o sugar004
2+${IDRIS:-idris} $@ sugar004.idr -o sugar004
33./sugar004
44./sugar004 42
55./sugar004 42 100
test/sugar005/run+1−1
@@ -1,4 +1,4 @@
11#!/usr/bin/env bash
2−idris $@ As.idr -o sugar005
2+${IDRIS:-idris} $@ As.idr -o sugar005
33./sugar005
44rm -f sugar005 *.ibc
test/syntax001/expected+2−2
@@ -2,7 +2,7 @@ Syntax.idr:6:7-9:1:
22When checking right hand side of foo with expected type
33 Nat
44
5−When checking an application of function Prelude.Classes.+:
5+When checking an application of function Prelude.Interfaces.+:
66 Type mismatch between
77 String (Type of "argh")
88 and
@@ -11,7 +11,7 @@ SyntaxTest.idr:5:7-6:1:
1111When checking right hand side of foo with expected type
1212 Nat
1313
14−When checking an application of function Prelude.Classes.+:
14+When checking an application of function Prelude.Interfaces.+:
1515 Type mismatch between
1616 String (Type of "argh")
1717 and
test/syntax001/run+2−2
@@ -1,4 +1,4 @@
11#!/usr/bin/env bash
2−idris $@ Syntax.idr --nocolour --consolewidth 80 --check
3−idris $@ SyntaxTest.idr --nocolour --consolewidth 80 --check
2+${IDRIS:-idris} $@ Syntax.idr --nocolour --consolewidth 80 --check
3+${IDRIS:-idris} $@ SyntaxTest.idr --nocolour --consolewidth 80 --check
44rm -f *.ibc
test/syntax002/run+1−1
@@ -1,4 +1,4 @@
11#!/usr/bin/env bash
2−idris $@ syntax002.idr -o syntax002
2+${IDRIS:-idris} $@ syntax002.idr -o syntax002
33./syntax002
44rm -f syntax002 *.ibc
test/tactics001/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris $@ --check Tactics.idr
2+${IDRIS:-idris} $@ --check Tactics.idr
33rm -f *.ibc
test/totality001/run+3−3
@@ -1,6 +1,6 @@
11#!/usr/bin/env bash
2−idris --consolewidth 80 $@ --check test010.idr
3−idris --consolewidth 80 $@ --check test010a.idr
4−idris --consolewidth 80 $@ --check test010b.idr
2+${IDRIS:-idris} --consolewidth 80 $@ --check test010.idr
3+${IDRIS:-idris} --consolewidth 80 $@ --check test010a.idr
4+${IDRIS:-idris} --consolewidth 80 $@ --check test010b.idr
55
66rm -f *.ibc
test/totality002/run+3−3
@@ -1,5 +1,5 @@
11#!/usr/bin/env bash
2−idris --consolewidth 80 $@ --check test017.idr
3−idris --consolewidth 80 $@ --check test017a.idr
4−idris --consolewidth 80 $@ --check test017b.idr
2+${IDRIS:-idris} --consolewidth 80 $@ --check test017.idr
3+${IDRIS:-idris} --consolewidth 80 $@ --check test017a.idr
4+${IDRIS:-idris} --consolewidth 80 $@ --check test017b.idr
55rm -f *.ibc
test/totality003/run+2−2
@@ -1,4 +1,4 @@
11#!/usr/bin/env bash
2−idris --nocolour --consolewidth 80 $@ totality003.idr --check
3−idris --nocolour --consolewidth 80 $@ totality003a.idr --check
2+${IDRIS:-idris} --nocolour --consolewidth 80 $@ totality003.idr --check
3+${IDRIS:-idris} --nocolour --consolewidth 80 $@ totality003a.idr --check
44rm -f *.ibc
test/totality004/run+2−2
@@ -1,5 +1,5 @@
11#!/usr/bin/env bash
2−idris --consolewidth 80 $@ totality004.idr -o totality004
2+${IDRIS:-idris} --consolewidth 80 $@ totality004.idr -o totality004
33./totality004
4−idris --consolewidth 80 $@ --check totality004a.idr
4+${IDRIS:-idris} --consolewidth 80 $@ --check totality004a.idr
55rm -f totality004 *.ibc
test/totality005/run+2−2
@@ -1,5 +1,5 @@
11#!/usr/bin/env bash
2−idris $@ totality005.idr --total --check
3−idris $@ totality005.idr -o totality005
2+${IDRIS:-idris} $@ totality005.idr --total --check
3+${IDRIS:-idris} $@ totality005.idr -o totality005
44./totality005
55rm -f totality005 *.ibc
test/totality006/run+3−3
@@ -1,5 +1,5 @@
11#!/usr/bin/env bash
2−idris --consolewidth 80 $@ totality006.idr --check
3−idris --consolewidth 80 $@ totality006a.idr --check
4−idris --consolewidth 80 $@ totality006b.idr --check
2+${IDRIS:-idris} --consolewidth 80 $@ totality006.idr --check
3+${IDRIS:-idris} --consolewidth 80 $@ totality006a.idr --check
4+${IDRIS:-idris} --consolewidth 80 $@ totality006b.idr --check
55rm -f *.ibc
test/totality007/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris $@ --build totality.ipkg
2+${IDRIS:-idris} $@ --build totality.ipkg
33rm -f src/*.ibc
test/totality008/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris --consolewidth 80 $@ totality008.idr --check
2+${IDRIS:-idris} --consolewidth 80 $@ totality008.idr --check
33rm -f *.ibc
test/totality009/run+2−2
@@ -1,5 +1,5 @@
11#!/usr/bin/env bash
22OPTS="--consolewidth infinite --nocolour"
3−idris "$@" $OPTS --check TestLambdaImpossible
4−idris "$@" $OPTS --check --warnpartial TestLambdaPossible
3+${IDRIS:-idris} "$@" $OPTS --check TestLambdaImpossible
4+${IDRIS:-idris} "$@" $OPTS --check --warnpartial TestLambdaPossible
55rm -f *.ibc
test/totality010/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris $@ totality010.idr --nocolour --consolewidth 80 --check
2+${IDRIS:-idris} $@ totality010.idr --nocolour --consolewidth 80 --check
33rm -f *.ibc
test/tutorial001/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris --check tutorial001.idr
2+${IDRIS:-idris} --check tutorial001.idr
33rm -f *.ibc
test/tutorial002/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris $@ --nocolour --consolewidth 80 tutorial002.idr --check
2+${IDRIS:-idris} $@ --nocolour --consolewidth 80 tutorial002.idr --check
33rm -f *.ibc
test/tutorial003/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris $@ tutorial003.idr --check
2+${IDRIS:-idris} $@ tutorial003.idr --check
33rm -f *.ibc
test/tutorial004/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris $@ tutorial004.idr --check --nocolour --consolewidth 80
2+${IDRIS:-idris} $@ tutorial004.idr --check --nocolour --consolewidth 80
33rm -f *.ibc
test/tutorial005/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris $@ tutorial005.idr --check
2+${IDRIS:-idris} $@ tutorial005.idr --check
33rm -f *.ibc
test/tutorial006/run+3−3
@@ -1,5 +1,5 @@
11#!/usr/bin/env bash
2−idris --nocolour --consolewidth 80 $@ tutorial006a.idr --check
3−idris --nocolour --consolewidth 80 $@ tutorial006b.idr --check
4−idris --nocolour --consolewidth 80 $@ tutorial006c.idr -p effects --check
2+${IDRIS:-idris} --nocolour --consolewidth 80 $@ tutorial006a.idr --check
3+${IDRIS:-idris} --nocolour --consolewidth 80 $@ tutorial006b.idr --check
4+${IDRIS:-idris} --nocolour --consolewidth 80 $@ tutorial006c.idr -p effects --check
55rm -f *.ibc
test/unique001/run+6−6
@@ -1,9 +1,9 @@
11#!/usr/bin/env bash
2−idris --nocolour --consolewidth 80 $@ unique001.idr -o unique001
2+${IDRIS:-idris} --nocolour --consolewidth 80 $@ unique001.idr -o unique001
33./unique001
4−idris --nocolour --consolewidth 80 $@ unique001a.idr --check
5−idris --nocolour --consolewidth 80 $@ unique001b.idr --check
6−idris --nocolour --consolewidth 80 $@ unique001c.idr --check
7−idris --nocolour --consolewidth 80 $@ unique001d.idr --check
8−idris --nocolour --consolewidth 80 $@ unique001e.idr --check
4+${IDRIS:-idris} --nocolour --consolewidth 80 $@ unique001a.idr --check
5+${IDRIS:-idris} --nocolour --consolewidth 80 $@ unique001b.idr --check
6+${IDRIS:-idris} --nocolour --consolewidth 80 $@ unique001c.idr --check
7+${IDRIS:-idris} --nocolour --consolewidth 80 $@ unique001d.idr --check
8+${IDRIS:-idris} --nocolour --consolewidth 80 $@ unique001e.idr --check
99rm -f unique001 *.ibc
test/unique002/run+2−2
@@ -1,4 +1,4 @@
11#!/usr/bin/env bash
2−idris --nocolour --consolewidth 80 $@ unique002.idr --check
3−idris --nocolour --consolewidth 80 $@ unique002a.idr --check
2+${IDRIS:-idris} --nocolour --consolewidth 80 $@ unique002.idr --check
3+${IDRIS:-idris} --nocolour --consolewidth 80 $@ unique002a.idr --check
44rm -f *.ibc
test/unique003/run+1−1
@@ -1,3 +1,3 @@
11#!/usr/bin/env bash
2−idris --nocolour --consolewidth 80 $@ unique003.idr --check
2+${IDRIS:-idris} --nocolour --consolewidth 80 $@ unique003.idr --check
33rm -f *.ibc