Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

playing around with basic booleans and natural numbers #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash

ide:setup() {
brew:install:brew:itself
brew tap caskroom/cask
brew cask install minikube
brew install idris

minikube start
eval $(minikube docker-env)

docker run -d -v /tmp/.X11-unix/:/tmp/.X11-unix/ \
-v /dev/shm:/dev/shm \
-v ${HOME}/.atom:/home/atom/.atom \
-e DISPLAY \
jamesnetherton/docker-atom-editor
}

brew:install:brew:itself() {
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
}
3 changes: 3 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Clone this repository, then, on Mac OSX, run:

./ci.sh
Binary file added test.ibc
Binary file not shown.
43 changes: 43 additions & 0 deletions test.idr
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
module Tommy

data Boolean = True | False

BB : Type
BB = Boolean -> Boolean

not : Boolean -> Boolean
not True = False
not False = True

BBB : Type
BBB = Boolean -> BB

or : BBB
or False False = False
or _ _ = True

-- mike to check out laziness and how it might relate to some of these definitions
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was Idris' own && and || implementations I was looking at earlier https://github.com/idris-lang/Idris-dev/blob/master/libs/prelude/Prelude/Bool.idr


and:BBB
and True True = True
and _ _ = False

xor:BBB
xor True False = True
xor False True = True
xor _ _ = False

-- natural numbers

data Natural = Zero | Successor Natural

naturalFromInteger : Integer -> Natural
naturalFromInteger 0 = Zero
naturalFromInteger n = Successor (naturalFromInteger (n - 1))

integerFromNatural : Natural -> Integer
integerFromNatural Zero = 0
integerFromNatural (Successor n) = 1 + integerFromNatural n

Show Natural where
show n = show (integerFromNatural n)