]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Functions mapFst and mapSnd 63/1263/1
authorHannu Niemistö <hannu.niemisto@semantum.fi>
Fri, 24 Nov 2017 12:00:50 +0000 (14:00 +0200)
committerHannu Niemistö <hannu.niemisto@semantum.fi>
Fri, 24 Nov 2017 12:00:50 +0000 (14:00 +0200)
refs #7644

Change-Id: Id95dca0a0d48d864c745e65b597fe91a9c92bb83

bundles/org.simantics.scl.runtime/scl/Prelude.scl

index c04cc8625aa0be2bceb1ab372f8f9fe5a7eca5c4..a926ae40ec3b0ca4ffb4c635132c3fa9eaa58f9e 100644 (file)
@@ -1484,6 +1484,14 @@ fst (x,y) = x
 snd :: (a,b) -> b
 snd (x,y) = y
 
 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
 
 instance (Ord a, Ord b) => Ord (a, b) where
     compare (a0, b0) (a1, b1) = compare a0 a1 &<& compare b0 b1