Logs: liberachat/#haskell
| 2021-07-27 08:26:29 | × | econo quits (uid147250@user/econo) (Quit: Connection closed for inactivity) |
| 2021-07-27 08:27:48 | → | acidjnk_new3 joins (~acidjnk@p200300d0c72b953020abcb826e8e1ebf.dip0.t-ipconnect.de) |
| 2021-07-27 08:28:28 | → | jumper149 joins (~jumper149@80.240.31.34) |
| 2021-07-27 08:33:17 | → | burnside_ joins (~burnsides@dhcp168-022.wadham.ox.ac.uk) |
| 2021-07-27 08:33:37 | × | cfricke quits (~cfricke@user/cfricke) (Read error: Connection reset by peer) |
| 2021-07-27 08:33:59 | × | burnsidesLlama quits (~burnsides@dhcp168-022.wadham.ox.ac.uk) (Read error: Connection reset by peer) |
| 2021-07-27 08:35:31 | × | azeem quits (~azeem@176.200.241.36) (Ping timeout: 258 seconds) |
| 2021-07-27 08:35:59 | × | fossdd quits (~fossdd@sourcehut/user/fossdd) (Ping timeout: 252 seconds) |
| 2021-07-27 08:36:09 | → | azeem joins (~azeem@176.200.241.36) |
| 2021-07-27 08:36:40 | → | fossdd joins (~fossdd@sourcehut/user/fossdd) |
| 2021-07-27 08:40:04 | × | yauhsien quits (~yauhsien@61-231-38-146.dynamic-ip.hinet.net) (Quit: Leaving...) |
| 2021-07-27 08:40:45 | × | chomwitt quits (~chomwitt@2a02:587:dc0c:8100:12c3:7bff:fe6d:d374) (Ping timeout: 268 seconds) |
| 2021-07-27 08:44:31 | → | mastarija joins (~mastarija@31.217.8.174) |
| 2021-07-27 08:44:34 | → | johnw joins (~johnw@76-234-69-149.lightspeed.frokca.sbcglobal.net) |
| 2021-07-27 08:44:34 | → | eggplantade joins (~Eggplanta@108-201-191-115.lightspeed.sntcca.sbcglobal.net) |
| 2021-07-27 08:45:28 | <mastarija> | Say that I have a type `MyType i m v`, and that type can be a functor on either i or v, how would I write an instance for functor over i? |
| 2021-07-27 08:45:42 | <mastarija> | V is easy, instance Functor (MyType i m v) |
| 2021-07-27 08:46:02 | <mastarija> | * instance Functor (MyType i m) |
| 2021-07-27 08:46:24 | <mastarija> | But what about i? Can I use some type family to "swap" the arguments? |
| 2021-07-27 08:48:42 | <thomasjm[m]> | mastarija: probably just write out the `fmap` instance explicitly? you might want https://hackage.haskell.org/package/base-4.15.0.0/docs/Data-Bifunctor.html |
| 2021-07-27 08:49:04 | × | merijn quits (~merijn@83-160-49-249.ip.xs4all.nl) (Ping timeout: 265 seconds) |
| 2021-07-27 08:49:12 | × | eggplantade quits (~Eggplanta@108-201-191-115.lightspeed.sntcca.sbcglobal.net) (Ping timeout: 250 seconds) |
| 2021-07-27 08:49:22 | <mastarija> | thomasjm[m], a... but my type is not a Bifunctor |
| 2021-07-27 08:49:37 | <mastarija> | It's either a functor on i, or a functor on v |
| 2021-07-27 08:49:42 | → | merijn joins (~merijn@83-160-49-249.ip.xs4all.nl) |
| 2021-07-27 08:50:03 | <lortabac> | mastarija: since you can't have 2 Functor instances for the same type, you need to define a newtype with a different variable order |
| 2021-07-27 08:50:40 | <mastarija> | lortabac, hm.. yes, I was hoping there could be some trick |
| 2021-07-27 08:50:59 | <lortabac> | mastarija: how would you select which instance you want? |
| 2021-07-27 08:51:16 | <mastarija> | Didn't think about that :D |
| 2021-07-27 08:52:16 | <deejaytee> | mastarija: could you explain a bit more about the underlying structure, and why that means that it's either one functor or the other? |
| 2021-07-27 08:52:55 | <deejaytee> | I don't doubt such a thing is possible, I'm just having trouble thinking of an example |
| 2021-07-27 08:53:08 | → | eggplantade joins (~Eggplanta@108-201-191-115.lightspeed.sntcca.sbcglobal.net) |
| 2021-07-27 08:53:08 | × | _bin quits (~bin@user/bin/x-1583188) (Quit: ZNC - https://znc.in) |
| 2021-07-27 08:53:15 | <mastarija> | deejaytee, it's a bit complex, but basically I have a type like either (a bit more complex) |
| 2021-07-27 08:53:21 | → | _bin joins (~bin@user/bin/x-1583188) |
| 2021-07-27 08:53:46 | <mastarija> | So I might want to fmap over left or right |
| 2021-07-27 08:54:00 | <lortabac> | isn't it the definition of a Bifunctor? |
| 2021-07-27 08:54:06 | <mastarija> | No |
| 2021-07-27 08:54:12 | <mastarija> | It can be |
| 2021-07-27 08:54:14 | → | ham joins (~ham4@user/ham) |
| 2021-07-27 08:54:17 | <mastarija> | But I don't want a bifunctor |
| 2021-07-27 08:54:29 | <lortabac> | ok, you want it to be a Functor in both cases |
| 2021-07-27 08:54:46 | <mastarija> | I want just a functor over a, and just a functor over b in `Either a b` |
| 2021-07-27 08:55:12 | <deejaytee> | well Either is a Bifunctor - it's just that lmap and rmap don't do anything |
| 2021-07-27 08:55:24 | <deejaytee> | But if your heart is set on fmap, yeah a newtype wrapper is what you'll need |
| 2021-07-27 08:55:56 | <mastarija> | Although, now that I think about selecting the right instance, I guess that function type could be the "clue" to select the right instance |
| 2021-07-27 08:56:04 | <deejaytee> | (*it's just that first and second don't do anything unless you're on the correct constructor) |
| 2021-07-27 08:56:21 | × | burnside_ quits (~burnsides@dhcp168-022.wadham.ox.ac.uk) (Remote host closed the connection) |
| 2021-07-27 08:56:23 | <mastarija> | Problem is, I want to have different Monad instances as well :D |
| 2021-07-27 08:56:29 | <mastarija> | And applicatives |
| 2021-07-27 08:56:42 | <mastarija> | So bifunctor doesn't help |
| 2021-07-27 08:57:45 | × | eggplantade quits (~Eggplanta@108-201-191-115.lightspeed.sntcca.sbcglobal.net) (Ping timeout: 258 seconds) |
| 2021-07-27 08:57:45 | <tomsmeding> | % map (Data.Bifunctor.first (+1)) [Left 2, Right 2] |
| 2021-07-27 08:57:46 | <yahb> | tomsmeding: [Left 3,Right 2] |
| 2021-07-27 08:58:04 | <deejaytee> | Yeah for your monad instance you're definitely going to want a newtype, otherwise I wager it'll be difficult to tell `do` which instance to pick, even if you find a trick to get the functor & applicative instances working |
| 2021-07-27 08:58:47 | → | dunkeln joins (~dunkeln@94.129.69.87) |
| 2021-07-27 08:59:02 | → | burnsidesLlama joins (~burnsides@dhcp168-022.wadham.ox.ac.uk) |
| 2021-07-27 09:00:19 | <mastarija> | I guess, but one can dream :D |
| 2021-07-27 09:01:18 | <deejaytee> | unless you're too cool for do notation, in which case: https://hackage.haskell.org/package/bifunctors-5.5.11/docs/Data-Bifunctor-Functor.html#t:BifunctorMonad |
| 2021-07-27 09:02:01 | → | bingruns joins (~bingruns@bxk158.neoplus.adsl.tpnet.pl) |
| 2021-07-27 09:03:24 | → | agua joins (~agua@2804:14c:8793:8e2f:39e9:c5a8:c532:7498) |
| 2021-07-27 09:03:53 | × | dunkeln quits (~dunkeln@94.129.69.87) (Ping timeout: 258 seconds) |
| 2021-07-27 09:06:43 | × | bingruns quits (~bingruns@bxk158.neoplus.adsl.tpnet.pl) (Client Quit) |
| 2021-07-27 09:06:57 | → | bingruns joins (~bingruns@bxk158.neoplus.adsl.tpnet.pl) |
| 2021-07-27 09:07:20 | × | pesada quits (~agua@2804:18:4c:684a:1:0:5b66:52cd) (Ping timeout: 256 seconds) |
| 2021-07-27 09:08:11 | × | bingruns quits (~bingruns@bxk158.neoplus.adsl.tpnet.pl) (Client Quit) |
| 2021-07-27 09:08:21 | → | bingruns joins (~bingruns@bxk158.neoplus.adsl.tpnet.pl) |
| 2021-07-27 09:09:47 | × | mei quits (~mei@user/mei) (Read error: Connection reset by peer) |
| 2021-07-27 09:10:03 | × | Erutuon quits (~Erutuon@user/erutuon) (Ping timeout: 276 seconds) |
| 2021-07-27 09:10:14 | → | mei joins (~mei@user/mei) |
| 2021-07-27 09:15:07 | × | bingruns quits (~bingruns@bxk158.neoplus.adsl.tpnet.pl) (Quit: Client closed) |
| 2021-07-27 09:26:22 | × | azeem quits (~azeem@176.200.241.36) (Ping timeout: 245 seconds) |
| 2021-07-27 09:26:49 | → | azeem joins (~azeem@176.200.241.36) |
| 2021-07-27 09:29:04 | × | fossdd quits (~fossdd@sourcehut/user/fossdd) (Ping timeout: 250 seconds) |
| 2021-07-27 09:29:25 | <tomsmeding> | why does that type class use 't' as the monad type, instead of 'm' |
| 2021-07-27 09:29:52 | <ixlun> | What's the best way to implement a fast circular buffer of fixed sized? |
| 2021-07-27 09:29:54 | × | lortabac quits (~lortabac@2a01:e0a:541:b8f0:7d8e:40bb:852a:65d0) (Ping timeout: 240 seconds) |
| 2021-07-27 09:30:12 | → | fossdd joins (~fossdd@sourcehut/user/fossdd) |
| 2021-07-27 09:30:25 | <ixlun> | So as you add one element at the head, an element gets dropped at the tail |
| 2021-07-27 09:30:44 | <tomsmeding> | ixlun: should it be functional, or can it be in ST? |
| 2021-07-27 09:30:48 | <deejaytee> | tomsmeding: I assume because it "transforms" the underlying bifunctor |
| 2021-07-27 09:31:00 | <ixlun> | Can be in ST |
| 2021-07-27 09:31:09 | <tomsmeding> | deejaytee: then I'd expect 't' to be a monad transformer :p |
| 2021-07-27 09:31:18 | <tomsmeding> | but it doesn't matter anyway |
| 2021-07-27 09:31:27 | <ixlun> | or IO |
| 2021-07-27 09:31:29 | <tomsmeding> | ixlun: then just an STArray, right? or the vector equivalent |
| 2021-07-27 09:31:36 | × | azeem quits (~azeem@176.200.241.36) (Ping timeout: 265 seconds) |
| 2021-07-27 09:31:37 | <tomsmeding> | not going to get a faster one |
| 2021-07-27 09:31:47 | → | chomwitt joins (~chomwitt@athedsl-32041.home.otenet.gr) |
| 2021-07-27 09:31:54 | <deejaytee> | agree that I'd expect a transformer, agree that it doesn't matter :P |
| 2021-07-27 09:32:18 | → | azeem joins (~azeem@176.200.241.36) |
| 2021-07-27 09:32:28 | <ixlun> | Right, so I'm looking at Data.Vector.Unboxed.Mutable |
| 2021-07-27 09:32:41 | <ixlun> | That sound about right? |
| 2021-07-27 09:32:50 | <tomsmeding> | yeah |
| 2021-07-27 09:32:58 | <tomsmeding> | if your data type can be unboxed, that is |
| 2021-07-27 09:33:08 | <tomsmeding> | I wrote this at some point for a different #haskell'er: https://gist.github.com/tomsmeding/1a9f9f6d64ab60699751c9bdeb99bc81 |
| 2021-07-27 09:33:21 | <tomsmeding> | uses array, not vector, but it should be similar |
| 2021-07-27 09:34:11 | tomsmeding | isn't sure why that declares DataKinds, it doesn't use it |
| 2021-07-27 09:35:18 | × | hnOsmium0001 quits (uid453710@id-453710.stonehaven.irccloud.com) (Quit: Connection closed for inactivity) |
| 2021-07-27 09:35:29 | → | Tuplanolla joins (~Tuplanoll@91-159-68-239.elisa-laajakaista.fi) |
All times are in UTC.