From a16242538462def1a8e0911d48cb9dcf56aa096a Mon Sep 17 00:00:00 2001 From: Edwin Brady Date: Sun, 13 Oct 2019 12:12:49 +0100 Subject: [PATCH] Add curry/uncurry to Prelude --- libs/prelude/Prelude.idr | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libs/prelude/Prelude.idr b/libs/prelude/Prelude.idr index 5c8b571..b9bc141 100644 --- a/libs/prelude/Prelude.idr +++ b/libs/prelude/Prelude.idr @@ -86,6 +86,14 @@ public export apply : (a -> b) -> a -> b apply f a = f a +public export +curry : ((a, b) -> c) -> a -> b -> c +curry f a b = f (a, b) + +public export +uncurry : (a -> b -> c) -> (a, b) -> c +uncurry f (a, b) = f a b + -- $ is compiled specially to shortcut any tricky unification issues, but if -- it did have a type this is what it would be, and it might be useful to -- use directly sometimes (e.g. in higher order functions)