Newest at the top
2024-04-28 12:05:36 +0200 | mima | (~mmh@eduroam-pool4-264.wlan.uni-bremen.de) (Ping timeout: 268 seconds) |
2024-04-28 12:04:09 +0200 | <tomsmeding> | yin: indeed, it's a type annotation that you can put in a convenient spot |
2024-04-28 12:03:52 +0200 | <int-e> | (wrong channel) |
2024-04-28 12:03:45 +0200 | <lambdabot> | -9223372036854775808 |
2024-04-28 12:03:43 +0200 | <yin> | > minBound :: Int |
2024-04-28 12:03:38 +0200 | <yin> | somehow i don't consider that to be patter matching. it's just like |
2024-04-28 12:03:26 +0200 | wootehfoot | (~wootehfoo@user/wootehfoot) |
2024-04-28 12:03:10 +0200 | <int-e> | tomsmeding: oh the cloudatacost.com fan page is gone, so sad. https://web.archive.org/web/20220811231349/https://cloudatacost.com/mystory/original-story-2014 |
2024-04-28 12:02:51 +0200 | <yin> | oh i see |
2024-04-28 12:02:25 +0200 | <tomsmeding> | it's nicer to write `catch _ (\(e :: IOException) -> ...)` |
2024-04-28 12:02:14 +0200 | <tomsmeding> | you typically have to manually constrain e somehow, and having to do that on some occurrence in the body is kind of clunky |
2024-04-28 12:02:08 +0200 | <yin> | yes |
2024-04-28 12:01:54 +0200 | <tomsmeding> | yin: do you see the `(e :: IOException)` in the example in the haddocks? |
2024-04-28 12:01:34 +0200 | <tomsmeding> | so then ghc asks you to say precisely what you mean -- some specific instantiation, or an actual polymorphic type where it's then on you to write down what ghc should do |
2024-04-28 12:01:14 +0200 | <yin> | tomsmeding: where's the type annotation on pattern matching in 'catch'? |
2024-04-28 12:01:00 +0200 | <tomsmeding> | perhaps because the polymorphism is constrained in some weird way |
2024-04-28 12:00:46 +0200 | <tomsmeding> | where ghc sees that your expression is polymorphic, but for some reason (typically a good one in general) it doesn't quite want to just infer that polymorphic type |
2024-04-28 12:00:15 +0200 | <tomsmeding> | right, that's an ambiguity error |
2024-04-28 12:00:09 +0200 | <famubu> | Yeah. |
2024-04-28 11:59:59 +0200 | <famubu> | tomsmeding: 👍 |
2024-04-28 11:59:58 +0200 | <tomsmeding> | famubu: was the error something like "Cannot match type Foo a with Foo a0"? |
2024-04-28 11:59:49 +0200 | <famubu> | [exa]: 🥴 |
2024-04-28 11:59:33 +0200 | <tomsmeding> | famubu: that would be a type equality |
2024-04-28 11:59:06 +0200 | <tomsmeding> | you need that e to infer to something specific, usually, and the body of the lambda is typically not enough for that |
2024-04-28 11:58:49 +0200 | <tomsmeding> | yin: a typical example of (1.) is https://hackage.haskell.org/package/base-4.19.0.0/docs/Control-Exception.html#v:catch |
2024-04-28 11:58:40 +0200 | <famubu> | I'm sure I'm not using the right term here.. |
2024-04-28 11:58:25 +0200 | <famubu> | Type annototaion had a 'type equivalence' thing from Token to Char. That had made the error go away. As in `Token ~ Char` |
2024-04-28 11:58:23 +0200 | <yin> | in the first case, isn't it always inferred by the type system anyways? |
2024-04-28 11:58:15 +0200 | <tomsmeding> | you can't pattern match on types in haskell |
2024-04-28 11:57:51 +0200 | <tomsmeding> | note that type annotations in patterns are just that -- type _annotations_, they don't influence pattern matching, they can only constrain the overall type of the function or bring type variables into scope |
2024-04-28 11:57:31 +0200 | <yin> | hmm |
2024-04-28 11:57:23 +0200 | <tomsmeding> | and with ScopedTypeVariables you can bring that thing into scope with a type annotation in a pattern |
2024-04-28 11:57:08 +0200 | <tomsmeding> | or 2. the argument's type has some instantiation of a type variable in it that you need on the type level, and you could get via other means but that would be very cumbersome |
2024-04-28 11:56:30 +0200 | <tomsmeding> | so you just write (x :: Int) as the argument or something |
2024-04-28 11:56:15 +0200 | <tomsmeding> | but it can be helpful, in my experience, in two cases: 1. you want some kind of type annotation on a lambda function but are too lazy to make it a let-defined thing with a type signature |
2024-04-28 11:55:46 +0200 | <tomsmeding> | I think it's never actually necessary |
2024-04-28 11:55:29 +0200 | <yin> | when do we use type annotations in pattern matching with it? |
2024-04-28 11:54:24 +0200 | mima | (~mmh@eduroam-pool4-264.wlan.uni-bremen.de) |
2024-04-28 11:53:20 +0200 | <tomsmeding> | ScopedTypeVariables is in GHC2021 (if that's what you mean with "the default ones") |
2024-04-28 11:52:47 +0200 | <yin> | assuming no language extensions other that the default ones, when are type annotations used in pattern matching? |
2024-04-28 11:40:58 +0200 | mreh | (~matthew@host86-160-168-68.range86-160.btcentralplus.com) |
2024-04-28 11:38:47 +0200 | wootehfoot | (~wootehfoo@user/wootehfoot) (Read error: Connection reset by peer) |
2024-04-28 11:14:36 +0200 | wootehfoot | (~wootehfoo@user/wootehfoot) |
2024-04-28 11:10:46 +0200 | poscat | (~poscat@user/poscat) |
2024-04-28 11:09:25 +0200 | wootehfoot | (~wootehfoo@user/wootehfoot) (Read error: Connection reset by peer) |
2024-04-28 11:02:49 +0200 | yin | (~yin@user/zero) |
2024-04-28 11:00:54 +0200 | poscat0x04 | (~poscat@user/poscat) (Ping timeout: 255 seconds) |
2024-04-28 11:00:02 +0200 | Rodney_ | (~Rodney@176.254.244.83) |
2024-04-28 10:50:18 +0200 | yin | (~yin@user/zero) (Ping timeout: 252 seconds) |
2024-04-28 10:46:44 +0200 | L29Ah | (~L29Ah@wikipedia/L29Ah) |