| Copyright | (C) 2012-2016 University of Twente |
|---|---|
| License | BSD2 (see the file LICENSE) |
| Maintainer | Christiaan Baaij <christiaan.baaij@gmail.com> |
| Safe Haskell | None |
| Language | Haskell2010 |
Clash.Util
Description
Assortment of utility function used in the Clash library
Synopsis
- class MonadUnique m where
- curLoc :: Q Exp
- makeCached :: (MonadState s m, Hashable k, Eq k) => k -> Lens' s (HashMap k v) -> m v -> m v
- makeCachedT3 :: (MonadTrans t2, MonadTrans t1, MonadTrans t, Eq k, Hashable k, MonadState s m, Monad (t2 m), Monad (t1 (t2 m)), Monad (t (t1 (t2 m)))) => k -> Lens' s (HashMap k v) -> t (t1 (t2 m)) v -> t (t1 (t2 m)) v
- makeCachedT3S :: (MonadTrans t2, MonadTrans t1, MonadTrans t, Eq k, Hashable k, MonadState s m, Monad (t2 m), Monad (t1 (t2 m)), Monad (t (t1 (t2 m))), NFData v) => k -> Lens' s (HashMap k v) -> t (t1 (t2 m)) v -> t (t1 (t2 m)) v
- liftState :: MonadState s m => Lens' s s' -> State s' a -> m a
- firstM :: Functor f => (a -> f c) -> (a, b) -> f (c, b)
- secondM :: Functor f => (b -> f c) -> (a, b) -> f (a, c)
- combineM :: Applicative f => (a -> f b) -> (c -> f d) -> (a, c) -> f (b, d)
- traceIf :: Bool -> String -> a -> a
- partitionM :: Monad m => (a -> m Bool) -> [a] -> m ([a], [a])
- mapAccumLM :: Monad m => (acc -> x -> m (acc, y)) -> acc -> [x] -> m (acc, [y])
- dot :: (c -> d) -> (a -> b -> c) -> a -> b -> d
- ifThenElse :: (a -> Bool) -> (a -> b) -> (a -> b) -> a -> b
- (<:>) :: Applicative f => f a -> f [a] -> f [a]
- indexMaybe :: [a] -> Int -> Maybe a
- indexNote :: String -> [a] -> Int -> a
- splitAtList :: [b] -> [a] -> ([a], [a])
- clashLibVersion :: Version
- flogBase :: Integer -> Integer -> Maybe Int
- clogBase :: Integer -> Integer -> Maybe Int
- class Functor f => Applicative (f :: * -> *) where
- (<$>) :: Functor f => (a -> b) -> f a -> f b
- (<=<) :: Monad m => (b -> m c) -> (a -> m b) -> a -> m c
- (>=>) :: Monad m => (a -> m b) -> (b -> m c) -> a -> m c
- first :: Arrow a => a b c -> a (b, d) (c, d)
- second :: Arrow a => a b c -> a (d, b) (d, c)
- (***) :: Arrow a => a b c -> a b' c' -> a (b, b') (c, c')
- on :: (b -> b -> c) -> (a -> b) -> a -> a -> c
- makeLenses :: Name -> DecsQ
Documentation
class MonadUnique m where Source #
A class that can generate unique numbers
Minimal complete definition
Instances
| MonadUnique (RewriteMonad extra) Source # | |
Methods getUniqueM :: RewriteMonad extra Int Source # | |
| Monad m => MonadUnique (StateT Int m) Source # | |
Create a TH expression that returns the a formatted string containing the
name of the module curLoc is spliced into, and the line where it was spliced.
Arguments
| :: (MonadState s m, Hashable k, Eq k) | |
| => k | The key the action is associated with |
| -> Lens' s (HashMap k v) | The Lens to the HashMap that is the cache |
| -> m v | The action to cache |
| -> m v |
Cache the result of a monadic action
Arguments
| :: (MonadTrans t2, MonadTrans t1, MonadTrans t, Eq k, Hashable k, MonadState s m, Monad (t2 m), Monad (t1 (t2 m)), Monad (t (t1 (t2 m)))) | |
| => k | The key the action is associated with |
| -> Lens' s (HashMap k v) | The Lens to the HashMap that is the cache |
| -> t (t1 (t2 m)) v | The action to cache |
| -> t (t1 (t2 m)) v |
Cache the result of a monadic action in a State 3 transformer layers down
makeCachedT3S :: (MonadTrans t2, MonadTrans t1, MonadTrans t, Eq k, Hashable k, MonadState s m, Monad (t2 m), Monad (t1 (t2 m)), Monad (t (t1 (t2 m))), NFData v) => k -> Lens' s (HashMap k v) -> t (t1 (t2 m)) v -> t (t1 (t2 m)) v Source #
Spine-strict cache variant of mkCachedT3
Arguments
| :: MonadState s m | |
| => Lens' s s' | Lens to the State in the higher-layer monad |
| -> State s' a | The State-action to perform |
| -> m a |
Run a State-action using the State that is stored in a higher-layer Monad
combineM :: Applicative f => (a -> f b) -> (c -> f d) -> (a, c) -> f (b, d) Source #
mapAccumLM :: Monad m => (acc -> x -> m (acc, y)) -> acc -> [x] -> m (acc, [y]) Source #
Monadic version of mapAccumL
dot :: (c -> d) -> (a -> b -> c) -> a -> b -> d Source #
Composition of a unary function with a binary function
ifThenElse :: (a -> Bool) -> (a -> b) -> (a -> b) -> a -> b Source #
if-then-else as a function on an argument
(<:>) :: Applicative f => f a -> f [a] -> f [a] infixr 5 Source #
Applicative version of 'GHC.Types.(:)'
indexMaybe :: [a] -> Int -> Maybe a Source #
Safe indexing, returns a Nothing if the index does not exist
indexNote :: String -> [a] -> Int -> a Source #
Unsafe indexing, return a custom error message when indexing fails
splitAtList :: [b] -> [a] -> ([a], [a]) Source #
Split the second list at the length of the first list
class Functor f => Applicative (f :: * -> *) where #
A functor with application, providing operations to
A minimal complete definition must include implementations of pure
and of either <*> or liftA2. If it defines both, then they must behave
the same as their default definitions:
(<*>) =liftA2id
liftA2f x y = f<$>x<*>y
Further, any definition must satisfy the following:
- identity
pureid<*>v = v- composition
pure(.)<*>u<*>v<*>w = u<*>(v<*>w)- homomorphism
puref<*>purex =pure(f x)- interchange
u
<*>purey =pure($y)<*>u
The other methods have the following default definitions, which may be overridden with equivalent specialized implementations:
As a consequence of these laws, the Functor instance for f will satisfy
It may be useful to note that supposing
forall x y. p (q x y) = f x . g y
it follows from the above that
liftA2p (liftA2q u v) =liftA2f u .liftA2g v
If f is also a Monad, it should satisfy
(which implies that pure and <*> satisfy the applicative functor laws).
Methods
Lift a value.
(<*>) :: f (a -> b) -> f a -> f b infixl 4 #
Sequential application.
A few functors support an implementation of <*> that is more
efficient than the default one.
Instances
| Applicative [] | Since: 2.1 |
| Applicative Maybe | Since: 2.1 |
| Applicative IO | Since: 2.1 |
| Applicative Par1 | Since: 4.9.0.0 |
| Applicative Q | |
| Applicative IResult | |
| Applicative Result | |
| Applicative Parser | |
| Applicative Complex | Since: 4.9.0.0 |
| Applicative Min | Since: 4.9.0.0 |
| Applicative Max | Since: 4.9.0.0 |
| Applicative First | Since: 4.9.0.0 |
| Applicative Last | Since: 4.9.0.0 |
| Applicative Option | Since: 4.9.0.0 |
| Applicative ZipList | f '<$>' 'ZipList' xs1 '<*>' ... '<*>' 'ZipList' xsN
= 'ZipList' (zipWithN f xs1 ... xsN)where (\a b c -> stimes c [a, b]) <$> ZipList "abcd" <*> ZipList "567" <*> ZipList [1..]
= ZipList (zipWith3 (\a b c -> stimes c [a, b]) "abcd" "567" [1..])
= ZipList {getZipList = ["a5","b6b6","c7c7c7"]}Since: 2.1 |
| Applicative Identity | Since: 4.8.0.0 |
| Applicative STM | Since: 4.8.0.0 |
| Applicative First | |
| Applicative Last | |
| Applicative Dual | Since: 4.8.0.0 |
| Applicative Sum | Since: 4.8.0.0 |
| Applicative Product | Since: 4.8.0.0 |
| Applicative Down | Since: 4.11.0.0 |
| Applicative ReadPrec | Since: 4.6.0.0 |
| Applicative ReadP | Since: 4.6.0.0 |
| Applicative NonEmpty | Since: 4.9.0.0 |
| Applicative Put | |
| Applicative Tree | |
| Applicative Seq | Since: 0.5.4 |
| Applicative DList | |
| Applicative Vector | |
| Applicative SmallArray | |
Methods pure :: a -> SmallArray a # (<*>) :: SmallArray (a -> b) -> SmallArray a -> SmallArray b # liftA2 :: (a -> b -> c) -> SmallArray a -> SmallArray b -> SmallArray c # (*>) :: SmallArray a -> SmallArray b -> SmallArray b # (<*) :: SmallArray a -> SmallArray b -> SmallArray a # | |
| Applicative Array | |
| Applicative Parser | |
| Applicative Result | |
| Applicative Id | |
| Applicative Box | |
| Applicative P | Since: 4.5.0.0 |
| Applicative NetlistMonad # | |
Methods pure :: a -> NetlistMonad a # (<*>) :: NetlistMonad (a -> b) -> NetlistMonad a -> NetlistMonad b # liftA2 :: (a -> b -> c) -> NetlistMonad a -> NetlistMonad b -> NetlistMonad c # (*>) :: NetlistMonad a -> NetlistMonad b -> NetlistMonad b # (<*) :: NetlistMonad a -> NetlistMonad b -> NetlistMonad a # | |
| Applicative (Either e) | Since: 3.0 |
| Applicative (U1 :: * -> *) | Since: 4.9.0.0 |
| Monoid a => Applicative ((,) a) | For tuples, the ("hello ", (+15)) <*> ("world!", 2002)
("hello world!",2017)Since: 2.1 |
| Applicative (ST s) | Since: 4.4.0.0 |
| Representable f => Applicative (Co f) | |
| Applicative (Parser i) | |
| Monad m => Applicative (WrappedMonad m) | Since: 2.1 |
Methods pure :: a -> WrappedMonad m a # (<*>) :: WrappedMonad m (a -> b) -> WrappedMonad m a -> WrappedMonad m b # liftA2 :: (a -> b -> c) -> WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m c # (*>) :: WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m b # (<*) :: WrappedMonad m a -> WrappedMonad m b -> WrappedMonad m a # | |
| Arrow a => Applicative (ArrowMonad a) | Since: 4.6.0.0 |
Methods pure :: a0 -> ArrowMonad a a0 # (<*>) :: ArrowMonad a (a0 -> b) -> ArrowMonad a a0 -> ArrowMonad a b # liftA2 :: (a0 -> b -> c) -> ArrowMonad a a0 -> ArrowMonad a b -> ArrowMonad a c # (*>) :: ArrowMonad a a0 -> ArrowMonad a b -> ArrowMonad a b # (<*) :: ArrowMonad a a0 -> ArrowMonad a b -> ArrowMonad a a0 # | |
| Applicative (Proxy :: * -> *) | Since: 4.7.0.0 |
| Applicative (Signal domain) | |
Methods pure :: a -> Signal domain a # (<*>) :: Signal domain (a -> b) -> Signal domain a -> Signal domain b # liftA2 :: (a -> b -> c) -> Signal domain a -> Signal domain b -> Signal domain c # (*>) :: Signal domain a -> Signal domain b -> Signal domain b # (<*) :: Signal domain a -> Signal domain b -> Signal domain a # | |
| (Functor m, Monad m) => Applicative (MaybeT m) | |
| Alternative f => Applicative (Cofree f) | |
| Functor f => Applicative (Free f) | |
| Applicative f => Applicative (Yoneda f) | |
| Applicative (ReifiedGetter s) | |
Methods pure :: a -> ReifiedGetter s a # (<*>) :: ReifiedGetter s (a -> b) -> ReifiedGetter s a -> ReifiedGetter s b # liftA2 :: (a -> b -> c) -> ReifiedGetter s a -> ReifiedGetter s b -> ReifiedGetter s c # (*>) :: ReifiedGetter s a -> ReifiedGetter s b -> ReifiedGetter s b # (<*) :: ReifiedGetter s a -> ReifiedGetter s b -> ReifiedGetter s a # | |
| Applicative (ReifiedFold s) | |
Methods pure :: a -> ReifiedFold s a # (<*>) :: ReifiedFold s (a -> b) -> ReifiedFold s a -> ReifiedFold s b # liftA2 :: (a -> b -> c) -> ReifiedFold s a -> ReifiedFold s b -> ReifiedFold s c # (*>) :: ReifiedFold s a -> ReifiedFold s b -> ReifiedFold s b # (<*) :: ReifiedFold s a -> ReifiedFold s b -> ReifiedFold s a # | |
| Applicative f => Applicative (Indexing f) | |
| Applicative f => Applicative (Indexing64 f) | |
Methods pure :: a -> Indexing64 f a # (<*>) :: Indexing64 f (a -> b) -> Indexing64 f a -> Indexing64 f b # liftA2 :: (a -> b -> c) -> Indexing64 f a -> Indexing64 f b -> Indexing64 f c # (*>) :: Indexing64 f a -> Indexing64 f b -> Indexing64 f b # (<*) :: Indexing64 f a -> Indexing64 f b -> Indexing64 f a # | |
| Applicative m => Applicative (ListT m) | |
| Applicative m => Applicative (Unhighlighted m) | |
Methods pure :: a -> Unhighlighted m a # (<*>) :: Unhighlighted m (a -> b) -> Unhighlighted m a -> Unhighlighted m b # liftA2 :: (a -> b -> c) -> Unhighlighted m a -> Unhighlighted m b -> Unhighlighted m c # (*>) :: Unhighlighted m a -> Unhighlighted m b -> Unhighlighted m b # (<*) :: Unhighlighted m a -> Unhighlighted m b -> Unhighlighted m a # | |
| Applicative m => Applicative (Unspaced m) | |
| Applicative m => Applicative (Unlined m) | |
| (Applicative (Rep p), Representable p) => Applicative (Prep p) | |
| Applicative f => Applicative (Mon f) | |
| Applicative (It r) | |
| Applicative (FFM f) | |
| Monad m => Applicative (FreshMT m) | |
| Applicative m => Applicative (LFreshMT m) | |
| Applicative (SetM s) | |
| Applicative (RewriteMonad extra) # | |
Methods pure :: a -> RewriteMonad extra a # (<*>) :: RewriteMonad extra (a -> b) -> RewriteMonad extra a -> RewriteMonad extra b # liftA2 :: (a -> b -> c) -> RewriteMonad extra a -> RewriteMonad extra b -> RewriteMonad extra c # (*>) :: RewriteMonad extra a -> RewriteMonad extra b -> RewriteMonad extra b # (<*) :: RewriteMonad extra a -> RewriteMonad extra b -> RewriteMonad extra a # | |
| Applicative f => Applicative (Rec1 f) | Since: 4.9.0.0 |
| Arrow a => Applicative (WrappedArrow a b) | Since: 2.1 |
Methods pure :: a0 -> WrappedArrow a b a0 # (<*>) :: WrappedArrow a b (a0 -> b0) -> WrappedArrow a b a0 -> WrappedArrow a b b0 # liftA2 :: (a0 -> b0 -> c) -> WrappedArrow a b a0 -> WrappedArrow a b b0 -> WrappedArrow a b c # (*>) :: WrappedArrow a b a0 -> WrappedArrow a b b0 -> WrappedArrow a b b0 # (<*) :: WrappedArrow a b a0 -> WrappedArrow a b b0 -> WrappedArrow a b a0 # | |
| Monoid m => Applicative (Const m :: * -> *) | Since: 2.0.1 |
| Applicative f => Applicative (Alt f) | |
| Biapplicative p => Applicative (Join p) | |
| Biapplicative p => Applicative (Fix p) | |
| Applicative m => Applicative (IdentityT m) | |
| (Applicative f, Monad f) => Applicative (WhenMissing f x) | Equivalent to Since: 0.5.9 |
Methods pure :: a -> WhenMissing f x a # (<*>) :: WhenMissing f x (a -> b) -> WhenMissing f x a -> WhenMissing f x b # liftA2 :: (a -> b -> c) -> WhenMissing f x a -> WhenMissing f x b -> WhenMissing f x c # (*>) :: WhenMissing f x a -> WhenMissing f x b -> WhenMissing f x b # (<*) :: WhenMissing f x a -> WhenMissing f x b -> WhenMissing f x a # | |
| (Functor m, Monad m) => Applicative (ExceptT e m) | |
| (Functor f, Monad m) => Applicative (FreeT f m) | |
| (Alternative f, Applicative w) => Applicative (CofreeT f w) | |
| (Applicative f, Applicative g) => Applicative (Day f g) | |
| (Functor m, Monad m) => Applicative (ErrorT e m) | |
| Applicative f => Applicative (Backwards f) | Apply |
| Applicative (Mafic a b) | |
| Applicative (Flows i b) | This is an illegal |
| Applicative (Indexed i a) | |
| (Functor m, Monad m) => Applicative (StateT s m) | |
| (Functor m, Monad m) => Applicative (StateT s m) | |
| (Monoid w, Applicative m) => Applicative (WriterT w m) | |
| (Monoid w, Applicative m) => Applicative (WriterT w m) | |
| (Profunctor p, Arrow p) => Applicative (Tambara p a) | |
| Applicative (Tagged s) | |
| Applicative f => Applicative (Reverse f) | Derived instance. |
| Monoid a => Applicative (Constant a :: * -> *) | |
| Monoid m => Applicative (Holes t m) | |
| Applicative ((->) a :: * -> *) | Since: 2.1 |
| (Applicative f, Applicative g) => Applicative (f :*: g) | Since: 4.9.0.0 |
| (Applicative f, Applicative g) => Applicative (Product f g) | Since: 4.9.0.0 |
| (Monad f, Applicative f) => Applicative (WhenMatched f x y) | Equivalent to Since: 0.5.9 |
Methods pure :: a -> WhenMatched f x y a # (<*>) :: WhenMatched f x y (a -> b) -> WhenMatched f x y a -> WhenMatched f x y b # liftA2 :: (a -> b -> c) -> WhenMatched f x y a -> WhenMatched f x y b -> WhenMatched f x y c # (*>) :: WhenMatched f x y a -> WhenMatched f x y b -> WhenMatched f x y b # (<*) :: WhenMatched f x y a -> WhenMatched f x y b -> WhenMatched f x y a # | |
| (Applicative f, Monad f) => Applicative (WhenMissing f k x) | Equivalent to Since: 0.5.9 |
Methods pure :: a -> WhenMissing f k x a # (<*>) :: WhenMissing f k x (a -> b) -> WhenMissing f k x a -> WhenMissing f k x b # liftA2 :: (a -> b -> c) -> WhenMissing f k x a -> WhenMissing f k x b -> WhenMissing f k x c # (*>) :: WhenMissing f k x a -> WhenMissing f k x b -> WhenMissing f k x b # (<*) :: WhenMissing f k x a -> WhenMissing f k x b -> WhenMissing f k x a # | |
| Applicative (Molten i a b) | |
Methods pure :: a0 -> Molten i a b a0 # (<*>) :: Molten i a b (a0 -> b0) -> Molten i a b a0 -> Molten i a b b0 # liftA2 :: (a0 -> b0 -> c) -> Molten i a b a0 -> Molten i a b b0 -> Molten i a b c # (*>) :: Molten i a b a0 -> Molten i a b b0 -> Molten i a b b0 # (<*) :: Molten i a b a0 -> Molten i a b b0 -> Molten i a b a0 # | |
| Applicative (Bazaar p a b) | |
Methods pure :: a0 -> Bazaar p a b a0 # (<*>) :: Bazaar p a b (a0 -> b0) -> Bazaar p a b a0 -> Bazaar p a b b0 # liftA2 :: (a0 -> b0 -> c) -> Bazaar p a b a0 -> Bazaar p a b b0 -> Bazaar p a b c # (*>) :: Bazaar p a b a0 -> Bazaar p a b b0 -> Bazaar p a b b0 # (<*) :: Bazaar p a b a0 -> Bazaar p a b b0 -> Bazaar p a b a0 # | |
| Applicative (ContT r m) | |
| Applicative m => Applicative (ReaderT r m) | |
| Applicative (ParsecT s u m) | |
Methods pure :: a -> ParsecT s u m a # (<*>) :: ParsecT s u m (a -> b) -> ParsecT s u m a -> ParsecT s u m b # liftA2 :: (a -> b -> c) -> ParsecT s u m a -> ParsecT s u m b -> ParsecT s u m c # (*>) :: ParsecT s u m a -> ParsecT s u m b -> ParsecT s u m b # (<*) :: ParsecT s u m a -> ParsecT s u m b -> ParsecT s u m a # | |
| Applicative f => Applicative (M1 i c f) | Since: 4.9.0.0 |
| (Applicative f, Applicative g) => Applicative (f :.: g) | Since: 4.9.0.0 |
| (Applicative f, Applicative g) => Applicative (Compose f g) | Since: 4.9.0.0 |
| (Monad f, Applicative f) => Applicative (WhenMatched f k x y) | Equivalent to Since: 0.5.9 |
Methods pure :: a -> WhenMatched f k x y a # (<*>) :: WhenMatched f k x y (a -> b) -> WhenMatched f k x y a -> WhenMatched f k x y b # liftA2 :: (a -> b -> c) -> WhenMatched f k x y a -> WhenMatched f k x y b -> WhenMatched f k x y c # (*>) :: WhenMatched f k x y a -> WhenMatched f k x y b -> WhenMatched f k x y b # (<*) :: WhenMatched f k x y a -> WhenMatched f k x y b -> WhenMatched f k x y a # | |
| Applicative (TakingWhile p f a b) | |
Methods pure :: a0 -> TakingWhile p f a b a0 # (<*>) :: TakingWhile p f a b (a0 -> b0) -> TakingWhile p f a b a0 -> TakingWhile p f a b b0 # liftA2 :: (a0 -> b0 -> c) -> TakingWhile p f a b a0 -> TakingWhile p f a b b0 -> TakingWhile p f a b c # (*>) :: TakingWhile p f a b a0 -> TakingWhile p f a b b0 -> TakingWhile p f a b b0 # (<*) :: TakingWhile p f a b a0 -> TakingWhile p f a b b0 -> TakingWhile p f a b a0 # | |
| Applicative (BazaarT p g a b) | |
Methods pure :: a0 -> BazaarT p g a b a0 # (<*>) :: BazaarT p g a b (a0 -> b0) -> BazaarT p g a b a0 -> BazaarT p g a b b0 # liftA2 :: (a0 -> b0 -> c) -> BazaarT p g a b a0 -> BazaarT p g a b b0 -> BazaarT p g a b c # (*>) :: BazaarT p g a b a0 -> BazaarT p g a b b0 -> BazaarT p g a b b0 # (<*) :: BazaarT p g a b a0 -> BazaarT p g a b b0 -> BazaarT p g a b a0 # | |
| (Monoid w, Functor m, Monad m) => Applicative (RWST r w s m) | |
| (Monoid w, Functor m, Monad m) => Applicative (RWST r w s m) | |
| Reifies s (ReifiedApplicative f) => Applicative (ReflectedApplicative f s) | |
Methods pure :: a -> ReflectedApplicative f s a # (<*>) :: ReflectedApplicative f s (a -> b) -> ReflectedApplicative f s a -> ReflectedApplicative f s b # liftA2 :: (a -> b -> c) -> ReflectedApplicative f s a -> ReflectedApplicative f s b -> ReflectedApplicative f s c # (*>) :: ReflectedApplicative f s a -> ReflectedApplicative f s b -> ReflectedApplicative f s b # (<*) :: ReflectedApplicative f s a -> ReflectedApplicative f s b -> ReflectedApplicative f s a # | |
(<$>) :: Functor f => (a -> b) -> f a -> f b infixl 4 #
An infix synonym for fmap.
The name of this operator is an allusion to $.
Note the similarities between their types:
($) :: (a -> b) -> a -> b (<$>) :: Functor f => (a -> b) -> f a -> f b
Whereas $ is function application, <$> is function
application lifted over a Functor.
Examples
Convert from a to a Maybe Int using Maybe Stringshow:
>>>show <$> NothingNothing>>>show <$> Just 3Just "3"
Convert from an to an Either Int IntEither IntString using show:
>>>show <$> Left 17Left 17>>>show <$> Right 17Right "17"
Double each element of a list:
>>>(*2) <$> [1,2,3][2,4,6]
Apply even to the second element of a pair:
>>>even <$> (2,2)(2,True)
(>=>) :: Monad m => (a -> m b) -> (b -> m c) -> a -> m c infixr 1 #
Left-to-right Kleisli composition of monads.
first :: Arrow a => a b c -> a (b, d) (c, d) #
Send the first component of the input through the argument arrow, and copy the rest unchanged to the output.
second :: Arrow a => a b c -> a (d, b) (d, c) #
A mirror image of first.
The default definition may be overridden with a more efficient version if desired.
(***) :: Arrow a => a b c -> a b' c' -> a (b, b') (c, c') infixr 3 #
Split the input between the two argument arrows and combine their output. Note that this is in general not a functor.
The default definition may be overridden with a more efficient version if desired.
makeLenses :: Name -> DecsQ #
Build lenses (and traversals) with a sensible default configuration.
e.g.
data FooBar
= Foo { _x, _y :: Int }
| Bar { _x :: Int }
makeLenses ''FooBar
will create
x ::Lens'FooBarIntx f (Foo a b) = (\a' -> Foo a' b) <$> f a x f (Bar a) = Bar <$> f a y ::Traversal'FooBarInty f (Foo a b) = (\b' -> Foo a b') <$> f b y _ c@(Bar _) = pure c
makeLenses=makeLensesWithlensRules