forked from idris-lang/Idris2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request idris-lang#66 from abailly/no-prelude
check noprelude option when starting up without loading a file
- Loading branch information
Showing
6 changed files
with
84 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
unset IDRIS2_PATH | ||
|
||
$1 --no-prelude < input | ||
|
||
rm -rf build |