* package:ghc-lib-parser

Sequence actions, discarding the value of the first argument.

Examples

If used in conjunction with the Applicative instance for Maybe, you can chain Maybe computations, with a possible "early return" in case of Nothing.
>>> Just 2 *> Just 3
Just 3
>>> Nothing *> Just 3
Nothing
Of course a more interesting use case would be to have effectful computations instead of just returning pure values.
>>> import Data.Char

>>> import Text.ParserCombinators.ReadP

>>> let p = string "my name is " *> munch1 isAlpha <* eof

>>> readP_to_S p "my name is Simon"
[("Simon","")]
Sequence actions, discarding the value of the second argument.
Sequential application. A few functors support an implementation of <*> that is more efficient than the default one.

Example

Used in combination with (<$>), (<*>) can be used to build a record.
>>> data MyState = MyState {arg1 :: Foo, arg2 :: Bar, arg3 :: Baz}
>>> produceFoo :: Applicative f => f Foo
>>> produceBar :: Applicative f => f Bar

>>> produceBaz :: Applicative f => f Baz
>>> mkState :: Applicative f => f MyState

>>> mkState = MyState <$> produceFoo <*> produceBar <*> produceBaz
c :* sd is a demand that says "evaluated c times, and any trace in which it is evaluated will evaluate at least as deep as sd". Matching on this pattern synonym is a complete match. If the matched demand was AbsDmd, it will match as C_00 :* seqSubDmd. If the matched demand was BotDmd, it will match as C_10 :* botSubDmd. The builder of this pattern synonym simply discards the SubDemand if the Card was absent and returns AbsDmd or BotDmd instead. It will assert that the discarded sub-demand was seqSubDmd and botSubDmd, respectively. Call sites should consider whether they really want to look at the SubDemand of an absent demand and match on AbsDmd and/or BotDmd otherwise. Really, any other SubDemand would be allowed and might work better, depending on context.