Logs: freenode/#haskell
| 2020-11-17 13:22:28 | <dminuoso> | % (1, "str, 123, 'a') ^. _2 |
| 2020-11-17 13:22:29 | <yahb> | dminuoso: ; <interactive>:159:26: error: lexical error in string/character literal at end of input |
| 2020-11-17 13:22:31 | → | m0b10s joins (53dff9cb@gateway/web/cgi-irc/kiwiirc.com/ip.83.223.249.203) |
| 2020-11-17 13:22:35 | <dminuoso> | % (1, "str", 123, 'a') ^. _2 |
| 2020-11-17 13:22:35 | <yahb> | dminuoso: "str" |
| 2020-11-17 13:22:37 | <dminuoso> | m0b10s: This? |
| 2020-11-17 13:23:37 | → | PacoV joins (~pcoves@16.194.31.93.rev.sfr.net) |
| 2020-11-17 13:23:42 | <PacoV> | Hey again! |
| 2020-11-17 13:24:04 | <hc> | % :t (^.) |
| 2020-11-17 13:24:04 | <yahb> | hc: forall {s} {a}. s -> Getting a s a -> a |
| 2020-11-17 13:24:16 | × | kritzefitz quits (~kritzefit@fw-front.credativ.com) (Read error: Connection reset by peer) |
| 2020-11-17 13:24:19 | <hc> | dminuoso: this will fail hard when the types don't match? |
| 2020-11-17 13:24:27 | <hc> | % (1, "str") ^. _1 == "foo" |
| 2020-11-17 13:24:27 | <yahb> | hc: ; <interactive>:162:2: error:; * No instance for (Num [Char]) arising from the literal `1'; * In the expression: 1; In the first argument of `(^.)', namely `(1, "str")'; In the first argument of `(==)', namely `(1, "str") ^. _1' |
| 2020-11-17 13:24:29 | <hc> | ah :) |
| 2020-11-17 13:24:44 | <m0b10s> | diminuoso, it’s that, but in a funcion... i think the “maybe” type is what i’m looking for! =) |
| 2020-11-17 13:24:54 | → | prez joins (~prez@unaffiliated/prez) |
| 2020-11-17 13:24:57 | → | kritzefitz joins (~kritzefit@fw-front.credativ.com) |
| 2020-11-17 13:24:58 | <m0b10s> | ty hc |
| 2020-11-17 13:25:18 | <PacoV> | Thanks to you I was able to write http://ix.io/2EsV/haskell which is supposed to be a clean rewrite at my take in I18n of Hakyll that you can find here https://gitlab.com/swi18ng/swi18ng |
| 2020-11-17 13:25:33 | <dminuoso> | m0b10s: well you can just |
| 2020-11-17 13:25:41 | <PacoV> | Now, the real question : why is the new code failing on yaml parsing? |
| 2020-11-17 13:25:42 | <dminuoso> | % getFirst = (^. _1) |
| 2020-11-17 13:25:43 | <yahb> | dminuoso: |
| 2020-11-17 13:25:46 | <dminuoso> | % :t getFirst -- m0b10s |
| 2020-11-17 13:25:46 | <yahb> | dminuoso: forall {s} {b}. Field1 s s b b => s -> b |
| 2020-11-17 13:25:52 | <xerox_> | curl ghcup ... Unknown architecture: arm64 ... aw :| |
| 2020-11-17 13:25:56 | × | enoq quits (~textual@194-208-146-143.lampert.tv) (Ping timeout: 240 seconds) |
| 2020-11-17 13:25:57 | <dminuoso> | Admittedly, the type is awkward, but it works! |
| 2020-11-17 13:26:42 | → | LaserShark joins (~LaserShar@s91904426.blix.com) |
| 2020-11-17 13:26:53 | <dminuoso> | hc: What do you mean "fail hard"? |
| 2020-11-17 13:27:08 | <p0a> | will `data List = Null | List a (List b)' with your own (!!) for it work? |
| 2020-11-17 13:27:13 | <hc> | m0b10s: have a look at https://hackage.haskell.org/package/vault , that's where i got the idea |
| 2020-11-17 13:27:23 | <maerwald> | xerox_: wip |
| 2020-11-17 13:27:28 | <hc> | dminuoso: I mean a run time error, I guess |
| 2020-11-17 13:27:33 | <dminuoso> | p0a: If you implement a Field1 instance for it, sure |
| 2020-11-17 13:27:42 | <Orbstheorem> | Hi o/ Why are ReaderT classes injective? I would like to run two Readers under the same monadstack. |
| 2020-11-17 13:27:46 | <xerox_> | maerwald: makes sense :) |
| 2020-11-17 13:27:49 | <maerwald> | xerox_: https://gitlab.haskell.org/haskell/ghcup-hs/-/issues/12 |
| 2020-11-17 13:27:51 | <dminuoso> | Orbstheorem: Because newtypes are injective? |
| 2020-11-17 13:28:37 | <dminuoso> | Orbstheorem: Is "injective" really the word you mean to use here? |
| 2020-11-17 13:28:59 | <dminuoso> | In principle, you can run two ReaderT if you want, nothing prevents you from that. |
| 2020-11-17 13:29:03 | → | enoq joins (~textual@194-208-146-143.lampert.tv) |
| 2020-11-17 13:29:50 | <prez> | @free x :: (((a -> b) -> b) -> c) -> c |
| 2020-11-17 13:29:50 | <lambdabot> | (forall q f1. (forall f2 f3. g . f2 = f3 . f => g (q f2) = f1 f3) => h (k q) = p f1) => h (x k) = x p |
| 2020-11-17 13:30:02 | <dminuoso> | Orbstheorem: It's probably better to just use `ReaderT (e1, e2)` instead of multiple ReaderT though |
| 2020-11-17 13:30:09 | <Orbstheorem> | dminuoso: Maybe injective is not the right word then. I see `MonadReader r m | m -> r` in the class definition. |
| 2020-11-17 13:30:14 | <dminuoso> | That's a functional dependency |
| 2020-11-17 13:30:22 | <Orbstheorem> | Oh, my bad. |
| 2020-11-17 13:30:25 | <dminuoso> | Also note that MonadReader /= ReaderT |
| 2020-11-17 13:30:34 | <dminuoso> | Albeit related, they are very much different things |
| 2020-11-17 13:30:53 | <Orbstheorem> | Yes, I'm probably a bit distracted :( |
| 2020-11-17 13:31:16 | <dminuoso> | Orbstheorem: Anyway. Use ReaderT with a tuple. |
| 2020-11-17 13:31:23 | <dminuoso> | Or data if you have even more things |
| 2020-11-17 13:31:27 | <Orbstheorem> | Anyways, I want to run `MonadReader Foo m` and `MonadReader Bar m` under the same monad stack. |
| 2020-11-17 13:32:00 | <dminuoso> | data Env = Env { envA :: A, envB :: B, envC :: C }; newtype T a = T { runT :: ReaderT Env (...) } |
| 2020-11-17 13:32:07 | <dminuoso> | Orbstheorem: ^- use that. either with data or (,) |
| 2020-11-17 13:32:38 | <dminuoso> | You can mix that with lens/optics and classy lenses (or at least mimic it) for convenient access |
| 2020-11-17 13:32:48 | <dminuoso> | say |
| 2020-11-17 13:32:50 | <p0a> | m0b10s: right, so you can stack tuples like (1, ('a', ("b", ⊥))) and then write (!!) 0 (x,_) = x ; (!!) n (_, xs) = !! (n - 1) xs |
| 2020-11-17 13:32:55 | <reactormonk> | If I have a Recursive and a Corecursive instance for my AST structure (with recursion-schemes) can I write a Traversal' lens with these? |
| 2020-11-17 13:33:06 | × | nbloomf quits (~nbloomf@2600:1700:ad14:3020:5d4c:3718:c0a8:9f94) (Quit: My MacBook has gone to sleep. ZZZzzz…) |
| 2020-11-17 13:33:37 | <Orbstheorem> | Maybe there's something I fail to see, but that would imply that my consumers need to be aware of the structure of `Env` instead of just its components. |
| 2020-11-17 13:34:08 | → | Sanchayan joins (~Sanchayan@122.182.198.33) |
| 2020-11-17 13:34:13 | <dminuoso> | Orbstheorem: It depends, either they need to be aware of Env, or you can use classy lenses (or something akin to them) |
| 2020-11-17 13:34:17 | <dminuoso> | so say |
| 2020-11-17 13:34:34 | <dminuoso> | % data Foo { _fooInt :: Int; _fooChar :: Char } |
| 2020-11-17 13:34:34 | <yahb> | dminuoso: ; <interactive>:165:26: error: parse error on input `;' |
| 2020-11-17 13:34:41 | <dminuoso> | % data Foo = Foo { _fooInt :: Int; _fooChar :: Char } |
| 2020-11-17 13:34:41 | <yahb> | dminuoso: ; <interactive>:166:32: error: parse error on input `;' |
| 2020-11-17 13:34:45 | × | Sanchayan quits (~Sanchayan@122.182.198.33) (Remote host closed the connection) |
| 2020-11-17 13:34:52 | <dminuoso> | % data Foo = Foo { _fooInt :: Int, _fooChar :: Char } |
| 2020-11-17 13:34:53 | <yahb> | dminuoso: |
| 2020-11-17 13:34:58 | <m0b10s> | p0a, what would be the signature in that case? |
| 2020-11-17 13:35:11 | × | vicfred quits (~vicfred@unaffiliated/vicfred) (Quit: Leaving) |
| 2020-11-17 13:35:15 | → | brodie_ joins (~brodie@207.53.253.137) |
| 2020-11-17 13:35:35 | → | son0p joins (~son0p@181.136.122.143) |
| 2020-11-17 13:35:42 | <dminuoso> | % $(makeLenses ''Foo) |
| 2020-11-17 13:35:42 | <yahb> | dminuoso: ; <interactive>:173:3: error:; * Couldn't match type `[Dec]' with `Exp'; Expected type: ExpQ; Actual type: DecsQ; * In the expression: makeLenses ''Foo; In the untyped splice: $(makeLenses ''Foo) |
| 2020-11-17 13:35:50 | brodie_ | is now known as brodie |
| 2020-11-17 13:36:11 | <dminuoso> | Orbstheorem: err, see https://hackage.haskell.org/package/optics-th-0.3.0.2/docs/Optics-TH.html#v:makeClassy |
| 2020-11-17 13:36:13 | <Axman6> | Orbstheorem: if you go the lens route, you end up with code that looks like: foo :: (HadFoo r, HasBar r, MonadReader r m) => m Thing, which you can then access (assuming you have used classy lenses) with do theFoo <- view foo; theBar <- view bar |
| 2020-11-17 13:36:29 | <p0a> | m0b10s: oh yeah, of course that is the issue :) Sorry, my solution doesn't work |
| 2020-11-17 13:36:46 | <Orbstheorem> | Axman6: Yes, that's what I feared. |
| 2020-11-17 13:36:51 | → | acarrico joins (~acarrico@dhcp-68-142-39-249.greenmountainaccess.net) |
| 2020-11-17 13:36:58 | <dminuoso> | Orbstheorem: You can mimic classy lenses without going all in on lenses. |
| 2020-11-17 13:37:02 | <dminuoso> | Say by writing |
| 2020-11-17 13:37:09 | × | brodie quits (~brodie@207.53.253.137) (Client Quit) |
| 2020-11-17 13:37:16 | <dminuoso> | class HasFoo e where foo :: e -> Foo |
| 2020-11-17 13:37:22 | <dminuoso> | class HasBar e where bar :: e -> Bar |
| 2020-11-17 13:37:26 | <Axman6> | it's quite pleasant to use, because your code only declares what parts of the environment it needs to know about, and can't access anything it doesn't declare, meaning you know know more about what your code can do, and you don't need to define a data type which everything depends on |
| 2020-11-17 13:37:27 | <Orbstheorem> | Yes, I've manually implemented it with `MonadReader a m, Convertible a Foo` in the past. |
| 2020-11-17 13:37:34 | <dminuoso> | And then you can just write `do f <- asks foo` |
| 2020-11-17 13:37:42 | <dminuoso> | No lens needed, same idea |
| 2020-11-17 13:38:05 | <Orbstheorem> | Oh well. |
| 2020-11-17 13:38:09 | <Orbstheorem> | Thanks ^^ |
| 2020-11-17 13:38:23 | <Orbstheorem> | I think I'll go the classy way just to learn lenses. |
| 2020-11-17 13:38:48 | <xerox_> | maerwald: was it you that posted ghc-9.1.0.20201110-aarch-apple-darwin.tar.xz? |
| 2020-11-17 13:39:08 | <maerwald> | posted? |
| 2020-11-17 13:39:14 | × | m0b10s quits (53dff9cb@gateway/web/cgi-irc/kiwiirc.com/ip.83.223.249.203) (Quit: Connection closed) |
All times are in UTC.