mirror of
https://github.com/edwinb/Idris2-boot.git
synced 2024-12-27 14:52:10 +03:00
Merge pull request #66 from abailly/no-prelude
check noprelude option when starting up without loading a file
This commit is contained in:
commit
f39b736110
@ -126,8 +126,10 @@ stMain opts
|
|||||||
|
|
||||||
u <- newRef UST initUState
|
u <- newRef UST initUState
|
||||||
updateREPLOpts
|
updateREPLOpts
|
||||||
|
session <- getSession
|
||||||
case fname of
|
case fname of
|
||||||
Nothing => logTime "Loading prelude" $
|
Nothing => logTime "Loading prelude" $
|
||||||
|
when (not $ noprelude session) $
|
||||||
readPrelude
|
readPrelude
|
||||||
Just f => logTime "Loading main file" $
|
Just f => logTime "Loading main file" $
|
||||||
loadMainFile f
|
loadMainFile f
|
||||||
|
@ -28,7 +28,7 @@ idrisTests
|
|||||||
"basic011", "basic012", "basic013", "basic014", "basic015",
|
"basic011", "basic012", "basic013", "basic014", "basic015",
|
||||||
"basic016", "basic017", "basic018", "basic019", "basic020",
|
"basic016", "basic017", "basic018", "basic019", "basic020",
|
||||||
"basic021", "basic022", "basic023", "basic024", "basic025",
|
"basic021", "basic022", "basic023", "basic024", "basic025",
|
||||||
"basic026", "basic027",
|
"basic026", "basic027", "basic028",
|
||||||
"coverage001", "coverage002", "coverage003", "coverage004",
|
"coverage001", "coverage002", "coverage003", "coverage004",
|
||||||
"error001", "error002", "error003", "error004", "error005",
|
"error001", "error002", "error003", "error004", "error005",
|
||||||
"error006", "error007", "error008", "error009", "error010",
|
"error006", "error007", "error008", "error009", "error010",
|
||||||
@ -143,4 +143,3 @@ main
|
|||||||
where
|
where
|
||||||
testPaths : String -> List String -> List String
|
testPaths : String -> List String -> List String
|
||||||
testPaths dir tests = map (\test => dir ++ "/" ++ test) tests
|
testPaths dir tests = map (\test => dir ++ "/" ++ test) tests
|
||||||
|
|
||||||
|
49
tests/idris2/basic028/Do.idr
Normal file
49
tests/idris2/basic028/Do.idr
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
data Maybe a = Nothing
|
||||||
|
| Just a
|
||||||
|
|
||||||
|
infixl 1 >>=
|
||||||
|
|
||||||
|
(>>=) : Maybe a -> (a -> Maybe b) -> Maybe b
|
||||||
|
(>>=) Nothing k = Nothing
|
||||||
|
(>>=) (Just x) k = k x
|
||||||
|
|
||||||
|
data Nat : Type where
|
||||||
|
Z : Nat
|
||||||
|
S : Nat -> Nat
|
||||||
|
|
||||||
|
plus : Nat -> Nat -> Nat
|
||||||
|
plus Z y = y
|
||||||
|
plus (S k) y = S (plus k y)
|
||||||
|
|
||||||
|
maybeAdd' : Maybe Nat -> Maybe Nat -> Maybe Nat
|
||||||
|
maybeAdd' x y
|
||||||
|
= x >>= \x' =>
|
||||||
|
y >>= \y' =>
|
||||||
|
Just (plus x' y')
|
||||||
|
|
||||||
|
maybeAdd : Maybe Nat -> Maybe Nat -> Maybe Nat
|
||||||
|
maybeAdd x y
|
||||||
|
= do x' <- x
|
||||||
|
y' <- y
|
||||||
|
Just (plus x' y')
|
||||||
|
|
||||||
|
data Either : Type -> Type -> Type where
|
||||||
|
Left : a -> Either a b
|
||||||
|
Right : b -> Either a b
|
||||||
|
|
||||||
|
mEmbed : Maybe a -> Maybe (Either String a)
|
||||||
|
mEmbed Nothing = Just (Left "FAIL")
|
||||||
|
mEmbed (Just x) = Just (Right x)
|
||||||
|
|
||||||
|
mPatBind : Maybe Nat -> Maybe Nat -> Maybe Nat
|
||||||
|
mPatBind x y
|
||||||
|
= do Right res <- mEmbed (maybeAdd x y)
|
||||||
|
| Left err => Just Z
|
||||||
|
Just res
|
||||||
|
|
||||||
|
mLetBind : Maybe Nat -> Maybe Nat -> Maybe Nat
|
||||||
|
mLetBind x y
|
||||||
|
= do let Just res = maybeAdd x y
|
||||||
|
| Nothing => Just Z
|
||||||
|
Just res
|
||||||
|
|
7
tests/idris2/basic028/expected
Normal file
7
tests/idris2/basic028/expected
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
Welcome to Idris 2 version 0.0. Enjoy yourself!
|
||||||
|
Main> 1/1: Building Do (Do.idr)
|
||||||
|
Main> Just (S (S (S Z)))
|
||||||
|
Main> Just Z
|
||||||
|
Main> Just (S (S (S Z)))
|
||||||
|
Main> Just Z
|
||||||
|
Main> Bye for now!
|
6
tests/idris2/basic028/input
Normal file
6
tests/idris2/basic028/input
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
:l Do.idr
|
||||||
|
mPatBind (Just (S Z)) (Just (S (S Z)))
|
||||||
|
mPatBind (Just (S Z)) Nothing
|
||||||
|
mLetBind (Just (S Z)) (Just (S (S Z)))
|
||||||
|
mLetBind (Just (S Z)) Nothing
|
||||||
|
:q
|
5
tests/idris2/basic028/run
Executable file
5
tests/idris2/basic028/run
Executable file
@ -0,0 +1,5 @@
|
|||||||
|
unset IDRIS2_PATH
|
||||||
|
|
||||||
|
$1 --no-prelude < input
|
||||||
|
|
||||||
|
rm -rf build
|
Loading…
Reference in New Issue
Block a user