mirror of
https://github.com/idris-lang/Idris2.git
synced 2024-12-25 04:33:45 +03:00
parent
d952741563
commit
4c7d0db4bc
@ -109,6 +109,7 @@ modules =
|
||||
Libraries.Data.LengthMatch,
|
||||
Libraries.Data.List.Extra,
|
||||
Libraries.Data.List.Lazy,
|
||||
Libraries.Data.List1,
|
||||
Libraries.Data.NameMap,
|
||||
Libraries.Data.SortedMap,
|
||||
Libraries.Data.SortedSet,
|
||||
|
@ -86,6 +86,13 @@ export
|
||||
snoc : (xs : List1 a) -> (x : a) -> List1 a
|
||||
snoc xs x = append xs (singleton x)
|
||||
|
||||
public export
|
||||
unsnoc : (xs : List1 a) -> (List a, a)
|
||||
unsnoc (h ::: Nil) = (Nil, h)
|
||||
unsnoc (h ::: (x :: xs)) =
|
||||
let (ini,lst) = unsnoc (x ::: xs)
|
||||
in (h :: ini, lst)
|
||||
|
||||
------------------------------------------------------------------------
|
||||
-- Reverse
|
||||
|
||||
|
@ -6,6 +6,7 @@ import Core.Metadata
|
||||
import Core.Options
|
||||
import Core.Unify
|
||||
import Libraries.Utils.Path
|
||||
import Libraries.Data.List1 as Lib
|
||||
|
||||
import Idris.CommandLine
|
||||
import Idris.REPL
|
||||
@ -33,23 +34,26 @@ candidateDirs dname pkg bounds
|
||||
| Left err => pure []
|
||||
getFiles d []
|
||||
where
|
||||
toVersionNum : String -> List Nat
|
||||
toVersionNum str
|
||||
= case span (/= '.') str of
|
||||
(num, rest) =>
|
||||
case strM rest of
|
||||
StrNil => [stringToNatOrZ num]
|
||||
StrCons _ rest =>
|
||||
(stringToNatOrZ num :: toVersionNum rest)
|
||||
toVersion : String -> Maybe PkgVersion
|
||||
toVersion = map MkPkgVersion
|
||||
. traverse parsePositive
|
||||
. forget
|
||||
. split (== '.')
|
||||
|
||||
getVersion : String -> (String, PkgVersion)
|
||||
getVersion str
|
||||
= case span (/= '-') str of
|
||||
(name, ver) => case strM ver of
|
||||
StrNil => (name, MkPkgVersion [0])
|
||||
StrCons _ ver =>
|
||||
(name, MkPkgVersion (toVersionNum ver))
|
||||
_ => (str, MkPkgVersion [0])
|
||||
getVersion str =
|
||||
-- Split the dir name into parts concatenated by "-"
|
||||
-- treating the last part as the version number
|
||||
-- and the initial parts as the package name.
|
||||
-- For reasons of backwards compatibility, we also
|
||||
-- accept hyphenated directory names without a part
|
||||
-- corresponding to a version number.
|
||||
case Lib.unsnoc $ split (== '-') str of
|
||||
(Nil, last) => (last, MkPkgVersion [0])
|
||||
(init,last) =>
|
||||
case toVersion last of
|
||||
Just v => (concat $ intersperse "-" init, v)
|
||||
Nothing => (str, MkPkgVersion [0])
|
||||
|
||||
-- Return a list of paths that match the version spec
|
||||
-- (full name, version string)
|
||||
|
14
src/Libraries/Data/List1.idr
Normal file
14
src/Libraries/Data/List1.idr
Normal file
@ -0,0 +1,14 @@
|
||||
module Libraries.Data.List1
|
||||
|
||||
import public Data.List1
|
||||
|
||||
%default total
|
||||
|
||||
-- TODO: Remove this, once Data.List1.unsnoc from base is available
|
||||
-- to the compiler
|
||||
export
|
||||
unsnoc : (xs : List1 a) -> (List a, a)
|
||||
unsnoc (h ::: Nil) = (Nil, h)
|
||||
unsnoc (h ::: (x :: xs)) =
|
||||
let (ini,lst) = Libraries.Data.List1.unsnoc (x ::: xs)
|
||||
in (h :: ini, lst)
|
2
tests/idris2/pkg006/depends/bar-baz/bar-baz.ipkg
Normal file
2
tests/idris2/pkg006/depends/bar-baz/bar-baz.ipkg
Normal file
@ -0,0 +1,2 @@
|
||||
package bar-baz
|
||||
version = 1.0.1
|
2
tests/idris2/pkg006/depends/foo-bar-1.3.1/foo-bar.ipkg
Normal file
2
tests/idris2/pkg006/depends/foo-bar-1.3.1/foo-bar.ipkg
Normal file
@ -0,0 +1,2 @@
|
||||
package foo-bar
|
||||
version = 1.3.1
|
2
tests/idris2/pkg006/depends/quux/quux.ipkg
Normal file
2
tests/idris2/pkg006/depends/quux/quux.ipkg
Normal file
@ -0,0 +1,2 @@
|
||||
package quux
|
||||
version = 0.0.0
|
@ -1,3 +1,3 @@
|
||||
package test1
|
||||
|
||||
depends = foo, bar
|
||||
depends = foo, bar, foo-bar, quux, bar-baz
|
||||
|
@ -1,4 +1,8 @@
|
||||
package test2
|
||||
|
||||
depends = foo >= 0.5 && < 0.6,
|
||||
bar >= 1
|
||||
bar >= 1,
|
||||
foo-bar == 1.3.1,
|
||||
quux == 0,
|
||||
bar-baz == 0
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user