Idris2/tests/idris2/linear/linear002/Stuff.idr
André Videla 75032a7164
Emit warning for fixities with no export modifiers (#3234)
* Emit warning for fixities with no export modifiers

This is to help update all the existing code to program with explicit
fixity export directives in preparation for the behavioral change where
they will become private by default.
2024-04-03 15:41:57 +01:00

65 lines
1.2 KiB
Idris

-- a mini prelude
module Stuff
public export
data Bool = True | False
public export
not : Bool -> Bool
not True = False
not False = True
public export
data Maybe : Type -> Type where
Nothing : Maybe a
Just : (1 x : a) -> Maybe a
public export
data Either : Type -> Type -> Type where
Left : (1 x : a) -> Either a b
Right : (1 y : b) -> Either a b
public export
intToBool : Int -> Bool
intToBool 0 = False
intToBool x = True
public export
ifThenElse : Bool -> Lazy a -> Lazy a -> a
ifThenElse True t e = t
ifThenElse False t e = e
public export
data Nat = Z | S Nat
public export
fromInteger : Integer -> Nat
fromInteger x = ifThenElse (intToBool (prim__eq_Integer x 0))
Z (S (fromInteger (prim__sub_Integer x 1)))
public export
plus : Nat -> Nat -> Nat
plus Z y = y
plus (S k) y = S (plus k y)
export infixr 5 ::
public export
data List a = Nil | (::) a (List a)
public export
data Eq : a -> b -> Type where
Refl : (x : a) -> Eq x x
public export
data Unit = MkUnit
public export
data Pair : Type -> Type -> Type where
MkPair : {a, b : Type} -> a -> b -> Pair a b
public export
the : (a : Type) -> a -> a
the _ x = x