Last active
May 23, 2020 07:57
-
-
Save LeifW/8f99aaca6d63b28f195e to your computer and use it in GitHub Desktop.
A Num instance for Type
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
import Data.Vect | |
%default total | |
Num Type where | |
(+) = Either | |
(*) = Pair | |
fromInteger 0 = Void | |
fromInteger 1 = Unit | |
fromInteger 2 = Bool | |
fromInteger n = Vect (fromInteger n) Unit | |
-- Now you can use arithmetic expressions as type signatures: | |
a : 1 | |
a = () | |
b : 1 * 2 | |
b = ((), True) | |
c : 0 + 2 | |
c = Right False | |
me : String * Int | |
me = ("Leif", 36) | |
three : 3 | |
three = [(), (), ()] |
Author
LeifW
commented
May 23, 2020
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment