... | ... | @@ -89,6 +89,20 @@ work out what `f` is, and thus what code is executed by that `liftA2`. |
|
|
None of this is easy. We prefer `f2` or `f3`. **General rule: use monomorphic functions
|
|
|
if you can**.
|
|
|
|
|
|
Another simpler example. Suppse `f :: t2 -> t3` and `xs :: [(t1,t2)]` Instead of
|
|
|
```
|
|
|
fmap f <$> xs -- Two uses of fmap, in different notation, one
|
|
|
-- of which is over a partial application of (,)
|
|
|
```
|
|
|
write
|
|
|
```
|
|
|
mapSnd f xs
|
|
|
```
|
|
|
where `mapSnd :: (b->c) -> [(a,b)] -> [(a,c)]` is defined in `GHC.Utils.Misc`. Actually, even there `mapSnd` generalises over the list part:
|
|
|
```
|
|
|
mapSnd :: Functor f => (b->c) -> f (a,b) -> f (a,c)
|
|
|
```
|
|
|
|
|
|
### 1.4 INLINE and SPECIALISE pragmas
|
|
|
|
|
|
If inlining or specialisation is important for performance, use pragmas to say so. Consider
|
... | ... | |