From: Hannu Niemistö Date: Fri, 24 Nov 2017 12:00:50 +0000 (+0200) Subject: Functions mapFst and mapSnd X-Git-Tag: v1.31.0~19 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=88d2a4a6eb85beaf007ef544e7be8c9b901b1974;p=simantics%2Fplatform.git Functions mapFst and mapSnd refs #7644 Change-Id: Id95dca0a0d48d864c745e65b597fe91a9c92bb83 --- diff --git a/bundles/org.simantics.scl.runtime/scl/Prelude.scl b/bundles/org.simantics.scl.runtime/scl/Prelude.scl index c04cc8625..a926ae40e 100644 --- a/bundles/org.simantics.scl.runtime/scl/Prelude.scl +++ b/bundles/org.simantics.scl.runtime/scl/Prelude.scl @@ -1484,6 +1484,14 @@ fst (x,y) = x snd :: (a,b) -> b snd (x,y) = y +@inline +mapFst :: (a -> b) -> (a,c) -> (b,c) +mapFst f (x,y) = (f x, y) + +@inline +mapSnd :: (a -> b) -> (c,a) -> (c,b) +mapSnd f (x,y) = (x, f y) + instance (Ord a, Ord b) => Ord (a, b) where compare (a0, b0) (a1, b1) = compare a0 a1 &<& compare b0 b1