2023-10-18 14:06:36 +03:00
|
|
|
|
2023-10-24 19:11:27 +03:00
|
|
|
module Test
|
2023-10-21 16:28:17 +03:00
|
|
|
|
2023-10-21 23:00:12 +03:00
|
|
|
import Data.Vect
|
|
|
|
|
2024-04-03 17:41:57 +03:00
|
|
|
private typebind infixr 0 =@
|
|
|
|
private infixr 0 -@
|
2023-10-18 14:06:36 +03:00
|
|
|
|
2024-06-06 12:59:30 +03:00
|
|
|
%hide Prelude.Ops.infixl.(|>)
|
|
|
|
|
2023-12-12 18:23:50 +03:00
|
|
|
-- typebind infixr 1 =@@
|
2023-10-24 19:11:27 +03:00
|
|
|
|
2023-10-18 15:04:42 +03:00
|
|
|
0 (=@) : (a : Type) -> (a -> Type) -> Type
|
2023-10-18 14:06:36 +03:00
|
|
|
(=@) a f = (1 x : a) -> f x
|
|
|
|
|
2023-10-24 19:11:27 +03:00
|
|
|
0 (=@@) : (a : Type) -> (a -> Type) -> Type
|
|
|
|
(=@@) a f = (1 x : a) -> f x
|
|
|
|
|
2023-10-22 15:42:13 +03:00
|
|
|
(-@) : (a, b : Type) -> Type
|
|
|
|
(-@) a b = (1 _ : a) -> b
|
2023-10-21 16:28:17 +03:00
|
|
|
|
|
|
|
data S : {ty : Type} -> (x : ty) -> Type where
|
|
|
|
MkS : (x : ty) =@ S x
|
2023-10-22 15:42:13 +03:00
|
|
|
Mk2 : (x : ty) =@ (y : ty) =@ S (x, y)
|
|
|
|
Mk3 : (x : ty) =@ ty -@ S x
|
|
|
|
Mk4 : ty -@ (x : ty) =@ S x
|
2023-10-24 19:11:27 +03:00
|
|
|
|
2023-12-12 18:23:50 +03:00
|
|
|
-- map : (x : a) =@@ b -@ (y : List a) =@ List b
|
2023-10-24 19:11:27 +03:00
|
|
|
|
|
|
|
map2 : ((x : a) =@ b) -@ (y : List a) =@ List b
|
|
|
|
|
|
|
|
map3 : (x : a) =@ b -@ (y : List a) =@ List b
|
|
|
|
|
|
|
|
map4 : (x : a) =@ (b -@ (y : List a) =@ List b)
|
|
|
|
|
2024-01-23 13:39:44 +03:00
|
|
|
-- this could be possible if we allowed binding operators
|
2023-12-12 18:23:50 +03:00
|
|
|
-- with higher precedences
|
|
|
|
-- test : Test.map === Test.map2
|
|
|
|
-- failing
|
|
|
|
-- test2 : Test.map === Test.map3
|
2023-10-24 19:11:27 +03:00
|
|
|
|
|
|
|
test3 : Test.map3 === Test.map4
|
2023-10-21 16:28:17 +03:00
|
|
|
|
2024-04-03 17:41:57 +03:00
|
|
|
private typebind infixr 0 *>
|
2023-10-21 23:00:12 +03:00
|
|
|
|
|
|
|
-- (*>) : (ty : Type) -> (ty -> Type) -> Type
|
|
|
|
-- (*>) = DPair
|
|
|
|
--
|
|
|
|
-- testCompose : (x : Nat) *> (y : Nat) *> Vect (n + m) String
|
|
|
|
-- testCompose = (1 ** 2 ** ["hello", "world", "!"])
|
|
|
|
|
2024-04-03 17:41:57 +03:00
|
|
|
private autobind infixr 0 `MyLet`
|
2023-10-21 23:00:12 +03:00
|
|
|
|
|
|
|
MyLet : (val) -> (val -> rest) -> rest
|
|
|
|
MyLet arg fn = fn arg
|
|
|
|
|
|
|
|
program : Nat
|
|
|
|
program = (n := 3) `MyLet` 2 + n
|
2023-10-21 16:28:17 +03:00
|
|
|
|
2023-10-21 23:00:12 +03:00
|
|
|
program2 : Nat
|
|
|
|
program2 = (n : Nat := 3) `MyLet` 2 + n
|
2023-11-11 22:15:47 +03:00
|
|
|
|
2024-04-03 17:41:57 +03:00
|
|
|
private typebind infixr 0 |>
|
2023-11-11 22:15:47 +03:00
|
|
|
|
|
|
|
record Container where
|
|
|
|
constructor (|>)
|
|
|
|
shape : Type
|
|
|
|
position : shape -> Type
|
|
|
|
|
2024-04-03 17:41:57 +03:00
|
|
|
private typebind infixr 0 @@
|
2023-11-11 22:15:47 +03:00
|
|
|
|
|
|
|
record (@@) (x : Type) (y : x -> Type) where
|
|
|
|
constructor PairUp
|
|
|
|
fst : x
|
|
|
|
snd : y fst
|
|
|
|
|
|
|
|
compose : Container -> Container -> Container
|
|
|
|
compose (a |> a') (b |> b') =
|
2023-11-12 03:43:14 +03:00
|
|
|
(x : (y : a) @@ (a' y -> b)) |>
|
2023-11-11 22:15:47 +03:00
|
|
|
(y : a' x.fst) @@
|
|
|
|
b' (x.snd y)
|