on master help sign in
.travis.yml+23−14
since splitsnapshots
unifiedsplit
@@ -8,7 +8,7 @@ env:
8
8
9matrix:
9matrix:
10 include:
10 include:
11− - env: CABALVER="2.4" GHCVER="8.6.5" STACKVER="14.15" STYLISH=YES
11+ - env: CABALVER="2.4" GHCVER="8.6.5" STACKVER="15.4" STYLISH=YES
12 addons: {apt: {packages: [cabal-install-2.4,ghc-8.6.5,hscolour], sources: [hvr-ghc]}}
12 addons: {apt: {packages: [cabal-install-2.4,ghc-8.6.5,hscolour], sources: [hvr-ghc]}}
13 - env: CABALVER="2.4" GHCVER="8.2.2" TESTS="lib_doc doc"
13 - env: CABALVER="2.4" GHCVER="8.2.2" TESTS="lib_doc doc"
14 compiler: ": #GHC 8.2.2"
14 compiler: ": #GHC 8.2.2"
@@ -19,18 +19,26 @@ matrix:
19 - env: CABALVER="2.4" GHCVER="8.2.2" TESTS="test_c"
19 - env: CABALVER="2.4" GHCVER="8.2.2" TESTS="test_c"
20 compiler: ": #GHC 8.2.2"
20 compiler: ": #GHC 8.2.2"
21 addons: {apt: {packages: [cabal-install-2.4,ghc-8.2.2,cppcheck,hscolour], sources: [hvr-ghc]}}
21 addons: {apt: {packages: [cabal-install-2.4,ghc-8.2.2,cppcheck,hscolour], sources: [hvr-ghc]}}
22− - env: CABALVER="3.0" GHCVER="8.8.2" IDRIS2=YES
22+ - env: CABALVER="2.4" GHCVER="8.4.4" TESTS="lib_doc doc"
23+ compiler: ": #GHC 8.4.4"
24+ addons: {apt: {packages: [cabal-install-2.4,ghc-8.4.4,cppcheck,hscolour], sources: [hvr-ghc]}}
25+ - env: CABALVER="2.4" GHCVER="8.4.4" TESTS="test_js"
26+ compiler: ": #GHC 8.4.4"
27+ addons: {apt: {packages: [cabal-install-2.4,ghc-8.4.4,cppcheck,hscolour], sources: [hvr-ghc]}}
28+ - env: CABALVER="2.4" GHCVER="8.4.4" TESTS="test_c"
29+ compiler: ": #GHC 8.4.4"
30+ addons: {apt: {packages: [cabal-install-2.4,ghc-8.4.4,cppcheck,hscolour], sources: [hvr-ghc]}}
31+ - env: CABALVER="3.0" GHCVER="8.8.3" TESTS="lib_doc doc"
32+ compiler: ": #GHC 8.8.3"
33+ addons: {apt: {packages: [cabal-install-3.0,ghc-8.8.3,cppcheck,hscolour], sources: [hvr-ghc]}}
34+ - env: CABALVER="3.0" GHCVER="8.8.3" TESTS="test_js"
35+ compiler: ": #GHC 8.8.3"
36+ addons: {apt: {packages: [cabal-install-3.0,ghc-8.8.3,cppcheck,hscolour], sources: [hvr-ghc]}}
37+ - env: CABALVER="3.0" GHCVER="8.8.3" TESTS="test_c"
38+ compiler: ": #GHC 8.8.3"
39+ addons: {apt: {packages: [cabal-install-3.0,ghc-8.8.3,cppcheck,hscolour], sources: [hvr-ghc]}}
40+ - env: CABALVER="3.0" GHCVER="8.8.3" IDRIS2=YES
23− addons: {apt: {packages: [cabal-install-3.0,ghc-8.8.2], sources: [hvr-ghc]}}
41+ addons: {apt: {packages: [cabal-install-3.0,ghc-8.8.3], sources: [hvr-ghc]}}
24−
25−# - env: CABALVER="3.0" GHCVER="8.8.1" TESTS="lib_doc doc"
26−# compiler: ": #GHC 8.8.1"
27−# addons: {apt: {packages: [cabal-install-3.0,ghc-8.8.1,cppcheck,hscolour], sources: [hvr-ghc]}}
28−# - env: CABALVER="3.0" GHCVER="8.8.1" TESTS="test_js"
29−# compiler: ": #GHC 8.8.1"
30−# addons: {apt: {packages: [cabal-install-3.0,ghc-8.8.1,cppcheck,hscolour], sources: [hvr-ghc]}}
31−# - env: CABALVER="3.0" GHCVER="8.8.1" TESTS="test_c"
32−# compiler: ": #GHC 8.8.1"
33−# addons: {apt: {packages: [cabal-install-3.0,ghc-8.8.1,cppcheck,hscolour], sources: [hvr-ghc]}}
34 fast-finish: true
42 fast-finish: true
35
43
36cache:
44cache:
@@ -119,7 +127,7 @@ install:
119 cp -a $HOME/.ghc $HOME/.cabsnap/ghc;
127 cp -a $HOME/.ghc $HOME/.cabsnap/ghc;
120 cp -a $HOME/.cabal/lib $HOME/.cabal/share $HOME/.cabal/bin installplan.txt $HOME/.cabsnap/;
128 cp -a $HOME/.cabal/lib $HOME/.cabal/share $HOME/.cabal/bin installplan.txt $HOME/.cabsnap/;
121 fi
129 fi
122−
130+
123
131
124before_script:
132before_script:
125 - ORIGINAL_DIR=$(pwd)
133 - ORIGINAL_DIR=$(pwd)
@@ -128,6 +136,7 @@ before_script:
128 - tar -xf ${ORIGINAL_DIR}/dist/${PKGNAME}*.tar.gz
136 - tar -xf ${ORIGINAL_DIR}/dist/${PKGNAME}*.tar.gz
129 - cd ${PKGNAME}*
137 - cd ${PKGNAME}*
130script:
138script:
139+ - export LD_PRELOAD=/opt/ghc/${GHCVER}/lib/ghc-${GHCVER}/rts/libffi.so.7
131###
140###
132 - echo 'Configure...' && echo -en 'travis_fold:start:script.configure\\r'
141 - echo 'Configure...' && echo -en 'travis_fold:start:script.configure\\r'
133 - cabal v1-configure -f FFI -f CI --enable-tests
142 - cabal v1-configure -f FFI -f CI --enable-tests
INSTALL.md+11−2
@@ -130,7 +130,8 @@ PKG_CONFIG_PATH=/usr/local/opt/libffi/lib/pkgconfig stack build
130## Issue with GHC on Ubuntu/Fedora
130## Issue with GHC on Ubuntu/Fedora
131
131
132There is an upstream issue with GHC on some Ubuntu and Fedora machines.
132There is an upstream issue with GHC on some Ubuntu and Fedora machines.
133−The issue is that for GHC versions greater than 8.4.X linking to libFFI is broken.
133+The issue is that for GHC versions greater than 8.4.X linking to libFFI uses the version of libFFI shipped with GHC, instead of the system version.
134+
134See the following GHC issue page for more information:
135See the following GHC issue page for more information:
135
136
136 <https://gitlab.haskell.org/ghc/ghc/issues/15397>
137 <https://gitlab.haskell.org/ghc/ghc/issues/15397>
@@ -141,4 +142,12 @@ Specifically, one will see an error message along the lines of:
141
142
142> error while loading shared libraries: libffi.so.7: cannot open shared object file: No such file or directory
143> error while loading shared libraries: libffi.so.7: cannot open shared object file: No such file or directory
143
144
144−We have supplied an alternative stack configuration file (`stack-alt.yaml`) that will use a version of GHC prior to the upstream issue being introduced.
145+A workround for this bug is to override the used libffi version (this is what we use on CI):
146+
147+```bash
148+export LD_PRELOAD=/opt/ghc/${GHCVER}/lib/ghc-${GHCVER}/rts/libffi.so.7
149+```
150+
151+## GHC 8.6
152+
153+For reasons that haven't been investigated building the Idris compiler with GHC 8.6 leads to a compiler which doesn't pass test.
docs/conf.py+2−1
@@ -251,6 +251,7 @@ latex_elements = {
251# Additional stuff for the LaTeX preamble.
251# Additional stuff for the LaTeX preamble.
252'preamble': r'''
252'preamble': r'''
253\usepackage{lmodern}
253\usepackage{lmodern}
254+\usepackage{textalpha}
254\usepackage[T1]{fontenc}
255\usepackage[T1]{fontenc}
255\usepackage[utf8x]{inputenc}
256\usepackage[utf8x]{inputenc}
256\usepackage{titlesec}
257\usepackage{titlesec}
@@ -300,7 +301,7 @@ latex_elements = {
300# (source start file, target name, title,
301# (source start file, target name, title,
301# author, documentclass [howto, manual, or own class]).
302# author, documentclass [howto, manual, or own class]).
302latex_documents = [
303latex_documents = [
303− ('index', 'idris-documentation-complete.tex', u'Documentation for the Idris Language', u'The Idris Community', 'report'),
304+ # (master_doc, 'idris.tex', u'Documentation for the Idris Language', u'The Idris Community', 'report')
304 ('tutorial/index', 'idris-tutorial.tex', u'The Idris Tutorial', u'The Idris Community', 'howto'),
305 ('tutorial/index', 'idris-tutorial.tex', u'The Idris Tutorial', u'The Idris Community', 'howto'),
305]
306]
306
307
docs/effects/introduction.rst+2−1
@@ -17,7 +17,8 @@ exceptions, and verified resource management.
17This tutorial assumes familiarity with pure programming in Idris,
17This tutorial assumes familiarity with pure programming in Idris,
18as described in Sections 1–6 of the main tutorial [1]_. The examples
18as described in Sections 1–6 of the main tutorial [1]_. The examples
19presented are tested with Idris and can be found in the
19presented are tested with Idris and can be found in the
20−examples directory of the Idris repository.
20+examples directory of the Idris repository. The ``-p effects`` flag
21+is needed when starting Idris.
21
22
22Consider, for example, the following introductory function which
23Consider, for example, the following introductory function which
23illustrates the kind of properties which can be expressed in the type
24illustrates the kind of properties which can be expressed in the type
docs/reference/misc.rst+5−5
@@ -115,11 +115,11 @@ Here is an example:
115 import Syntax.PreorderReasoning
115 import Syntax.PreorderReasoning
116 multThree : (a, b, c : Nat) -> a * b * c = c * a * b
116 multThree : (a, b, c : Nat) -> a * b * c = c * a * b
117 multThree a b c =
117 multThree a b c =
118− (a * b * c) ={ sym (multAssociative a b c) }=
118+ (a * b * c) ={ sym (multAssociative a b c) }=
119− (a * (b * c)) ={ cong (multCommutative b c) }=
119+ (a * (b * c)) ={ cong (multCommutative b c) }=
120− (a * (c * b)) ={ multAssociative a c b }=
120+ (a * (c * b)) ={ multAssociative a c b }=
121− (a * c * b) ={ cong {f = (* b)} (multCommutative a c) }=
121+ (a * c * b) ={ cong {f = (* b)} (multCommutative a c) }=
122− (c * a * b) QED
122+ (c * a * b) QED
123
123
124Note that the parentheses are required -- only a simple expression can
124Note that the parentheses are required -- only a simple expression can
125be on the left of ``={ }=`` or ``QED``. Also, when using preorder
125be on the left of ``={ }=`` or ``QED``. Also, when using preorder
idris-tutorial.pdf

Binary file not shown.

idris.cabal+31−15
@@ -46,12 +46,19 @@ Build-type: Custom
46
46
47Tested-With: GHC == 7.10.3, GHC == 8.0.1
47Tested-With: GHC == 7.10.3, GHC == 8.0.1
48
48
49+-- NOTE: due to https://github.com/haskell/cabal/issues/6125 the use of ** is
50+-- heavily discouraged.
49Data-files: idrisdoc/styles.css
51Data-files: idrisdoc/styles.css
50− jsrts/**/*.js
52+ jsrts/jsbn/*.js
53+ jsrts/*.js
51 jsrts/jsbn/LICENSE
54 jsrts/jsbn/LICENSE
52 rts/Makefile
55 rts/Makefile
53− rts/**/*.c
56+ rts/*.c
57+ rts/seL4/*.c
58+ rts/arduino/*.c
59+ rts/windows/*.c
54− rts/**/*.h
60+ rts/windows/*.h
61+ rts/*.h
55 rts/seL4/CMakeLists.txt
62 rts/seL4/CMakeLists.txt
56 rts/seL4/README.md
63 rts/seL4/README.md
57
64
@@ -64,8 +71,13 @@ Extra-doc-files:
64 RELEASE-CHECKS.md
71 RELEASE-CHECKS.md
65 idris-tutorial.pdf
72 idris-tutorial.pdf
66 man/idris.1
73 man/idris.1
67− samples/**/*.idr
74+ samples/effects/*.idr
75+ samples/misc/*.idr
76+ samples/tutorial/*.idr
77+ samples/ST/*.idr
78+ samples/ST/Graphics/*.idr
79+ samples/ST/Net/*.idr
68− samples/**/*.lidr
80+ samples/misc/*.lidr
69
81
70-- extra-source-files is generated by Setup.hs using `git --ls-files`.
82-- extra-source-files is generated by Setup.hs using `git --ls-files`.
71Extra-source-files:
83Extra-source-files:
@@ -73,15 +85,20 @@ Extra-source-files:
73 config.mk
85 config.mk
74 custom.mk-alldeps
86 custom.mk-alldeps
75 mkpkg.sh
87 mkpkg.sh
76− stack-alt.yaml
77 stack-shell.nix
88 stack-shell.nix
78 stack.yaml
89 stack.yaml
79 stylize.sh
90 stylize.sh
80 win-release.sh
91 win-release.sh
81−
92+
82 benchmarks/*.pl
93 benchmarks/*.pl
83− benchmarks/**/*.idr
94+ benchmarks/fasta/*.idr
95+ benchmarks/fasta/*.ipkg
96+ benchmarks/pidigits/*.idr
97+ benchmarks/pidigits/*.ipkg
98+ benchmarks/quasigroups/*.idr
99+ benchmarks/quasigroups/*.ipkg
100+ benchmarks/trivial/*.idr
84− benchmarks/**/*.ipkg
101+ benchmarks/trivial/*.ipkg
85 benchmarks/quasigroups/board
102 benchmarks/quasigroups/board
86
103
87 icons/*.png
104 icons/*.png
@@ -304,13 +321,13 @@ Library
304 Build-depends: base >=4 && <5
321 Build-depends: base >=4 && <5
305 , aeson >= 0.6 && < 1.5
322 , aeson >= 0.6 && < 1.5
306 , annotated-wl-pprint >= 0.7 && < 0.8
323 , annotated-wl-pprint >= 0.7 && < 0.8
307− , ansi-terminal < 0.10
324+ , ansi-terminal < 0.11
308 , ansi-wl-pprint < 0.7
325 , ansi-wl-pprint < 0.7
309 , array >= 0.4.0.1 && < 0.6
326 , array >= 0.4.0.1 && < 0.6
310 , base64-bytestring < 1.1
327 , base64-bytestring < 1.1
311 , binary >= 0.8.4.1 && < 0.9
328 , binary >= 0.8.4.1 && < 0.9
312 , blaze-html >= 0.6.1.3 && < 0.10
329 , blaze-html >= 0.6.1.3 && < 0.10
313− , blaze-markup >= 0.5.2.1 && < 0.9
330+ , blaze-markup >= 0.5.2.1 && < 0.10
314 , bytestring < 0.11
331 , bytestring < 0.11
315 , cheapskate >= 0.1.1.2 && < 0.2
332 , cheapskate >= 0.1.1.2 && < 0.2
316 , code-page >= 0.1 && < 0.3
333 , code-page >= 0.1 && < 0.3
@@ -321,9 +338,9 @@ Library
321 , fingertree >= 0.1.4.1 && < 0.2
338 , fingertree >= 0.1.4.1 && < 0.2
322 , haskeline >= 0.7 && < 0.8
339 , haskeline >= 0.7 && < 0.8
323 , ieee754 >= 0.7 && < 0.9
340 , ieee754 >= 0.7 && < 0.9
324− , megaparsec >= 7.0.4 && < 8
341+ , megaparsec >= 7.0.4 && < 9
325 , mtl >= 2.1 && < 2.3
342 , mtl >= 2.1 && < 2.3
326− , network >= 2.7 && < 2.9
343+ , network >= 2.7 && < 3.1.2
327 , optparse-applicative >= 0.13 && < 0.16
344 , optparse-applicative >= 0.13 && < 0.16
328 , parser-combinators >= 1.0.0
345 , parser-combinators >= 1.0.0
329 , pretty < 1.2
346 , pretty < 1.2
@@ -341,7 +358,7 @@ Library
341 , vector < 0.13
358 , vector < 0.13
342 , vector-binary-instances < 0.3
359 , vector-binary-instances < 0.3
343 , zip-archive > 0.2.3.5 && < 0.5
360 , zip-archive > 0.2.3.5 && < 0.5
344− , fsnotify >= 0.2 && < 2.2
361+ , fsnotify >= 0.2 && < 0.4
345 , async < 2.3
362 , async < 2.3
346
363
347 if !impl(ghc >= 8.0)
364 if !impl(ghc >= 8.0)
@@ -459,4 +476,3 @@ Executable idris-codegen-node
459 Default-Language: Haskell2010
476 Default-Language: Haskell2010
460 ghc-prof-options: -auto-all -caf-all
477 ghc-prof-options: -auto-all -caf-all
461 ghc-options: -threaded -rtsopts -funbox-strict-fields
478 ghc-options: -threaded -rtsopts -funbox-strict-fields
462−
libs/base/Control/Isomorphism.idr+20−23
@@ -17,21 +17,22 @@ record Iso a b where
17
17
18-- Isomorphism properties
18-- Isomorphism properties
19
19
20−||| Isomorphism is Reflexive
20+||| Isomorphism is reflexive
21isoRefl : Iso a a
21isoRefl : Iso a a
22−isoRefl = MkIso id id (\x => Refl) (\x => Refl)
22+isoRefl = MkIso id id (\_ => Refl) (\_ => Refl)
23
23
24||| Isomorphism is transitive
24||| Isomorphism is transitive
25isoTrans : Iso a b -> Iso b c -> Iso a c
25isoTrans : Iso a b -> Iso b c -> Iso a c
26isoTrans (MkIso to from toFrom fromTo) (MkIso to' from' toFrom' fromTo') =
26isoTrans (MkIso to from toFrom fromTo) (MkIso to' from' toFrom' fromTo') =
27− MkIso (\x => to' (to x))
27+ MkIso xto xfrom xtoFrom xfromTo where
28− (\y => from (from' y))
28+ xto : a -> c
29− (\y => (to' (to (from (from' y)))) ={ cong (toFrom (from' y)) }=
29+ xto = to' . to
30+ xfrom : c -> a
31+ xfrom = from . from'
32+ xtoFrom : (z : c) -> xto (xfrom z) = z
30− (to' (from' y)) ={ toFrom' y }=
33+ xtoFrom z = rewrite toFrom $ from' z in toFrom' z
31− y QED)
34+ xfromTo : (x : a) -> xfrom (xto x) = x
32− (\x => (from (from' (to' (to x)))) ={ cong (fromTo' (to x)) }=
35+ xfromTo x = rewrite fromTo' (to x) in fromTo x
33− (from (to x)) ={ fromTo x }=
34− x QED)
35
36
36Category Iso where
37Category Iso where
37 id = isoRefl
38 id = isoRefl
@@ -99,8 +100,7 @@ eitherBotRight = isoTrans eitherComm eitherBotLeft
99
100
100||| Isomorphism is a congruence with regards to disjunction
101||| Isomorphism is a congruence with regards to disjunction
101eitherCong : Iso a a' -> Iso b b' -> Iso (Either a b) (Either a' b')
102eitherCong : Iso a a' -> Iso b b' -> Iso (Either a b) (Either a' b')
102−eitherCong {a = a} {a' = a'} {b = b} {b' = b'}
103− (MkIso to from toFrom fromTo)
103+eitherCong (MkIso to from toFrom fromTo)
104 (MkIso to' from' toFrom' fromTo') =
104 (MkIso to' from' toFrom' fromTo') =
105 MkIso (eitherMap to to') (eitherMap from from') ok1 ok2
105 MkIso (eitherMap to to') (eitherMap from from') ok1 ok2
106 where eitherMap : (c -> c') -> (d -> d') -> Either c d -> Either c' d'
106 where eitherMap : (c -> c') -> (d -> d') -> Either c d -> Either c' d'
@@ -143,9 +143,7 @@ pairAssoc = MkIso to from ok1 ok2
143
143
144||| Conjunction with truth is a no-op
144||| Conjunction with truth is a no-op
145pairUnitRight : Iso (a, ()) a
145pairUnitRight : Iso (a, ()) a
146−pairUnitRight = MkIso fst (\x => (x, ())) (\x => Refl) ok
146+pairUnitRight = MkIso fst (\x => (x, ())) (\_ => Refl) (\(_, ()) => Refl)
147− where ok : (x : (a, ())) -> (fst x, ()) = x
148− ok (x, ()) = Refl
149
147
150||| Conjunction with truth is a no-op
148||| Conjunction with truth is a no-op
151pairUnitLeft : Iso ((), a) a
149pairUnitLeft : Iso ((), a) a
@@ -161,8 +159,7 @@ pairBotRight = isoTrans pairComm pairBotLeft
161
159
162||| Isomorphism is a congruence with regards to conjunction
160||| Isomorphism is a congruence with regards to conjunction
163pairCong : Iso a a' -> Iso b b' -> Iso (a, b) (a', b')
161pairCong : Iso a a' -> Iso b b' -> Iso (a, b) (a', b')
164−pairCong {a = a} {a' = a'} {b = b} {b' = b'}
165− (MkIso to from toFrom fromTo)
162+pairCong (MkIso to from toFrom fromTo)
166 (MkIso to' from' toFrom' fromTo') =
163 (MkIso to' from' toFrom' fromTo') =
167 MkIso to'' from'' iso1 iso2
164 MkIso to'' from'' iso1 iso2
168 where to'' : (a, b) -> (a', b')
165 where to'' : (a, b) -> (a', b')
@@ -205,7 +202,7 @@ distribLeft = MkIso to from toFrom fromTo
205
202
206||| Products distribute over sums
203||| Products distribute over sums
207distribRight : Iso (a, Either b c) (Either (a, b) (a, c))
204distribRight : Iso (a, Either b c) (Either (a, b) (a, c))
208−distribRight {a} {b} {c} = (pairComm `isoTrans` distribLeft) `isoTrans` eitherCong pairComm pairComm
205+distribRight = (pairComm `isoTrans` distribLeft) `isoTrans` eitherCong pairComm pairComm
209
206
210
207
211-- Enable preorder reasoning syntax over isomorphisms
208-- Enable preorder reasoning syntax over isomorphisms
@@ -222,7 +219,7 @@ step a iso1 iso2 = isoTrans iso1 iso2
222-- Isomorphisms over Maybe
219-- Isomorphisms over Maybe
223||| Isomorphism is a congruence with respect to Maybe
220||| Isomorphism is a congruence with respect to Maybe
224maybeCong : Iso a b -> Iso (Maybe a) (Maybe b)
221maybeCong : Iso a b -> Iso (Maybe a) (Maybe b)
225−maybeCong {a} {b} (MkIso to from toFrom fromTo) = MkIso (map to) (map from) ok1 ok2
222+maybeCong (MkIso to from toFrom fromTo) = MkIso (map to) (map from) ok1 ok2
226 where ok1 : (y : Maybe b) -> map to (map from y) = y
223 where ok1 : (y : Maybe b) -> map to (map from y) = y
227 ok1 Nothing = Refl
224 ok1 Nothing = Refl
228 ok1 (Just x) = (Just (to (from x))) ={ cong (toFrom x) }= (Just x) QED
225 ok1 (Just x) = (Just (to (from x))) ={ cong (toFrom x) }= (Just x) QED
@@ -253,7 +250,7 @@ maybeVoidUnit = (Maybe Void) ={ maybeEither }=
253 () QED
250 () QED
254
251
255eitherMaybeLeftMaybe : Iso (Either (Maybe a) b) (Maybe (Either a b))
252eitherMaybeLeftMaybe : Iso (Either (Maybe a) b) (Maybe (Either a b))
256−eitherMaybeLeftMaybe {a} {b} =
253+eitherMaybeLeftMaybe =
257 (Either (Maybe a) b) ={ eitherCongLeft maybeEither }=
254 (Either (Maybe a) b) ={ eitherCongLeft maybeEither }=
258 (Either (Either a ()) b) ={ eitherAssoc }=
255 (Either (Either a ()) b) ={ eitherAssoc }=
259 (Either a (Either () b)) ={ eitherCongRight eitherComm }=
256 (Either a (Either () b)) ={ eitherCongRight eitherComm }=
@@ -263,7 +260,7 @@ eitherMaybeLeftMaybe {a} {b} =
263
260
264
261
265eitherMaybeRightMaybe : Iso (Either a (Maybe b)) (Maybe (Either a b))
262eitherMaybeRightMaybe : Iso (Either a (Maybe b)) (Maybe (Either a b))
266−eitherMaybeRightMaybe {a} {b} =
263+eitherMaybeRightMaybe =
267 (Either a (Maybe b)) ={ eitherComm }=
264 (Either a (Maybe b)) ={ eitherComm }=
268 (Either (Maybe b) a) ={ eitherMaybeLeftMaybe }=
265 (Either (Maybe b) a) ={ eitherMaybeLeftMaybe }=
269 (Maybe (Either b a)) ={ maybeCong eitherComm }=
266 (Maybe (Either b a)) ={ maybeCong eitherComm }=
@@ -288,8 +285,8 @@ maybeIsoS = MkIso forth back fb bf
288 fb (FS x) = Refl
285 fb (FS x) = Refl
289
286
290finZeroBot : Iso (Fin 0) Void
287finZeroBot : Iso (Fin 0) Void
291−finZeroBot = MkIso (\x => void (uninhabited x))
288+finZeroBot = MkIso (void . uninhabited)
292− (\x => void x)
289+ void
293 (\x => void x)
290 (\x => void x)
294 (\x => void (uninhabited x))
291 (\x => void (uninhabited x))
295
292
libs/contrib/Control/Algebra/Laws.idr+128−80
@@ -6,98 +6,146 @@ import Interfaces.Verified
6
6
7%access export
7%access export
8
8
9+||| -(-x) = x in any verified group.
10+inverseSquaredIsIdentity : VerifiedGroup t => (x : t) ->
11+ inverse (inverse x) = x
12+inverseSquaredIsIdentity x =
13+ let
14+ ix = inverse x
15+ iix = inverse ix
16+ in
17+ rewrite sym $ monoidNeutralIsNeutralR iix in
18+ rewrite sym $ groupInverseIsInverseL x in
19+ rewrite sym $ semigroupOpIsAssociative x ix iix in
20+ rewrite groupInverseIsInverseL ix in
21+ monoidNeutralIsNeutralL x
22+
9−||| A prof that -0 = 0 in any verified group.
23+||| -0 = 0 in any verified group.
10−inverseNeutralIsNeutral : VerifiedGroup t => inverse (the t A.neutral) = A.neutral
24+inverseNeutralIsNeutral : VerifiedGroup t =>
25+ inverse (the t A.neutral) = A.neutral
11inverseNeutralIsNeutral {t} =
26inverseNeutralIsNeutral {t} =
12− let zero = the t neutral
27+ let e = the t neutral in
13− step1 = cong {f = (<+> inverse zero)} (the (zero = zero) Refl)
14− step2 = replace {P = \x => zero <+> inverse zero = x} (groupInverseIsInverseL zero) step1
28+ rewrite sym $ cong {f = inverse} (groupInverseIsInverseL e) in
15− in
16− replace {P = \x => x = neutral} (monoidNeutralIsNeutralR $ inverse zero) step2
29+ rewrite monoidNeutralIsNeutralR $ inverse e in
30+ inverseSquaredIsIdentity e
17
31
18−||| A proof that -(-x) = x in any verified group.
32+||| -(x + y) = -y + -x in any verified group.
19−inverseSquaredIsIdentity : VerifiedGroup t => (x : t) -> inverse (inverse x) = x
33+inverseOfSum : VerifiedGroup t => (l, r : t) ->
20−inverseSquaredIsIdentity {t} x =
34+ inverse (l <+> r) = inverse r <+> inverse l
35+inverseOfSum {t} l r =
36+ let
21− let zero = the t neutral
37+ e = the t neutral
22− step1 = cong {f = (x <+>)} (groupInverseIsInverseL (inverse x))
38+ il = inverse l
23− step2 = replace {P = \r => r = x <+> neutral} (semigroupOpIsAssociative x (inverse x) (inverse $ inverse x)) step1
39+ ir = inverse r
24− step3 = replace {P = \r => r <+> inverse (inverse x) = x <+> neutral} (groupInverseIsInverseL x) step2
40+ sum = l <+> r
41+ ilr = inverse sum
42+ iril = ir <+> il
43+ ile = il <+> e
44+ in
45+ -- expand
25− step4 = replace {P = \r => r = x <+> neutral} (monoidNeutralIsNeutralR (inverse $ inverse x)) step3
46+ rewrite sym $ monoidNeutralIsNeutralR ilr in
26− in
47+ rewrite sym $ groupInverseIsInverseR r in
48+ rewrite sym $ monoidNeutralIsNeutralL ir in
49+ rewrite sym $ groupInverseIsInverseR l in
50+ -- shuffle
51+ rewrite semigroupOpIsAssociative ir il l in
52+ rewrite sym $ semigroupOpIsAssociative iril l r in
53+ rewrite sym $ semigroupOpIsAssociative iril sum ilr in
54+ -- contract
55+ rewrite sym $ monoidNeutralIsNeutralL il in
56+ rewrite groupInverseIsInverseL sum in
57+ rewrite sym $ semigroupOpIsAssociative (ir <+> ile) l ile in
58+ rewrite semigroupOpIsAssociative l il e in
59+ rewrite groupInverseIsInverseL l in
27− replace {P = \r => inverse (inverse x) = r} (monoidNeutralIsNeutralL x) step4
60+ rewrite monoidNeutralIsNeutralL e in
61+ Refl
28
62
29−||| A proof that -(x + y) = -x - y in any verified abelian group.
63+||| -(x + y) = -x + -y in any verified abelian group.
30−inverseDistributesOverGroupOp : VerifiedAbelianGroup t => (l, r : t) -> inverse (l <+> r) = inverse l <+> inverse r
64+inverseDistributesOverGroupOp : VerifiedAbelianGroup t => (l, r : t) ->
65+ inverse (l <+> r) = inverse l <+> inverse r
31−inverseDistributesOverGroupOp {t} l r =
66+inverseDistributesOverGroupOp l r =
32− let step1 = replace {P = \x => x = neutral} (sym $ groupInverseIsInverseL (l <+> r)) $ the (the t neutral = neutral) Refl
33− step2 = cong {f = ((inverse r) <+>) . ((inverse l) <+>)} step1
34− step3 = replace {P = \x => inverse r <+> (inverse l <+> (l <+> r <+> inverse (l <+> r))) = inverse r <+> x} (monoidNeutralIsNeutralL (inverse l)) step2
35− step4 = replace {P = \x => x = inverse r <+> inverse l} (semigroupOpIsAssociative (inverse r) (inverse l) (l <+> r <+> inverse (l <+> r))) step3
36− step5 = replace {P = \x => x = inverse r <+> inverse l} (semigroupOpIsAssociative (inverse r <+> inverse l) (l <+> r) (inverse (l <+> r))) step4
37− step6 = replace {P = \x => x <+> inverse (l <+> r) = inverse r <+> inverse l} (semigroupOpIsAssociative (inverse r <+> inverse l) l r) step5
38− step7 = replace {P = \x => x <+> r <+> inverse (l <+> r) = inverse r <+> inverse l} (sym $ semigroupOpIsAssociative (inverse r) (inverse l) l) step6
39− step8 = replace {P = \x => inverse r <+> x <+> r <+> inverse (l <+> r) = inverse r <+> inverse l} (groupInverseIsInverseR l) step7
40− step9 = replace {P = \x => x <+> r <+> inverse (l <+> r) = inverse r <+> inverse l} (monoidNeutralIsNeutralL (inverse r)) step8
41− step10 = replace {P = \x => x <+> inverse (l <+> r) = inverse r <+> inverse l} (groupInverseIsInverseR r) step9
42− step11 = replace {P = \x => x = inverse r <+> inverse l} (monoidNeutralIsNeutralR (inverse (l <+> r))) step10
43− in
44− replace {P = \x => inverse (l <+> r) = x} (abelianGroupOpIsCommutative (inverse r) (inverse l)) step11
67+ rewrite abelianGroupOpIsCommutative (inverse l) (inverse r) in
68+ inverseOfSum l r
45
69
46−||| A proof that anything multiplied by zero yields zero back.
70+||| Anything multiplied by zero yields zero back in a verified ring.
47−multNeutralAbsorbingL : VerifiedRingWithUnity t => (r : t) -> A.neutral <.> r = A.neutral
71+multNeutralAbsorbingL : VerifiedRing t => (r : t) ->
72+ A.neutral <.> r = A.neutral
48−multNeutralAbsorbingL r =
73+multNeutralAbsorbingL {t} r =
49− let step1 = the (unity <.> r = r) (ringWithUnityIsUnityR r)
74+ let
75+ e = the t neutral
76+ ir = inverse r
77+ exr = e <.> r
78+ iexr = inverse exr
79+ in
50− step2 = replace {P = \x => x <.> r = r} (sym $ monoidNeutralIsNeutralR unity) step1
80+ rewrite sym $ monoidNeutralIsNeutralR exr in
51− step3 = replace {P = \x => x = r} (ringOpIsDistributiveR neutral unity r) step2
81+ rewrite sym $ groupInverseIsInverseR exr in
52− step4 = replace {P = \x => neutral <.> r <+> x = r} (ringWithUnityIsUnityR r) step3
53− step5 = cong {f = \x => x <+> inverse r} step4
54− step6 = replace {P = \x => x = r <+> inverse r} (sym $ semigroupOpIsAssociative (neutral <.> r) r (inverse r)) step5
82+ rewrite sym $ semigroupOpIsAssociative iexr exr ((iexr <+> exr) <.> r) in
55− step7 = replace {P = \x => neutral <.> r <+> x = x} (groupInverseIsInverseL r) step6
83+ rewrite groupInverseIsInverseR exr in
56− in
84+ rewrite sym $ ringOpIsDistributiveR e e r in
57− replace {P = \x => x = neutral} (monoidNeutralIsNeutralL (neutral <.> r)) step7
85+ rewrite monoidNeutralIsNeutralR e in
86+ groupInverseIsInverseR exr
58
87
59−||| A proof that anything multiplied by zero yields zero back.
88+||| Anything multiplied by zero yields zero back in a verified ring.
60−multNeutralAbsorbingR : VerifiedRingWithUnity t => (l : t) -> l <.> A.neutral = A.neutral
89+multNeutralAbsorbingR : VerifiedRing t => (l : t) ->
90+ l <.> A.neutral = A.neutral
61−multNeutralAbsorbingR l =
91+multNeutralAbsorbingR {t} l =
62− let step1 = the (l <.> unity = l) (ringWithUnityIsUnityL l)
92+ let
63− step2 = replace {P = \x => l <.> x = l} (sym $ monoidNeutralIsNeutralR unity) step1
93+ e = the t neutral
64− step3 = replace {P = \x => x = l} (ringOpIsDistributiveL l neutral unity) step2
94+ il = inverse l
65− step4 = replace {P = \x => l <.> neutral <+> x = l} (ringWithUnityIsUnityL l) step3
95+ lxe = l <.> e
66− step5 = cong {f = \x => x <+> inverse l} step4
96+ ilxe = inverse lxe
97+ in
98+ rewrite sym $ monoidNeutralIsNeutralL lxe in
99+ rewrite sym $ groupInverseIsInverseL lxe in
67− step6 = replace {P = \x => x = l <+> inverse l} (sym $ semigroupOpIsAssociative (l <.> neutral) l (inverse l)) step5
100+ rewrite semigroupOpIsAssociative (l <.> (lxe <+> ilxe)) lxe ilxe in
68− step7 = replace {P = \x => l <.> neutral <+> x = x} (groupInverseIsInverseL l) step6
101+ rewrite groupInverseIsInverseL lxe in
69− in
102+ rewrite sym $ ringOpIsDistributiveL l e e in
70− replace {P = \x => x = neutral} (monoidNeutralIsNeutralL (l <.> neutral)) step7
103+ rewrite monoidNeutralIsNeutralL e in
104+ groupInverseIsInverseL lxe
71
105
72−||| A proof that inverse operator can be extracted before multiplication
106+||| Inverse operator can be extracted before multiplication.
73||| (-x)y = -(xy)
107||| (-x)y = -(xy)
74−multInverseInversesL : VerifiedRingWithUnity t => (l, r : t) -> inverse l <.> r = inverse (l <.> r)
108+multInverseInversesL : VerifiedRing t => (l, r : t) ->
109+ inverse l <.> r = inverse (l <.> r)
75multInverseInversesL l r =
110multInverseInversesL l r =
111+ let
112+ il = inverse l
113+ lxr = l <.> r
114+ ilxr = il <.> r
115+ i_lxr = inverse lxr
116+ in
117+ rewrite sym $ monoidNeutralIsNeutralR ilxr in
118+ rewrite sym $ groupInverseIsInverseR lxr in
119+ rewrite sym $ semigroupOpIsAssociative i_lxr lxr ilxr in
120+ rewrite sym $ ringOpIsDistributiveR l il r in
76− let step1 = replace {P = \x => x <.> r = neutral} (sym $ groupInverseIsInverseL l) (multNeutralAbsorbingL r)
121+ rewrite groupInverseIsInverseL l in
77− step2 = replace {P = \x => x = neutral} (ringOpIsDistributiveR l (inverse l) r) step1
122+ rewrite multNeutralAbsorbingL r in
78− step3 = cong {f = ((inverse (l <.> r)) <+>)} step2
79− step4 = replace {P = \x => inverse (l <.> r) <+> (l <.> r <+> inverse l <.> r) = x} (monoidNeutralIsNeutralL (inverse (l <.> r))) step3
123+ monoidNeutralIsNeutralL i_lxr
80− step5 = replace {P = \x => x = inverse (l <.> r)} (semigroupOpIsAssociative (inverse (l <.> r)) (l <.> r) (inverse l <.> r)) step4
81− step6 = replace {P = \x => x <+> inverse l <.> r = inverse (l <.> r)} (groupInverseIsInverseR (l <.> r)) step5
82− in
83− replace {P = \x => x = inverse (l <.> r)} (monoidNeutralIsNeutralR (inverse l <.> r)) step6
84
124
85−||| A proof that inverse operator can be extracted before multiplication
125+||| Inverse operator can be extracted before multiplication.
86||| x(-y) = -(xy)
126||| x(-y) = -(xy)
87−multInverseInversesR : VerifiedRingWithUnity t => (l, r : t) -> l <.> inverse r = inverse (l <.> r)
127+multInverseInversesR : VerifiedRing t => (l, r : t) ->
128+ l <.> inverse r = inverse (l <.> r)
88multInverseInversesR l r =
129multInverseInversesR l r =
89− let step1 = replace {P = \x => l <.> x = neutral} (sym $ groupInverseIsInverseL r) (multNeutralAbsorbingR l)
130+ let
90− step2 = replace {P = \x => x = neutral} (ringOpIsDistributiveL l r (inverse r)) step1
131+ ir = inverse r
91− step3 = cong {f = ((inverse (l <.> r)) <+>)} step2
132+ lxr = l <.> r
133+ lxir = l <.> ir
134+ ilxr = inverse lxr
135+ in
92− step4 = replace {P = \x => inverse (l <.> r) <+> (l <.> r <+> l <.> inverse r) = x} (monoidNeutralIsNeutralL (inverse (l <.> r))) step3
136+ rewrite sym $ monoidNeutralIsNeutralL lxir in
137+ rewrite sym $ groupInverseIsInverseL lxr in
93− step5 = replace {P = \x => x = inverse (l <.> r)} (semigroupOpIsAssociative (inverse (l <.> r)) (l <.> r) (l <.> inverse r)) step4
138+ rewrite semigroupOpIsAssociative lxir lxr ilxr in
139+ rewrite sym $ ringOpIsDistributiveL l ir r in
94− step6 = replace {P = \x => x <+> l <.> inverse r = inverse (l <.> r)} (groupInverseIsInverseR (l <.> r)) step5
140+ rewrite groupInverseIsInverseR r in
95− in
141+ rewrite multNeutralAbsorbingR l in
96− replace {P = \x => x = inverse (l <.> r)} (monoidNeutralIsNeutralR (l <.> inverse r)) step6
142+ monoidNeutralIsNeutralR ilxr
97
143
98−||| A proof that multiplication of inverses is the same as multiplication of original
144+||| Multiplication of inverses is the same as multiplication of
99−||| elements. (-x)(-y) = xy
145+||| original elements.
146+||| (-x)(-y) = xy
100−multNegativeByNegativeIsPositive : VerifiedRingWithUnity t => (l, r : t) -> inverse l <.> inverse r = l <.> r
147+multNegativeByNegativeIsPositive : VerifiedRing t => (l, r : t) ->
148+ inverse l <.> inverse r = l <.> r
101multNegativeByNegativeIsPositive l r =
149multNegativeByNegativeIsPositive l r =
102 rewrite multInverseInversesR (inverse l) r in
150 rewrite multInverseInversesR (inverse l) r in
103 rewrite sym $ multInverseInversesL (inverse l) r in
151 rewrite sym $ multInverseInversesL (inverse l) r in
libs/contrib/Data/List/Reverse.idr+53
@@ -1,3 +1,4 @@
1+||| Properties of the reverse function.
1module Data.List.Reverse
2module Data.List.Reverse
2
3
3%default total
4%default total
@@ -33,6 +34,19 @@ reverseAppend (x :: xs) ys =
33 rewrite reverseCons x xs in
34 rewrite reverseCons x xs in
34 sym $ appendAssociative (reverse ys) (reverse xs) [x]
35 sym $ appendAssociative (reverse ys) (reverse xs) [x]
35
36
37+||| A recursive definition of reverse.
38+reverseRec : List a -> List a
39+reverseRec [] = []
40+reverseRec (x :: xs) = reverseRec xs ++ [x]
41+
42+||| The iterative and recursive defintions of reverse are the same.
43+reverseEquiv : (xs : List a) -> reverseRec xs = reverse xs
44+reverseEquiv [] = Refl
45+reverseEquiv (x :: xs) =
46+ rewrite reverseEquiv xs in
47+ rewrite reverseAppend [x] xs in
48+ Refl
49+
36||| Reversing a singleton list is a no-op.
50||| Reversing a singleton list is a no-op.
37reverseSingletonId : (x : a) -> reverse [x] = [x]
51reverseSingletonId : (x : a) -> reverse [x] = [x]
38reverseSingletonId _ = Refl
52reverseSingletonId _ = Refl
@@ -44,3 +58,42 @@ reverseReverseId (x :: xs) =
44 rewrite reverseCons x xs in
58 rewrite reverseCons x xs in
45 rewrite reverseAppend (reverse xs) [x] in
59 rewrite reverseAppend (reverse xs) [x] in
46 cong $ reverseReverseId xs
60 cong $ reverseReverseId xs
61+
62+||| Reversing onto preserves list length.
63+reverseOntoLength : (xs, acc : List a) ->
64+ length $ reverseOnto acc xs = length acc + length xs
65+reverseOntoLength [] acc = rewrite plusZeroRightNeutral (length acc) in Refl
66+reverseOntoLength (x :: xs) acc =
67+ rewrite reverseOntoLength xs (x :: acc) in
68+ plusSuccRightSucc (length acc) (length xs)
69+
70+||| Reversing preserves list length.
71+reverseLength : (xs : List a) -> length $ reverse xs = length xs
72+reverseLength xs = reverseOntoLength xs []
73+
74+||| Equal reversed lists are equal.
75+reverseEqual : (xs, ys : List a) -> reverse xs = reverse ys -> xs = ys
76+reverseEqual xs ys prf =
77+ rewrite sym $ reverseReverseId xs in
78+ rewrite prf in
79+ reverseReverseId ys
80+
81+||| Do geese see God?
82+data Palindrome : (xs : List a) -> Type where
83+ Empty : Palindrome []
84+ Single : Palindrome [_]
85+ Multi : Palindrome xs -> Palindrome $ [x] ++ xs ++ [x]
86+
87+||| A Palindrome reversed is itself.
88+palindromeReverse : (xs : List a) -> Palindrome xs -> reverse xs = xs
89+palindromeReverse [] Empty = Refl
90+palindromeReverse [_] Single = Refl
91+palindromeReverse ([x] ++ ys ++ [x]) (Multi pf) =
92+ rewrite reverseAppend ([x] ++ ys) [x] in
93+ rewrite reverseAppend [x] ys in
94+ rewrite palindromeReverse ys pf in
95+ Refl
96+
97+||| Only Palindromes are equal to their own reverse.
98+postulate -- This is a tough one. Any takers?
99+reversePalindrome : (xs : List a) -> reverse xs = xs -> Palindrome xs
libs/prelude/Prelude/Nat.idr+14−23
@@ -557,26 +557,21 @@ multCommutative (S left) right =
557 rewrite multRightSuccPlus right left in
557 rewrite multRightSuccPlus right left in
558 Refl
558 Refl
559
559
560−total multDistributesOverPlusRight : (left : Nat) -> (centre : Nat) -> (right : Nat) ->
561− left * (centre + right) = (left * centre) + (left * right)
562−multDistributesOverPlusRight Z centre right = Refl
563−multDistributesOverPlusRight (S left) centre right =
564− let inductiveHypothesis = multDistributesOverPlusRight left centre right in
565− rewrite inductiveHypothesis in
566− rewrite plusAssociative (plus centre (mult left centre)) right (mult left right) in
567− rewrite sym (plusAssociative centre (mult left centre) right) in
568− rewrite plusCommutative (mult left centre) right in
569− rewrite plusAssociative centre right (mult left centre) in
570− rewrite plusAssociative (plus centre right) (mult left centre) (mult left right) in
571− Refl
572−
573total multDistributesOverPlusLeft : (left : Nat) -> (centre : Nat) -> (right : Nat) ->
560total multDistributesOverPlusLeft : (left : Nat) -> (centre : Nat) -> (right : Nat) ->
574 (left + centre) * right = (left * right) + (centre * right)
561 (left + centre) * right = (left * right) + (centre * right)
575−multDistributesOverPlusLeft left centre right =
562+multDistributesOverPlusLeft Z centre right = Refl
576− rewrite multCommutative (left + centre) right in
563+multDistributesOverPlusLeft (S k) centre right =
564+ rewrite multDistributesOverPlusLeft k centre right in
565+ rewrite plusAssociative right (k * right) (centre * right) in
566+ Refl
567+
568+total multDistributesOverPlusRight : (left : Nat) -> (centre : Nat) -> (right : Nat) ->
569+ left * (centre + right) = (left * centre) + (left * right)
570+multDistributesOverPlusRight left centre right =
571+ rewrite multCommutative left (centre + right) in
577− rewrite multCommutative left right in
572+ rewrite multCommutative left centre in
578− rewrite multCommutative centre right in
573+ rewrite multCommutative left right in
579− multDistributesOverPlusRight right left centre
574+ multDistributesOverPlusLeft centre right left
580
575
581total multAssociative : (left : Nat) -> (centre : Nat) -> (right : Nat) ->
576total multAssociative : (left : Nat) -> (centre : Nat) -> (right : Nat) ->
582 left * (centre * right) = (left * centre) * right
577 left * (centre * right) = (left * centre) * right
@@ -588,11 +583,7 @@ multAssociative (S left) centre right =
588 Refl
583 Refl
589
584
590total multOneLeftNeutral : (right : Nat) -> 1 * right = right
585total multOneLeftNeutral : (right : Nat) -> 1 * right = right
591−multOneLeftNeutral Z = Refl
586+multOneLeftNeutral right = plusZeroRightNeutral right
592−multOneLeftNeutral (S right) =
593− let inductiveHypothesis = multOneLeftNeutral right in
594− rewrite inductiveHypothesis in
595− Refl
596
587
597total multOneRightNeutral : (left : Nat) -> left * 1 = left
588total multOneRightNeutral : (left : Nat) -> left * 1 = left
598multOneRightNeutral left = rewrite multCommutative left 1 in multOneLeftNeutral left
589multOneRightNeutral left = rewrite multCommutative left 1 in multOneLeftNeutral left
src/Idris/Core/TT.hs+1−1
@@ -325,7 +325,7 @@ bindTC x k = case x of
325instance Monad TC where
325instance Monad TC where
326 return x = OK x
326 return x = OK x
327 x >>= k = bindTC x k
327 x >>= k = bindTC x k
328−#if !(MIN_VERSION_base(4,12,0))
328+#if !(MIN_VERSION_base(4,13,0))
329 fail = Fail.fail
329 fail = Fail.fail
330#endif
330#endif
331
331
src/Idris/Parser/Stack.hs+14−1
@@ -5,7 +5,7 @@ Description : Idris parser stack and its primitives.
5License : BSD3
5License : BSD3
6Maintainer : The Idris Community.
6Maintainer : The Idris Community.
7-}
7-}
8−{-# LANGUAGE ConstraintKinds, FlexibleContexts, MultiParamTypeClasses #-}
8+{-# LANGUAGE CPP, ConstraintKinds, FlexibleContexts, MultiParamTypeClasses #-}
9module Idris.Parser.Stack
9module Idris.Parser.Stack
10 ( -- * Parsing
10 ( -- * Parsing
11 Parser(..)
11 Parser(..)
@@ -77,11 +77,20 @@ parseErrorOffset = P.errorOffset . parseError
77instance Message ParseError where
77instance Message ParseError where
78 messageExtent err = sourcePositionFC pos
78 messageExtent err = sourcePositionFC pos
79 where
79 where
80+#if MIN_VERSION_megaparsec(8,0,0)
81+ P.PosState {P.pstateSourcePos = pos} =
82+ P.reachOffsetNoLine (parseErrorOffset err) (parseErrorPosState err)
83+#else
80 (pos, _) = P.reachOffsetNoLine (parseErrorOffset err) (parseErrorPosState err)
84 (pos, _) = P.reachOffsetNoLine (parseErrorOffset err) (parseErrorPosState err)
85+#endif
81 messageText = PP.text . init . P.parseErrorTextPretty . parseError
86 messageText = PP.text . init . P.parseErrorTextPretty . parseError
82 messageSource err = Just sline
87 messageSource err = Just sline
83 where
88 where
89+#if MIN_VERSION_megaparsec(8,0,0)
90+ (sline, _) = P.reachOffset (parseErrorOffset err) (parseErrorPosState err)
91+#else
84 (_, sline, _) = P.reachOffset (parseErrorOffset err) (parseErrorPosState err)
92 (_, sline, _) = P.reachOffset (parseErrorOffset err) (parseErrorPosState err)
93+#endif
85
94
86-- | A fully formatted parse error, with caret and bar, etc.
95-- | A fully formatted parse error, with caret and bar, etc.
87prettyError :: ParseError -> String
96prettyError :: ParseError -> String
@@ -89,7 +98,11 @@ prettyError = P.errorBundlePretty . unParseError
89
98
90{- * Mark and restore -}
99{- * Mark and restore -}
91
100
101+#if MIN_VERSION_megaparsec(8,0,0)
102+type Mark = P.State String Void
103+#else
92type Mark = P.State String
104type Mark = P.State String
105+#endif
93
106
94-- | Retrieve the parser state so we can restart from this point later.
107-- | Retrieve the parser state so we can restart from this point later.
95mark :: Parsing m => m Mark
108mark :: Parsing m => m Mark
stack-11.22.yamlnew file+21
@@ -0,0 +1,21 @@
1+#recheck extra-deps next on resolver or cabal file change
2+resolver: lts-11.22
3+
4+extra-deps:
5+- cheapskate-0.1.1.2
6+- megaparsec-7.0.5
7+- Cabal-2.4.1.0
8+- network-3.1.1.1
9+- parser-combinators-1.0.0
10+
11+flags:
12+ idris:
13+ FFI: true
14+ GMP: true
15+
16+ghc-options:
17+ idris: -fwarn-unused-imports -fwarn-unused-binds
18+
19+nix:
20+ enable: false
21+ shell-file: stack-shell.nix
stack-12.26.yamlnew file+20
@@ -0,0 +1,20 @@
1+#recheck extra-deps next on resolver or cabal file change
2+resolver: lts-12.26
3+
4+extra-deps:
5+- cheapskate-0.1.1.2
6+- megaparsec-7.0.5
7+- Cabal-2.4.1.0
8+- network-3.1.1.1
9+
10+flags:
11+ idris:
12+ FFI: true
13+ GMP: true
14+
15+ghc-options:
16+ idris: -fwarn-unused-imports -fwarn-unused-binds
17+
18+nix:
19+ enable: false
20+ shell-file: stack-shell.nix
stack-15.3.yamlnew file+17
@@ -0,0 +1,17 @@
1+#recheck extra-deps next on resolver or cabal file change
2+resolver: lts-15.3
3+
4+extra-deps:
5+- cheapskate-0.1.1.2
6+
7+flags:
8+ idris:
9+ FFI: true
10+ GMP: true
11+
12+ghc-options:
13+ idris: -fwarn-unused-imports -fwarn-unused-binds
14+
15+nix:
16+ enable: false
17+ shell-file: stack-shell.nix
stack-15.4.yamlnew file+17
@@ -0,0 +1,17 @@
1+#recheck extra-deps next on resolver or cabal file change
2+resolver: lts-15.4
3+
4+extra-deps:
5+- cheapskate-0.1.1.2
6+
7+flags:
8+ idris:
9+ FFI: true
10+ GMP: true
11+
12+ghc-options:
13+ idris: -fwarn-unused-imports -fwarn-unused-binds
14+
15+nix:
16+ enable: false
17+ shell-file: stack-shell.nix
stack-alt.yamldeleted−25
@@ -1,25 +0,0 @@
1−#recheck extra-deps next on resolver or cabal file change
2−resolver: lts-11.4
3−
4−packages:
5− - location: .
6−
7−extra-deps:
8− - network-2.8.0.0@sha256:aae171e6c6028a7791dbe4de5b9d2da398056359e3cc7927465ffa3cdae1aa0b
9− - Cabal-2.2.0.1@sha256:2a80d8fb655474f0eaeb20434c47f64f84e6302e55973056f00df8ca050b9683
10− - megaparsec-7.0.4
11− - parser-combinators-1.0.0
12− - zip-archive-0.3.3@sha256:47cf2d66cc8e237f7226837758e1b041e24048ef3820d3d10276c500edb921bf
13− - containers-0.5.11.0@sha256:28ad7337057442f75bc689315ab4ec7bdf5e6b2c39668f306672cecd82c02798
14−
15−flags:
16− idris:
17− FFI: true
18− GMP: true
19−
20−ghc-options:
21− idris: -fwarn-unused-imports -fwarn-unused-binds
22−
23−nix:
24− enable: false
25− shell-file: stack-shell.nix
stack.yamlmode 100644 → 120000+1−26
@@ -1,26 +0,0 @@
1−#recheck extra-deps next on resolver or cabal file change
2−resolver: lts-13.21
3−
4−extra-deps:
5− - network-2.8.0.0@sha256:aae171e6c6028a7791dbe4de5b9d2da398056359e3cc7927465ffa3cdae1aa0b
6− - megaparsec-7.0.4
7− - parser-combinators-1.0.0
8− - zip-archive-0.3.3@sha256:47cf2d66cc8e237f7226837758e1b041e24048ef3820d3d10276c500edb921bf
9− - containers-0.5.11.0@sha256:28ad7337057442f75bc689315ab4ec7bdf5e6b2c39668f306672cecd82c02798
10− - tasty-rerun-1.1.14@sha256:ba9c19a281535bea566e1044bc02c36ef17abcb310af4b6a149ec11780c7ce35
11− - binary-0.8.7.0@sha256:ae3e6cca723ac55c54bbb3fa771bcf18142bc727afd57818e66d6ee6c8044f12
12− - text-1.2.4.0@sha256:8c24450feb8e3bbb7ea3e17af24ef57e85db077c4bf53e5bcc345b283d1b1d5b
13− - HsYAML-0.2.1.0@sha256:e4677daeba57f7a1e9a709a1f3022fe937336c91513e893166bd1f023f530d68,5311
14− - HsYAML-aeson-0.2.0.0@sha256:04796abfc01cffded83f37a10e6edba4f0c0a15d45bef44fc5bb4313d9c87757,1791
15−
16−flags:
17− idris:
18− FFI: true
19− GMP: true
20−
21−ghc-options:
22− idris: -fwarn-unused-imports -fwarn-unused-binds
23−
24−nix:
25− enable: false
26− shell-file: stack-shell.nix
@@ -0,0 +1 @@
1+stack-15.4.yaml