diff options
| author | hallgren <hallgren@chalmers.se> | 2012-11-07 15:31:45 +0000 |
|---|---|---|
| committer | hallgren <hallgren@chalmers.se> | 2012-11-07 15:31:45 +0000 |
| commit | 8e6c81fe5a00c605440a5707d2eb686485f24b5a (patch) | |
| tree | 0d535dc0ec5c882a62bcf9821ceec06c1bd7d42c /src/compiler/GF/Data/Utilities.hs | |
| parent | 1dbf575a71491068547614a54cfbb32580dc89a8 (diff) | |
Some changed/new utility functions
GF.Data.Utilities: Rename mapFst to apFst, mapSnd to apSnd.
Add apBoth, mapFst, mapSnd, mapBoth.
GF.Data.Operations: Remove onSnd (same as apSnd)
Diffstat (limited to 'src/compiler/GF/Data/Utilities.hs')
| -rw-r--r-- | src/compiler/GF/Data/Utilities.hs | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/compiler/GF/Data/Utilities.hs b/src/compiler/GF/Data/Utilities.hs index 50269bef1..f953938c8 100644 --- a/src/compiler/GF/Data/Utilities.hs +++ b/src/compiler/GF/Data/Utilities.hs @@ -130,11 +130,20 @@ both f g x y = g (f x) (f y) -- * functions on pairs -mapFst :: (a -> a') -> (a, b) -> (a', b) -mapFst f (a, b) = (f a, b) +apFst :: (a -> a') -> (a, b) -> (a', b) +apFst f (a, b) = (f a, b) -mapSnd :: (b -> b') -> (a, b) -> (a, b') -mapSnd f (a, b) = (a, f b) +apSnd :: (b -> b') -> (a, b) -> (a, b') +apSnd f (a, b) = (a, f b) + +apBoth :: (a -> b) -> (a, a) -> (b, b) +apBoth f (x, y) = (f x, f y) + +-- * functions on lists of pairs + +mapFst = map . apFst +mapSnd = map . apSnd +mapBoth = map . apBoth -- * functions on monads |
