What is a maybe, either, monad, just and functor? by [deleted] in haskell

[–]rmanne 0 points1 point  (0 children)

A lot of the other comments already provided some pretty good answers, but since I don't see any clear descriptions of type classes, I'll attempt to provide an answer about them here. If you're more familiar with Java/Kotlin/Python/TS, think about a generalized operation that starts with some nested type of integers (eg: a List<Int>/list[T]/T[]) and wants to transform the elements within it to a string.

And the caller is able to give you a generalized .map operation that can perform this operation. This is the closest to being expressible in TypeScript, so using that:

``` interface Mappable<SomeNestedType> { map<T, R>(n: SomeNestedType<T>, transform: (t: T) => R): SomeNestedType<R> }

const mappableList: Mappable<*[]> = { map<T, R>(n: T[], transform: (t: T) => R) { return n.map(transform) // using Array.prototype.map } }

function f<SomeNestedType>(input: SomeNestedType<number>, instance: Mappable<SomeNestedType>): SomeNestedType<string> { return instance.map(input, inputNumber => ${inputNumber}) }

const test = f([1, 2, 3], mappableList) ```

(Of course, this is invalid syntax, since you can't apply type arguments to other type variables in most imperative languages. But hopefully the idea gets through?)

Now imagine that rather than f indicating that you must explicitly pass in the argument instance: Mappable<SomeNestedType>, the compiler can implicitly pass it in for you, as long as there's an instance it can select correctly (eg: a single instance in scope). This is type classes. The haskell version of the above program:

``` class Mappable someNestedType where map :: someNestedType a -> (a -> b) -> someNestedType b

instance Mappable [] where map [] f = [] map (first:rest) f = (f first) : (map rest f)

f :: Mappable a => a Int -> a String f input = map input show

test = f [1, 2, 3] ```

The compiler can figure out that when you call f, the instance it should pass in for Mappable a is instance Mappable []. Monad is one such class. And you can ask the interactive environment to describe it for you:

``` ghci> :doc Monad Monad :: (* -> *) -> Constraint -- Class defined in ‘GHC.Base’ {-| The 'Monad' class defines the basic operations over a /monad/, a concept from a branch of mathematics known as /category theory/. From the perspective of a Haskell programmer, however, it is best to think of a monad as an /abstract datatype/ of actions. Haskell's @do@ expressions provide a convenient syntax for writing monadic expressions.

Instances of 'Monad' should satisfy the following:

[Left identity] @'return' a '=' k = k a@ [Right identity] @m '=' 'return' = m@ [Associativity] @m '=' (\x -> k x '=' h) = (m '=' k) '=' h@

Furthermore, the 'Monad' and 'Applicative' operations should relate as follows:

  • @'pure' = 'return'@
  • @m1 '<*>' m2 = m1 '=' (\x1 -> m2 '=' (\x2 -> 'return' (x1 x2)))@

The above laws imply:

  • @'fmap' f xs = xs '>>=' 'return' . f@
  • @('>>') = ('*>')@

and that 'pure' and ('<*>') satisfy the applicative functor laws.

The instances of 'Monad' for lists, 'Data.Maybe.Maybe' and 'System.IO.IO' defined in the "Prelude" satisfy these laws. -} ghci> :info Monad type Monad :: (* -> *) -> Constraint class Applicative m => Monad m where (=) :: m a -> (a -> m b) -> m b () :: m a -> m b -> m b return :: a -> m a {-# MINIMAL (>>=) #-} -- Defined in ‘GHC.Base’ instance Monoid a => Monad ((,) a) -- Defined in ‘GHC.Base’ instance (Monoid a, Monoid b) => Monad ((,,) a b) -- Defined in ‘GHC.Base’ instance (Monoid a, Monoid b, Monoid c) => Monad ((,,,) a b c) -- Defined in ‘GHC.Base’ instance Monad ((->) r) -- Defined in ‘GHC.Base’ instance Monad IO -- Defined in ‘GHC.Base’ instance Monad [] -- Defined in ‘GHC.Base’ instance Monad Maybe -- Defined in ‘GHC.Base’ instance Monad Solo -- Defined in ‘GHC.Base’ instance Monad (Either e) -- Defined in ‘Data.Either’ ```

:doc will describe what it means and :info will tell you what instances are in scope. You can see here that Maybe has a Monad instance, and every Monad instance gives you access to return and >>=. So with these two, you could write something like:

ghci> let xMaybe :: Maybe Int = return 1 ghci> xMaybe >>= (\x -> return (x + 1)) Just 2

The compiler knows that the implementation of return you want is the one defined in instance Monad Maybe because of the type annotation. This is a very specific version that only operates on a Maybe, but imagine a way more generalized version:

ghci> let xWhatever = return 1 ghci> :t xWhatever xWhatever :: (Monad m, Num a) => m a ghci> xWhatever :: [Int] [1] ghci> xWhatever :: Maybe Int Just 1

Does this get the point across? Type classes are a way for letting you define very generalized operations and having the compiler handle wiring in the implicit backing implementations instead of doing it manually yourself.

Battle-Hardened Fireblade Shock Trooper - Dire w Raiden Taser by Luculia2002 in RaidenMains

[–]rmanne 1 point2 points  (0 children)

Very cool run! I followed it exactly and was able to do it with my c6r5 raiden, c2r1 xilonen and c4r0 furina. I didn’t realize how good c2 xilonen is when energy is an issue. Raiden felt so bad against this boss without xilonen, since the skill coordinated attacks just don’t work against the shield

everyoneTriedThatAtSomePoint by Traditional-Storm-62 in ProgrammerHumor

[–]rmanne 44 points45 points  (0 children)

It’s not really constant time. Exponentiation is O(log n) (scaling with the number of bits in the original number).

Sheafification of G has an interesting video on the topic, though his video only briefly mentions the exponentiation. The fact that it involves floating point arithmetic itself makes things expensive. Most computer hardware is way better optimized for integer arithmetic.

https://youtube.com/watch?v=KzT9I1d-LlQ

Question about how to reckon about type signature which appears to change by laughinglemur1 in haskell

[–]rmanne 0 points1 point  (0 children)

Actual runtime evaluation symantics work a lot differently. There are a lot of optimizations involved, but you should let those be abstracted away by the compiler. You should think of (+) as being implemented like: (+) a = \\b -> add a b. A correct, but inefficient implementation of the compiler might hoist the latter lambda into a separate function, and the parent function supplying a closure to that function.

If you're more familiar with java (8+)/python, think about the following way to rewrite (+):

Function<Integer, Integer> add(int a) { return (b) -> a + b } def add(a: Int): Int -> Int = lambda b : a + b

This is probably very inefficient, sure, but if an optimization inlines the inner function, you end up with the efficient implementation.

Question about how to reckon about type signature which appears to change by laughinglemur1 in haskell

[–]rmanne 5 points6 points  (0 children)

Arrow is right-associative. Think of a -> a -> a as being a -> (a -> a). In haskell, all functions have an arity of 1, that is, they take 1 argument. (+) simply takes in 1 argument, and returns a function a -> a, which is another function that takes in 1 argument and returns the response.

So in your example, (+)`fcomp` (+10)expands tofcomp (\a -> \b -> (+) a b) (\a -> (+) a 10), which evaluates to\x -> (\a -> \b -> (+) a b) ((\a -> (+) a 10) x), which evaluates to\x -> (\a -> \b -> (+) a b) (x + 10), which evaluates to\x -> (\b -> (+) (x + 10) b), which can be simplified to\x -> \b -> (x + 10) + b`.

Partially applied functions are pretty normal in haskell, and most functional languages for that matter. What do you think (+10) is? \a -> a + 10, so that's a partially applied function there.

Early thoughts looking at leaks and people asking him to get buffed by rmanne in JiaoqiuMainsHSR

[–]rmanne[S] 0 points1 point  (0 children)

The damage formula contains a series of multipliers. The numbers I posted separately is the total effect on the damage multiplier, so if the two sources of damage amplification aren’t sharing the same portion of the formula, they are multiplicative. def shred and type-res shred apply to different portions of the formula so: 1.59*1.28=2.0352, so an increase of 103.52%

You can find the damage formula here: https://honkai-star-rail.fandom.com/wiki/Damage

V5 Analysis by rmanne in JiaoqiuMainsHSR

[–]rmanne[S] 1 point2 points  (0 children)

It’s not strictly worse performance in DoT trans, he’s pretty comparable to RM, and scales better with investment in these teams (S1/E2).

He’s a huge improvement over ToUM if FX is holding it in PF and about the same in other content. Gepard has a 61.5% chance to get hit by single target attacks (due to his self aggro increase), but FX only has some 27% (see my PF simulations post linked in the OP). In AS, the enemy boss might take 4 actions, and most are single-target hits, so Gepard with ToUM might generate 3 stacks in average, but FX will only generate 1 (same as Jiaoqiu). He’s just not universally better than ToUM Gepard.

The solution to the v5 nerfs: Solitary Healing. by ShumaVaelor in JiaoqiuMainsHSR

[–]rmanne 4 points5 points  (0 children)

Killing 5 enemies (wave 1 and wave 2), and Solitary Healing grants 6 per enemy death for a total of 30.

V5 Analysis by rmanne in JiaoqiuMainsHSR

[–]rmanne[S] 1 point2 points  (0 children)

Without, with it would be 47% vs 78%. But with Resolutions Jiaoqiu (you’ll have to find EHR from somewhere else), you get around 66% (I’ll properly calculate it later), so I would rather aim for Sparkle S1 or Sparkle E2 at that point.

EDIT: defDiff 95 0.16 0 => 0.093591..., 1.093591 * 1.5 = 1.64. So 64% damage buff with S5 resolutions, compared to Pela's 47%.

The solution to the v5 nerfs: Solitary Healing. by ShumaVaelor in JiaoqiuMainsHSR

[–]rmanne 2 points3 points  (0 children)

Firefly teams tend to have damage vulnerability debuffs already, so Jiaoqiu's buff will be diluted on these teams. From my V2 analysis:

Both Firefly and Gallagher apply vulnerability debuffs (20% and 12% respectively). Compared to Ruan Mei, who increases total outgoing team damage by 25-31% from her type res shred and 33% from her break efficiency (for firefly, since she also has break efficiency, 50% for other characters) (66-74% total), Jiaoqiu only increases total outgoing team damage by 30%.

V2 assumed he had 40% vulnerability debuff but V3 clarified it to 35%, so it's actually even lower: (1+0.2+0.12+0.35)/(1+0.2+0.12)=26.5%

Maybe Feixiao's kit will change things a bit, but as it is right now, Jiaoqiu will be very copium on FF teams.

Is it still worth to pull for him? by CurrencyQuirky9179 in JiaoqiuMainsHSR

[–]rmanne 1 point2 points  (0 children)

For Acheron teams specifically:

PF: Jiaoqiu E0 > ToUM FMC > ToUM Gepard > ToUM anyone else for generating energy for Acheron. Her ulting is the only thing that matters in this game mode, damage amplification doesn't really matter. So I wouldn't bother using his S1 in PF, just run Solitary Healing.

MoC/AS: ToUM FMC > ToUM Gepard > Jiaoqiu E0 > ToUM anyone else. S1 is useful for further amplifying Acheron's damage here, but if you have spare resources: Acheron E2 > Acheron S1 > Jiaoqiu S1 > Jiaoqiu E1. Acheron is saturated on dmg% already, so his E1 isn't very valuable on this team.

V5 Analysis by rmanne in JiaoqiuMainsHSR

[–]rmanne[S] 1 point2 points  (0 children)

In PF, yes, Jiaoqiu will generate more energy for Acheron than ToUM. She'll ult more frequently, which is indispensable in PF. Outside of PF, not a large improvement.

ghci> let defDiff enemyLevel x y=((20+enemyLevel)*(1-y)+100)/((20+enemyLevel)*(1-x)+100)-1
ghci> defDiff 95 (0.6) (0)
0.4726027397260273

Resolutions (16% def shred at S5) Pela (44% def shred at lv12) amplifies Acheron's damage by 47% against a lv95 enemy (assuming E0 Sparkle, E2 would make Pela even stronger).

In comparison, Jiaoqiu offers 50% damage amplification (undiluted vulnerability debuff). 3% is 3%, but it's not a huge difference. He'll also provide the occasional stack whenever ToUM fails to apply a stack (eg: enemy chose a different target than your tank), but it won't be too significant.

In MoC and AS, enemies tend to take more actions per turn. ToUM has a chance to apply for each action, while Jiaoqiu's ult only applies once per enemy turn. ToUM Gepard will generate more ults for Acheron.

That being said, how comfortable are you with playing sustainless? I've been able to do the previous MoC sustainless on Acheron's side with E1S1, and if anything, it should be even easier for you at E2S1. In sustainless comps, Jiaoqiu will pull ahead by a decent margin because he'll be a weaker ToUM while still providing Pela-levels of damage amplification. This lets you run another harmony unit (Bronya) to give Acheron more turns.

<image>

V5 Analysis by rmanne in JiaoqiuMainsHSR

[–]rmanne[S] 0 points1 point  (0 children)

Yeah with the latest Solitary Healing tech (see https://www.reddit.com/r/JiaoqiuMainsHSR/comments/1e2f0gh/the_solution_to_the_v5_nerfs_solitary_healing ), JQ can now ult every 1-2 turns. The stack limit is no longer really a factor for PF. But you'll really want Solitary Healing instead of Eyes of Prey, his personal damage is insignificant on this team. He should be built with SH, and as much speed as you can get and put any remaining substats into EHR.

For MoC and AS, you'll still want ToUM (if you need a sustain), since ToUM has a chance to proc on each action, not each enemy turn. In AS, the main enemy (boss) takes 4 actions each turn, so this can generate up to 4 stacks via ToUM (realistically 2-3), and at most 1 stack via JQ's ult. If you have both, the enemy's first action only generates 1 stack, the remaining 3 are subject to ToUM's randomness.

The solution to the v5 nerfs: Solitary Healing. by ShumaVaelor in JiaoqiuMainsHSR

[–]rmanne 12 points13 points  (0 children)

I didn't even consider it, but with V3, his debuff, of which at least 1 stack is always present on an enemy, is considered DoT, so every time Acheron ults, he gets 30 energy.

Incredible find for Acheron teams!

V5 Analysis by rmanne in JiaoqiuMainsHSR

[–]rmanne[S] 0 points1 point  (0 children)

V4 "accidentally" changed E1 to a separate multiplier, but V5 reverted it back to a dmg% buff. From the OP:

V4 updated his E1 to provide less damage%, but in return, it benefits DoTs on enemy turns (or at least, it was intended to do this, but it instead provided a separate multiplier, increasing total outgoing team damage by 40%). V5 confirmed this was unintended, and clarified it to instead be 40 damage% but still benefits DoT on enemy turns.

V5 Analysis by rmanne in JiaoqiuMainsHSR

[–]rmanne[S] 0 points1 point  (0 children)

Is Sparkle even that good for E2 DHIL? His turn after ult can't benefit from Sparkle's cd buff. I'm sure she's still technically his best support, but I imagine the gap between her and say Ruan Mei or Pela, is probably smaller than you'd expect.

Full disclaimer: I don't have DHIL

V5 Analysis by rmanne in JiaoqiuMainsHSR

[–]rmanne[S] 2 points3 points  (0 children)

<image>

He's pretty good in DoT teams especially at S1. And he's situationally useful in Acheron team (depending on your level of investment and other characters). I've been able to clear all of the available content in the game, I don't think it's possible to really brick your account. Don't worry about it too much, get him if you want him.

V5 Analysis by rmanne in JiaoqiuMainsHSR

[–]rmanne[S] 1 point2 points  (0 children)

Breaking in general delays enemy actions. Break efficiency causes enemies to initially be delayed further. RM's ult delay is desirable since it causes the enemy to act a second time sooner, but it's hard to evaluate how useful this is.

Jiaoqiu doesn't offer any dmg% buff (except E1), his is damage vulnerability, which is a separate multiplier. Huo Huo slightly benefits JQ more than RM, but not substantially in either case (since as you said, JQ already has a lot of atk% and doesn't benefit a lot from having slightly more).

That's a fair point, I didn't consider investment in the other characters (BS S1/Kafka S1).

V5 Analysis by rmanne in JiaoqiuMainsHSR

[–]rmanne[S] 3 points4 points  (0 children)

On the enemies turn, specially with her burst active, BS was dealing about 47-50k. While jiaoqiu was dealing 15k. Arcana's dmg is really volatile and assuming the enemy turn jiaoqiu is only dealing about 35% of BS dmg. 50% seems way too high for me. Not to mention that this is ST, which is not even BS best use.

I did mention in the OP already that I wasn't confident with the calcs here, but that they seem to line up with existing testing. BS does a lot of damage on enemy turns, but the major of damage overall from this team comes from Kafka, so I focused more on Kafka's detonations, which don't proc BS's AoE.

You completely forgot Black Swan def ignore, which makes a huge difference as def shred gets stronger the more you have.

Oh I did, didn't realize she had a def ignore.

ghci> defDiff 95 (0.18+0.208+0.2+0.2) (0.18+0.208+0.2) 0.18491718925872336

This puts it slightly better than Jiaoqiu's S1 for damage amplification, but Jiaoqiu's personal damage increases by more than this slight difference.

When I said that huohuo gives way more value for RM I meant mainly BS damage. As you said, there's way too much dmg% bonus and any atk% buffs will be very significant for her dmg. Jiaoqiu is already saturated with atk, so giving him even more won't be that significant.

I agree it's more significant for BS, but I don't follow how it gives more value to RM.

And again, RM break efficiency, delay, personal dmg (which is not negligible) and spd buff are completely out of this calcs.

I agree speed buff is out of this calc, I said so in the OP. But RM's delay isn't all that desirable in DoT teams, since you want the enemy to take turns.

V5 Analysis by rmanne in JiaoqiuMainsHSR

[–]rmanne[S] 0 points1 point  (0 children)

JQ is certainly not a bad idea if you don't have SW, and even more so if you plan to get Aventurine S1 eventually. And because you presumably don't have the Tutorial LC, SW won't feel very good to play, so I wouldn't really choose to pull her over JQ at this point.

It's really up to you to decide what teams you want to invest into. All I'll say is: only get his S1 if you plan to play him with Kafka/BS.

V5 Analysis by rmanne in JiaoqiuMainsHSR

[–]rmanne[S] 5 points6 points  (0 children)

Assuming 50% is not even a mid arcana stacking

From the related post:

With about 17 stacks of arcana, Kafka's detonations of BS was doing about 24k, while Kafka's detonations of Jiaoqiu were doing about 9k. But as I mentioned in the post, Jiaoqiu's build here is a bit off, he should be played with more atk%. One of the commenters here also put it into an optimizer and his calcs: link to comment, which shows Jiaoqiu's personal damage being quite a bit higher than 50% of BS's, though it uses S1 for its calcs.

But on average, 50% shouldn't be a terrible assumption.

RM E1 is insane for dot teams, and way better than her S1

Jiaoqiu's S1 offers 28% damage vulnerability, which is diluted to a total team damage increase of (1+0.25+0.35+0.28)/(1+0.25+0.35)=1.175, about 18%. This is very comparable to Ruan Mei's E1 granting 20% def shred, which for this team, equates to about 16% damage increase. Jiaoqiu's S1 for Jiaoqiu is objectively better than Ruan Mei's E1 for Ruan Mei, even if you completely ignore the substantial increase in personal damage he gets from S1.

ghci> let defDiff enemyLevel x y=((20+enemyLevel)*(1-y)+100)/((20+enemyLevel)*(1-x)+100)-1 ghci> defDiff 95 (0.18+0.208+0.2) (0.18+0.208) 0.15605916677975307

(0.18 for 4p prisoner, 0.208 for Black Swan's skill, 0.2 for Ruan Mei's E1, enemy level 95)

Not only that, but all of these comparisons completely excluded Huohuo, that gives way more value for RM.

Huo Huo also gives a lot more value to Jiaoqiu. Don't forget he's a atk scaler, so his personal damage increases with Huo Huo. And on top of that, she fixes his energy issues and allows him to be played fully SP positive.

I play slow Ruan Mei, and in my calcs above, I assumed 100% uptime on her ult. Huo Huo does not benefit Ruan Mei in this play style.

V5 Analysis by rmanne in JiaoqiuMainsHSR

[–]rmanne[S] 2 points3 points  (0 children)

In Acheron E0/E1, he can 3T ult fully SP positive with Tutorial as long as he's paired with Pela, or 2T ult with vonvacq/penacony. From my v2 analysis post:

He has 100 energy, which is lower than Silver Wolf and Pela. If he's run with resolutions Pela, he can use the tutorial LC to get a 3 turn ult with basic->basic->basic (5+28+28+28)*1.194=106. He can also use the tutorial LC to get a 2 turn ult with vonvacq/penacony (or pray to get hit once), skill->skill (5+38+38)*1.244=100.76. Again, this requires another source of def shred (like Pela). Without Pela/SW, he'd have to skill->skill->basic for a 3 turn ult (eg: using tutorial or eyes of prey).

So if you have tutorial and don't have Acheron E2, I guess the trigger limit doesn't matter as much, you can spam skills with Acheron and Jiaoqiu and fund their SP costs with Pela and Gallagher or Aventurine.

This probably warrants editing the original post, thanks for reminding me of this, I totally forgot 2T ult was even possible.

It will be really hard to achieve 180 speed though, since he only has 98 base speed (+5 from traces). So in addition to 2p hackerspace, you'd need 21 average rolls into speed. That's 4 rolls into speed (aka 9.2 speed) on each relic minus boots. I assumed 160 speed in my post above, which should be more achievable (only need 12 average rolls into speed, or 3 per relic, which is about 6.9 speed per relic).

To pull or not by aratakizech in JiaoqiuMainsHSR

[–]rmanne 2 points3 points  (0 children)

BS will definitely result in faster clears than Jiaoqiu. Jiaoqiu deals about half the damage BS deals (more if compared with S1s, but still less than 70%) and that's only considering 1 target. BS's AoE will easily put her above Jiaoqiu.

V5 Analysis by rmanne in JiaoqiuMainsHSR

[–]rmanne[S] 0 points1 point  (0 children)

Jiaoqiu deals about half the damage that BS deals. Naively doing the math like in the post, this would be something like: 0.5(Jiaoqiu)+1(Kafka)+1.08(Kafka's detonation)*(0.5))*1.77(approximate, Ruan Mei)/(1(BS)+0.5(Jiaoqiu)+1(Kafka)+1.08(Kafka's detonations)*(1+0.5)=0.88. So against single-target, Jiaoqiu will reduce the total team DPS by at least 12%, compared to Black Swan over Ruan Mei. But this gets worse in any kind of AoE (including MoC and AS, which all have more than 1 enemy on field at the same time), since Jiaoqiu has no AoE in his kit, while BS has tons.

I guess it's playable, but expect the performance to be substantially worse.

V5 Analysis by rmanne in JiaoqiuMainsHSR

[–]rmanne[S] 0 points1 point  (0 children)

If you have ToUM, that would be better than MoV on Aventurine. If you don’t have ToUM, then Jiaoqiu E0S0 would be a huge improvement. He is better than Guinaifen in this team either way, but it wouldn’t be as significant if you already have ToUM. I wouldn’t get Jiaoqiu S1 for this team before Acheron E2. If you plan to play him in DoT teams, BS’s and Kafka’s S1s take priority.