Skip to content

Commit

Permalink
New curry and uncurry functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
newhoggy committed Dec 10, 2024
1 parent 470b0a0 commit 5615e1d
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
1 change: 1 addition & 0 deletions hw-prelude.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,6 @@ library
HaskellWorks.Stack
HaskellWorks.String
HaskellWorks.ToText
HaskellWorks.Tuple
HaskellWorks.Unsafe
hs-source-dirs: src
58 changes: 58 additions & 0 deletions src/HaskellWorks/Tuple.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
module HaskellWorks.Tuple
( uncurry3,
uncurry4,
uncurry5,
uncurry6,
uncurry7,
uncurry8,
uncurry9,
curry3,
curry4,
curry5,
curry6,
curry7,
curry8,
curry9
) where

uncurry3 :: (a -> b -> c -> z) -> (a, b, c) -> z
uncurry3 fun (a, b, c) = fun a b c

uncurry4 :: (a -> b -> c -> d -> z) -> (a, b, c, d) -> z
uncurry4 fun (a, b, c, d) = fun a b c d

uncurry5 :: (a -> b -> c -> d -> e -> z) -> (a, b, c, d, e) -> z
uncurry5 fun (a, b, c, d, e) = fun a b c d e

uncurry6 :: (a -> b -> c -> d -> e -> f -> z) -> (a, b, c, d, e, f) -> z
uncurry6 fun (a, b, c, d, e, f) = fun a b c d e f

uncurry7 :: (a -> b -> c -> d -> e -> f -> g -> z) -> (a, b, c, d, e, f, g) -> z
uncurry7 fun (a, b, c, d, e, f, g) = fun a b c d e f g

uncurry8 :: (a -> b -> c -> d -> e -> f -> g -> h -> z) -> (a, b, c, d, e, f, g, h) -> z
uncurry8 fun (a, b, c, d, e, f, g, h) = fun a b c d e f g h

uncurry9 :: (a -> b -> c -> d -> e -> f -> g -> h -> i -> z) -> (a, b, c, d, e, f, g, h, i) -> z
uncurry9 fun (a, b, c, d, e, f, g, h, i) = fun a b c d e f g h i

curry3 :: ((a, b, c) -> z) -> a -> b -> c -> z
curry3 fun a b c = fun (a, b, c)

curry4 :: ((a, b, c, d) -> z) -> a -> b -> c -> d -> z
curry4 fun a b c d = fun (a, b, c, d)

curry5 :: ((a, b, c, d, e) -> z) -> a -> b -> c -> d -> e -> z
curry5 fun a b c d e = fun (a, b, c, d, e)

curry6 :: ((a, b, c, d, e, f) -> z) -> a -> b -> c -> d -> e -> f -> z
curry6 fun a b c d e f = fun (a, b, c, d, e, f)

curry7 :: ((a, b, c, d, e, f, g) -> z) -> a -> b -> c -> d -> e -> f -> g -> z
curry7 fun a b c d e f g = fun (a, b, c, d, e, f, g)

curry8 :: ((a, b, c, d, e, f, g, h) -> z) -> a -> b -> c -> d -> e -> f -> g -> h -> z
curry8 fun a b c d e f g h = fun (a, b, c, d, e, f, g, h)

curry9 :: ((a, b, c, d, e, f, g, h, i) -> z) -> a -> b -> c -> d -> e -> f -> g -> h -> i -> z
curry9 fun a b c d e f g h i = fun (a, b, c, d, e, f, g, h, i)

0 comments on commit 5615e1d

Please sign in to comment.