Logs: freenode/#haskell
| 2021-05-17 14:29:23 | alexander | is now known as Guest77094 |
| 2021-05-17 14:29:24 | → | ddellac__ joins (ddellacost@gateway/vpn/mullvad/ddellacosta) |
| 2021-05-17 14:29:31 | × | UTENTE quits (~Username@176.32.27.9) (Read error: Connection reset by peer) |
| 2021-05-17 14:29:34 | → | mrchampion joins (~mrchampio@206.186.171.254) |
| 2021-05-17 14:29:43 | × | Lycurgus quits (~niemand@cpe-45-46-140-49.buffalo.res.rr.com) (Quit: Exeunt) |
| 2021-05-17 14:29:50 | → | stree joins (~stree@68.36.8.116) |
| 2021-05-17 14:32:02 | <willardthor> | Thank you for the responses so far. @Cale What happens if you remove the annotation? : As evidenced by `Example0.hs` vs. `Example1.hs`, removing the `:: v` produces a type error. @Cale You're not using ScopedTypeVariables : I'll look into this; thanks for the tip! |
| 2021-05-17 14:34:13 | × | ddellac__ quits (ddellacost@gateway/vpn/mullvad/ddellacosta) (Ping timeout: 260 seconds) |
| 2021-05-17 14:34:25 | <boxscape> | does the star in `:m *<modulename>` simply mean that non-exported bindings can be used or does it also mean that the module is forced to be loaded interpreted instead of compiled? |
| 2021-05-17 14:34:28 | <boxscape> | (in ghci) |
| 2021-05-17 14:35:06 | <willardthor> | geekosaur "The scope of v does not extend to the definition, only to the declaration" : Can you clarify? Is the fact that I coerced at the right-hand-side of '=' not taken into account when typing the whole function definition? |
| 2021-05-17 14:35:36 | <Cale> | willardthor: oh, I see, yeah, you didn't have the type error in Example0.hs |
| 2021-05-17 14:35:48 | <Cale> | It seems like removing it fixes the problem? |
| 2021-05-17 14:36:07 | <Cale> | willardthor: It's just that it's not the same v |
| 2021-05-17 14:36:20 | <Cale> | willardthor: So it's as though you'd written thedef :: w there |
| 2021-05-17 14:36:44 | <Cale> | and then GHC doesn't know that w is supposed to be equal to the v from the type signature for the function |
| 2021-05-17 14:37:09 | <Cale> | (or definition, rather) |
| 2021-05-17 14:37:27 | <boxscape> | % :m + *Data.Monoid |
| 2021-05-17 14:37:27 | <yahb> | boxscape: module 'Data.Monoid' is from another package;; this command requires an interpreted module |
| 2021-05-17 14:37:33 | <boxscape> | I suppose that answers my question |
| 2021-05-17 14:37:38 | <willardthor> | Cale "Removing it fixes the problem": Yeah, but I kind of need it later :-P (Unless there's another way to do what I am trying to, of course). I'm writing a polymorphic function, where the only thing I know about the input type, is that it's a member of `Def` . I would then like to obtain the default value of the input type, in the function |
| 2021-05-17 14:37:39 | <willardthor> | body. |
| 2021-05-17 14:38:01 | × | nyd quits (~nyd@unaffiliated/elysian) (Ping timeout: 265 seconds) |
| 2021-05-17 14:38:33 | <willardthor> | Cale "It's just that it's not the same v" : That's what GHCI is saying, and that's what I'm not getting. Why is it not the same, or how do I make clear that it's the same? |
| 2021-05-17 14:38:49 | <geekosaur> | you use ScopedTypeZVZariables |
| 2021-05-17 14:38:51 | <geekosaur> | er |
| 2021-05-17 14:38:58 | <geekosaur> | you use ScopedTypeVariables |
| 2021-05-17 14:39:01 | <Cale> | willardthor: Without turning on extensions, type variables never scope over anything larger than a single type signature |
| 2021-05-17 14:39:36 | → | nyd joins (nyd@gateway/vpn/protonvpn/elysian) |
| 2021-05-17 14:40:48 | <Cale> | So yeah, you have to turn on ScopedTypeVariables if you want to be able to refer to the same v |
| 2021-05-17 14:41:11 | × | xff0x quits (xff0x@gateway/vpn/mullvad/xff0x) (Ping timeout: 268 seconds) |
| 2021-05-17 14:41:11 | × | benin quits (~benin@183.82.177.199) (Ping timeout: 268 seconds) |
| 2021-05-17 14:41:13 | <Cale> | I don't think there's another way, apart from doing trickery that would complicate the type of def |
| 2021-05-17 14:41:35 | <willardthor> | Cale geekosaur I just tried turning on `ScopedTypeVariables` (adding `{-# LANGUAGE ScopedTypeVariables #-}` to the start of `Example1.hs` and `Example2.hs` ), without success; the same errors get reported. |
| 2021-05-17 14:42:06 | <Cale> | Yep, to use ScopedTypeVariables, you have to explicitly bind the variables using forall |
| 2021-05-17 14:42:18 | <willardthor> | ... ah. Let me do that real quick. |
| 2021-05-17 14:42:50 | → | xff0x joins (~xff0x@2001:1a81:535b:1600:c038:9b40:2a0a:496d) |
| 2021-05-17 14:46:21 | <willardthor> | Cale geekosaur I added `forall v .` at the start of the type declaration of `thedef` . This fixes the problem in `Example1.hs` . I did the same in `Example2.hs` , yet the problem remains there. |
| 2021-05-17 14:47:17 | <Cale> | Did you also add a signature to clarify the type of the usage of def? |
| 2021-05-17 14:47:24 | <willardthor> | waitwait, I then coerced the `def` and /that/ worked |
| 2021-05-17 14:47:29 | <Cale> | yep |
| 2021-05-17 14:47:31 | → | parabolize joins (~paraboliz@98.43.173.221) |
| 2021-05-17 14:47:34 | <willardthor> | :-) Thanks guys |
| 2021-05-17 14:47:38 | → | romesrf joins (~romesrf@44.190.189.46.rev.vodafone.pt) |
| 2021-05-17 14:47:41 | × | ddellacosta quits (~ddellacos@ool-44c73afa.dyn.optonline.net) (Ping timeout: 265 seconds) |
| 2021-05-17 14:48:29 | <romesrf> | hey everyone, if I do a StateT Maybe monad, and return (Element) normally, how can I lift the StateT to return Nothing instead of a Just something ? |
| 2021-05-17 14:49:21 | <[exa]> | romesrf: how did the Maybe get there? |
| 2021-05-17 14:49:30 | <[exa]> | ah sorry I can't read |
| 2021-05-17 14:49:43 | <romesrf> | perhaps i should make a small example, but i thought it might be a common issue |
| 2021-05-17 14:50:01 | <[exa]> | for returning nothing I'd just try failing, e.g. with `empty` |
| 2021-05-17 14:50:01 | <romesrf> | some function has type Something -> StateT SomeState Maybe Something |
| 2021-05-17 14:50:13 | <[exa]> | (possibly: lift empty) |
| 2021-05-17 14:50:19 | <romesrf> | Oh! Okay, i'll try that. |
| 2021-05-17 14:50:37 | × | acidjnk_new quits (~acidjnk@p200300d0c72b9554e88f3d58cc93ff66.dip0.t-ipconnect.de) (Ping timeout: 250 seconds) |
| 2021-05-17 14:51:08 | <[exa]> | :t lift empty |
| 2021-05-17 14:51:09 | <lambdabot> | (MonadTrans t, Monad m, Alternative m) => t m a |
| 2021-05-17 14:51:47 | <[exa]> | looks okay to me with t~StateT, m~Maybe |
| 2021-05-17 14:52:23 | <Cale> | empty or mempty on its own ought to be fine |
| 2021-05-17 14:52:32 | <Cale> | er |
| 2021-05-17 14:52:39 | <[exa]> | can StateT carry that? |
| 2021-05-17 14:52:45 | <Cale> | Actually, not sure about mempty, I mean mzero |
| 2021-05-17 14:53:00 | → | ddellacosta joins (~ddellacos@ool-44c73afa.dyn.optonline.net) |
| 2021-05-17 14:53:13 | <[exa]> | ah cool it has MonadFail |
| 2021-05-17 14:53:51 | <Cale> | Oh yeah, you could also use fail I suppose |
| 2021-05-17 14:54:52 | <romesrf> | i think just empty might work. at least the type system is fine with it ;) |
| 2021-05-17 14:55:04 | <romesrf> | i'll let you know soon. ty |
| 2021-05-17 14:55:35 | [exa] | stares at the Alternative (StateT s m) marked [safe], cool |
| 2021-05-17 14:56:33 | × | Guest35141 quits (~textual@zrcout.mskcc.org) (Remote host closed the connection) |
| 2021-05-17 14:56:54 | → | wroathe joins (~wroathe@c-68-54-25-135.hsd1.mn.comcast.net) |
| 2021-05-17 14:57:10 | <willardthor> | Cale geekosaur (so that I learn from this) : How come `ScopedTypeVariables` is needed? I thought that this was the default behavior in Haskell. That is: That a polymorphic function's type declaration (e.g. type of `thedef` ) binds all occurrences of polymorphic types (e.g. `v` ) that it mentions, such that any occurrence of those bound types (e.g. |
| 2021-05-17 14:57:10 | <willardthor> | `v` ) within the body of the function definition, refers to that binder (unless bound more locally). (It's reasonable of GHCI to consider that `v` could be bound to something else more locally; it's dumb that it can't see that it isn't) |
| 2021-05-17 14:57:11 | → | Alleria joins (~textual@mskresolve-a.mskcc.org) |
| 2021-05-17 14:57:15 | <[exa]> | noticing many more instances have [safe] now, I should probably upgrade ghc much more often. :D |
| 2021-05-17 14:57:25 | ← | cohn parts (~noone@unaffiliated/cohn) () |
| 2021-05-17 14:57:35 | Alleria | is now known as Guest1564 |
| 2021-05-17 14:58:07 | <Cale> | Nope, that's just not how it works. Type variables are only meaningful in the single type that's using them and don't carry over into other type signatures |
| 2021-05-17 14:58:24 | <geekosaur> | it's not the default behavior but enough people expect it that the ScopedTypeVariables extension was created |
| 2021-05-17 14:59:41 | <Cale> | Though what might be nicer than ScopedTypeVariables is being able to explicitly bind the applied type variables at the term level. Eventually that'll probably be a feature of TypeApplications, but it doesn't yet work |
| 2021-05-17 15:00:41 | <Cale> | e.g. to be able to write prettydef @t v = pretty v <+> pretty (def @t) |
| 2021-05-17 15:00:46 | <willardthor> | Cale "Only meaningful": I see; and the coercion is then a separate type signature (where an occurrence e.g. to `v` is considered a different/fresh `v` ). |
| 2021-05-17 15:01:02 | <Cale> | yeah |
| 2021-05-17 15:01:22 | <Cale> | So it's exactly the same as if you'd written any other variable name there |
| 2021-05-17 15:01:22 | <willardthor> | geekosaur This is now one of my new favorite extensions:) |
| 2021-05-17 15:02:04 | → | qwerty2o joins (~qwerty2o@46-116-99-209.bb.netvision.net.il) |
| 2021-05-17 15:03:05 | <qwerty2o> | hi im trying to creat a splitOn function |
| 2021-05-17 15:03:10 | <qwerty2o> | i got this so far |
| 2021-05-17 15:03:11 | <qwerty2o> | https://dpaste.org/ezmS#L1,3 |
| 2021-05-17 15:03:26 | <qwerty2o> | but now i want to split by two or more delimiters |
| 2021-05-17 15:03:42 | <qwerty2o> | is there an option to give break a second delimiter? |
| 2021-05-17 15:03:50 | → | ddellac__ joins (~ddellacos@86.106.143.217) |
| 2021-05-17 15:03:55 | → | LKoen joins (~LKoen@2a01cb0407597a009cf9697881694994.ipv6.abo.wanadoo.fr) |
| 2021-05-17 15:03:59 | <qwerty2o> | like break (== del1 || == del2) |
| 2021-05-17 15:04:02 | <qwerty2o> | something like that |
| 2021-05-17 15:04:29 | <qwerty2o> | or if i could go by a list or delimiters that'd be even better |
| 2021-05-17 15:04:38 | <willardthor> | Cale `TypeApplications` : nice, that would bring Haskell even closer to dependently-typed programming. |
| 2021-05-17 15:05:11 | <Cale> | qwerty2o: (\x -> x == del1 || x == del2) or (\x -> x `elem` [del1, del2]) or (`elem` [del1, del2]) |
| 2021-05-17 15:05:39 | <Cale> | willardthor: Yeah, to be clear, TypeApplications exists, just there's no pattern matching bit |
| 2021-05-17 15:05:53 | <Cale> | So you still need to use ScopedTypeVariables with it usually |
| 2021-05-17 15:06:03 | <willardthor> | Cale gotcha (y) |
| 2021-05-17 15:07:06 | <qwerty2o> | Cale, thank you sir |
All times are in UTC.