Live data from Hacker News

Exception Patterns (2013)

wiki.c2.com

21–30 of 30 posts

Re: Exception Patterns (2013)

#21

Earlier quoted context omitted.

Unfortunately, even with fp-ts, typescript does not yet have the means to enable ergonomic handling of errors without exceptions. I hope they improve this in the future though.

As a daily fp-ts user I'm not sure I agree, you handle them with the appropriate data type: Either. Exceptions are a path like any other, there's nothing really magical about those, you catch the functions that could throw and handle the fact they have thrown the error, which error, why? There's two helpers for that in fp-ts [1][2] plus the obvious lazy and asynchronous counter parts in the TaskEither and ReaderTaskE…

I think it's a matter of perspective. I tried to user Either, but without proper pattern matching and syntactic sugar for monadic operations, I didn't quite like it.

That being said, I think the authors did a great job to make it as good as possible given the limitations.

Re: Exception Patterns (2013)

#22

Earlier quoted context omitted.

As a daily fp-ts user I'm not sure I agree, you handle them with the appropriate data type: Either. Exceptions are a path like any other, there's nothing really magical about those, you catch the functions that could throw and handle the fact they have thrown the error, which error, why? There's two helpers for that in fp-ts [1][2] plus the obvious lazy and asynchronous counter parts in the TaskEither and ReaderTaskE…

I think it's a matter of perspective. I tried to user Either, but without proper pattern matching and syntactic sugar for monadic operations, I didn't quite like it. That being said, I think the authors did a great job to make it as good as possible given the limitations.

Could you show the limitations you're speaking of?

I know fp-ts very well and it does not have those limitations you're speaking of.

Either admits all of the functor, bifunctor, monad, apply, applicative and traversable instances in fp-ts (so do all the other bifunctors) so there's no shortage of combinators.

Re: Exception Patterns (2013)

#23

Earlier quoted context omitted.

I think it's a matter of perspective. I tried to user Either, but without proper pattern matching and syntactic sugar for monadic operations, I didn't quite like it. That being said, I think the authors did a great job to make it as good as possible given the limitations.

Could you show the limitations you're speaking of? I know fp-ts very well and it does not have those limitations you're speaking of. Either admits all of the functor, bifunctor, monad, apply, applicative and traversable instances in fp-ts (so do all the other bifunctors) so there's no shortage of combinators.

Essentially, I want do write things in the style of (pseudocode)

    do {
       result1 
and so on. This gets very noisy without syntactic sugar.

Re: Exception Patterns (2013)

#24

Earlier quoted context omitted.

I think it's a matter of perspective. I tried to user Either, but without proper pattern matching and syntactic sugar for monadic operations, I didn't quite like it. That being said, I think the authors did a great job to make it as good as possible given the limitations.

Could you show the limitations you're speaking of? I know fp-ts very well and it does not have those limitations you're speaking of. Either admits all of the functor, bifunctor, monad, apply, applicative and traversable instances in fp-ts (so do all the other bifunctors) so there's no shortage of combinators.

@valenterry (I can't reply further), you can do that:

https://codesandbox.io/s/wispy-shadow-7789p6?file=/src/index...

In whatever ways you want to complicate it (with exceptions, asynchronous operations, with or without Do syntax) you can easily do that in fp-ts.

Re: Exception Patterns (2013)

#25

Earlier quoted context omitted.

Could you show the limitations you're speaking of? I know fp-ts very well and it does not have those limitations you're speaking of. Either admits all of the functor, bifunctor, monad, apply, applicative and traversable instances in fp-ts (so do all the other bifunctors) so there's no shortage of combinators.

@valenterry (I can't reply further), you can do that: https://codesandbox.io/s/wispy-shadow-7789p6?file=/src/index... In whatever ways you want to complicate it (with exceptions, asynchronous operations, with or without Do syntax) you can easily do that in fp-ts.

You can click on the timestamp of the post to reply next time ;)

Re: Exception Patterns (2013)

#26

Earlier quoted context omitted.

@valenterry (I can't reply further), you can do that: https://codesandbox.io/s/wispy-shadow-7789p6?file=/src/index... In whatever ways you want to complicate it (with exceptions, asynchronous operations, with or without Do syntax) you can easily do that in fp-ts.

You can click on the timestamp of the post to reply next time ;)

Today I learned, thank you.

Re: Exception Patterns (2013)

#27

Earlier quoted context omitted.

Could you show the limitations you're speaking of? I know fp-ts very well and it does not have those limitations you're speaking of. Either admits all of the functor, bifunctor, monad, apply, applicative and traversable instances in fp-ts (so do all the other bifunctors) so there's no shortage of combinators.

@valenterry (I can't reply further), you can do that: https://codesandbox.io/s/wispy-shadow-7789p6?file=/src/index... In whatever ways you want to complicate it (with exceptions, asynchronous operations, with or without Do syntax) you can easily do that in fp-ts.

(edited)

That's actually not too bad!

Re: Exception Patterns (2013)

#29
I'm on Firefox on Android and all I get is a neverending loading spinner and

> This site uses features not available in older browsers.

This site used to be good, just plain html, no javascript, little styling to get in the way... What happened to it?

Re: Exception Patterns (2013)

#30

Earlier quoted context omitted.

Could you show the limitations you're speaking of? I know fp-ts very well and it does not have those limitations you're speaking of. Either admits all of the functor, bifunctor, monad, apply, applicative and traversable instances in fp-ts (so do all the other bifunctors) so there's no shortage of combinators.

@valenterry (I can't reply further), you can do that: https://codesandbox.io/s/wispy-shadow-7789p6?file=/src/index... In whatever ways you want to complicate it (with exceptions, asynchronous operations, with or without Do syntax) you can easily do that in fp-ts.

If you are still here: any resources on how to build those other things that you mentioned myself? For example, if I would like to combine either and reader into a single monad, how would that look like? Now I'm kinda thrilled!
Post reply on HN