| Copyright | (C) 2025 Alexey Tochin |
|---|---|
| License | BSD3 (see the file LICENSE) |
| Maintainer | Alexey Tochin <Alexey.Tochin@gmail.com> |
| Safe Haskell | None |
| Language | Haskell2010 |
Control.ExtendableMap
Description
ExtandableMap class and its instances.
Synopsis
- class ExtandableMap a b c d where
- extendMap :: (a -> b) -> c -> d
Documentation
class ExtandableMap a b c d where Source #
Type is similar to fmap, but it can extend the function application.
It can apply a function to each element and subelements
of a tuple, list, sized vector, stream, etc.
Examples
>>>import GHC.Base (Bool(True, False), Int)>>>import GHC.Show (show)>>>import GHC.Num ((*))>>>import Data.String (String)
>>>extendMap (show :: Int -> String) (42 :: Int) :: String"42"
>>>extendMap (show :: Bool -> String) (True, False) :: (String, String)("True","False")
>>>extendMap ((*2) :: Int -> Int) (1 :: Int, (2 :: Int, 3 :: Int)) :: (Int, (Int, Int))(2,(4,6))
>>>extendMap ((*2) :: Int -> Int) ([1, 2, 3] :: [Int], (4 :: Int, 5 :: Int)) :: ([Int], (Int, Int))([2,4,6],(8,10))