Logs: freenode/#haskell
| 2020-11-04 12:00:02 | × | BjarniRunar1 quits (~BjarniRun@84.39.116.180) () |
| 2020-11-04 12:00:12 | → | GUEST1604491197 joins (~GUEST1604@124.123.107.91) |
| 2020-11-04 12:00:28 | <tomsmeding> | though perhaps you can attempt to see head/fromMaybe/toEnum as a different "class" of partial functions than the case I described, but that's getting firmly and deeply in the subjective realm :p |
| 2020-11-04 12:00:52 | → | ahmr88 joins (~ahmr88@cpc85006-haye22-2-0-cust131.17-4.cable.virginm.net) |
| 2020-11-04 12:01:08 | <bqv> | i actually hit the problem you described earlier |
| 2020-11-04 12:01:26 | → | chaosmasttter joins (~chaosmast@p200300c4a7117c01215e340256877fbe.dip0.t-ipconnect.de) |
| 2020-11-04 12:01:27 | × | GUEST1604491197 quits (~GUEST1604@124.123.107.91) (Read error: Connection reset by peer) |
| 2020-11-04 12:01:28 | <bqv> | my solution was undefined, which is... kinda worse |
| 2020-11-04 12:01:29 | <merijn> | Enum is a terrible class anyway :p |
| 2020-11-04 12:01:37 | <merijn> | If anything I'd just recommend avoiding Enum :p |
| 2020-11-04 12:01:43 | → | GUEST1604491290 joins (~GUEST1604@124.123.107.91) |
| 2020-11-04 12:02:00 | <bqv> | as usual, next to impossible if you FFI at all |
| 2020-11-04 12:02:11 | → | kish joins (~oracle@unaffiliated/oracle) |
| 2020-11-04 12:02:27 | <merijn> | How so? |
| 2020-11-04 12:03:07 | <bqv> | C enums would have to be sent back and forth somehow |
| 2020-11-04 12:03:24 | <bqv> | any haskell sum type eventually ends up as a number |
| 2020-11-04 12:03:57 | <bqv> | you could i guess have checks at every marshal in, but that's no better than Enum with safeToEnum |
| 2020-11-04 12:04:02 | <merijn> | I fail to see how that requires the Enum class, though? |
| 2020-11-04 12:04:25 | × | GUEST1604491290 quits (~GUEST1604@124.123.107.91) (Read error: Connection reset by peer) |
| 2020-11-04 12:04:35 | <bqv> | well what would be an alternative? |
| 2020-11-04 12:05:52 | <dminuoso> | bqv: I tend to have my own Enumerable typeclass that adds a MonadFail constraint to toEnum |
| 2020-11-04 12:05:53 | → | GUEST1604491541 joins (~GUEST1604@124.123.107.91) |
| 2020-11-04 12:06:10 | <dminuoso> | For things where want to keep a mapping to numbers (usually I use this for protocol de/serializatoin) |
| 2020-11-04 12:06:16 | <merijn> | Just writing a single function to convert, safeToEnum only works for bounded types and makes a bunch of assumptions about the underlying Enum instance (and I'd be war to make any assumptions of those) |
| 2020-11-04 12:06:31 | <dminuoso> | (The reason for using a typeclass is mostly convenience, it could just be plain functions) |
| 2020-11-04 12:06:43 | → | thir joins (~thir@p200300f27f0b7e00f4e9381c2bf90854.dip0.t-ipconnect.de) |
| 2020-11-04 12:07:02 | <dminuoso> | And that typeclass is not about *enumerating* from/to, it's just for mapping into something |
| 2020-11-04 12:07:11 | <bqv> | oh yeah, just, generally i considered any function to be of vastly the same nature as Enum anyway |
| 2020-11-04 12:07:47 | × | GUEST1604491541 quits (~GUEST1604@124.123.107.91) (Remote host closed the connection) |
| 2020-11-04 12:07:51 | → | Tops2 joins (~Tobias@dyndsl-095-033-016-001.ewe-ip-backbone.de) |
| 2020-11-04 12:08:43 | <dminuoso> | bqv: class (t ~ MappedInto f, Show t) => EnumMapping f where type MappedInto t; mappingTo :: f -> t; mappingFrom :: MonadFail m => t -> m f |
| 2020-11-04 12:08:46 | <dminuoso> | Is roughly what I use |
| 2020-11-04 12:09:52 | <bqv> | pretty general, fair enough |
| 2020-11-04 12:09:54 | <dminuoso> | oh heh, that hsould be `type MappedInto s` |
| 2020-11-04 12:10:09 | <dminuoso> | or f, rather. bah, my code is not copy pastable for other reasons |
| 2020-11-04 12:10:20 | → | GUEST91807 joins (~GUEST9180@124.123.107.91) |
| 2020-11-04 12:10:30 | <bqv> | curious why the Show constraint at that level |
| 2020-11-04 12:11:02 | × | ahmr88 quits (~ahmr88@cpc85006-haye22-2-0-cust131.17-4.cable.virginm.net) (Remote host closed the connection) |
| 2020-11-04 12:11:04 | × | thir quits (~thir@p200300f27f0b7e00f4e9381c2bf90854.dip0.t-ipconnect.de) (Ping timeout: 244 seconds) |
| 2020-11-04 12:11:52 | → | Chi1thangoo joins (~Chi1thang@87.112.60.168) |
| 2020-11-04 12:11:57 | <merijn> | For the error to MonadFail, presumably |
| 2020-11-04 12:12:04 | <dminuoso> | Mmm. Good question, I guess there is no need for it there |
| 2020-11-04 12:12:15 | → | bitmagie joins (~Thunderbi@200116b80654c700253602a817d4606f.dip.versatel-1u1.de) |
| 2020-11-04 12:12:44 | <dminuoso> | bqv: The reason I have it that general, is because Im writing a protocol library here, so some enums are mapped into Word8, others into Word32, etc.. |
| 2020-11-04 12:12:53 | <dminuoso> | (So that helper typeclass is then used in my Get/Put code) |
| 2020-11-04 12:13:07 | <bqv> | ah fair |
| 2020-11-04 12:13:36 | <dminuoso> | It was either that, or sprinkling fromIntegral left and right, not knowing if I accidentally narrow data. |
| 2020-11-04 12:13:50 | <merijn> | Or...just write individual Get/Put operations? >.> |
| 2020-11-04 12:14:07 | <dminuoso> | merijn: That would have worked too, of course. The typeclass was really just for convenience. |
| 2020-11-04 12:14:37 | <dminuoso> | It reduces some boilerplate in some areas. :) |
| 2020-11-04 12:14:37 | × | GUEST91807 quits (~GUEST9180@124.123.107.91) (Ping timeout: 260 seconds) |
| 2020-11-04 12:14:38 | <merijn> | dminuoso: The convenience of being unable to have multiple versions in your codebase? >.> |
| 2020-11-04 12:14:45 | <dminuoso> | merijn: That's perfectly fine for me. |
| 2020-11-04 12:14:51 | <dminuoso> | It's an internal typeclass I dont ever expose. |
| 2020-11-04 12:15:07 | <dminuoso> | And these things do *not* ever change |
| 2020-11-04 12:15:24 | <bqv> | merijn: as a fan of a strictly typed language, surely you appreciate restriction :D |
| 2020-11-04 12:15:43 | <dminuoso> | bqv: No, it's an annoying restriction since if you ever have multiple protocol versions, you need to start using newtype wrappers |
| 2020-11-04 12:15:56 | <dminuoso> | But in my case, the protocol is standardized and hasnt changed in 20 years. :p |
| 2020-11-04 12:16:02 | <merijn> | You fool! You fell victim to one of the classic blunders - the most famous of which is "never get involved in a land war in Asia" and "Never go in against a Sicilian when death is on the line", but only slightly less well-known is this: "Never use typeclasses for (de)serialisation"! Ha ha ha ha ha ha ha! Ha ha ha ha ha ha ha! |
| 2020-11-04 12:16:03 | <dminuoso> | (It was only ever ammended) |
| 2020-11-04 12:16:07 | <bqv> | heh |
| 2020-11-04 12:16:19 | <dminuoso> | merijn: I dont use typeclasses for get/put itself. |
| 2020-11-04 12:16:23 | <dminuoso> | Or actually, that's not true |
| 2020-11-04 12:16:28 | <dminuoso> | I have my own Get/Put typeclasses! |
| 2020-11-04 12:16:30 | <dminuoso> | Again, for convenience |
| 2020-11-04 12:16:46 | <dminuoso> | But I know what price I pay, the cost is lower than the extra effort and annoyance from writing functions instead. |
| 2020-11-04 12:16:51 | → | yoyo joins (50a46f47@80-164-111-71-dynamic.dk.customer.tdc.net) |
| 2020-11-04 12:17:08 | <dminuoso> | There is ever only a single protocol encoding of `Foo |
| 2020-11-04 12:17:17 | <dminuoso> | And, should it ever be different, I can turn it into functions easily |
| 2020-11-04 12:18:23 | × | zfnmxt quits (~zfnmxt@unaffiliated/zfnmxt) (Quit: Bye!) |
| 2020-11-04 12:18:49 | × | todda7 quits (~torstein@ppp-2-84-30-242.home.otenet.gr) (Ping timeout: 260 seconds) |
| 2020-11-04 12:20:01 | hackage | servant-multipart 0.12 - multipart/form-data (e.g file upload) support for servant https://hackage.haskell.org/package/servant-multipart-0.12 (maksbotan) |
| 2020-11-04 12:20:13 | → | zfnmxt joins (~zfnmxt@unaffiliated/zfnmxt) |
| 2020-11-04 12:20:29 | × | avdb quits (~avdb@ip-62-235-73-30.dsl.scarlet.be) (Quit: WeeChat 2.9) |
| 2020-11-04 12:21:39 | × | bitmagie quits (~Thunderbi@200116b80654c700253602a817d4606f.dip.versatel-1u1.de) (Quit: bitmagie) |
| 2020-11-04 12:21:55 | → | vfaronov joins (~vfaronov@broadband-95-84-210-78.ip.moscow.rt.ru) |
| 2020-11-04 12:23:26 | × | chaosmasttter quits (~chaosmast@p200300c4a7117c01215e340256877fbe.dip0.t-ipconnect.de) (Ping timeout: 264 seconds) |
| 2020-11-04 12:24:30 | → | asthasr joins (~asthasr@162.210.29.120) |
| 2020-11-04 12:28:46 | → | knupfer joins (~Thunderbi@dynamic-046-114-148-101.46.114.pool.telefonica.de) |
| 2020-11-04 12:30:01 | → | bitmagie joins (~Thunderbi@200116b80654c700253602a817d4606f.dip.versatel-1u1.de) |
| 2020-11-04 12:30:17 | → | elfets joins (~elfets@ip-37-201-23-96.hsi13.unitymediagroup.de) |
| 2020-11-04 12:31:05 | → | asthasr_ joins (~asthasr@162.210.29.120) |
| 2020-11-04 12:31:20 | × | asthasr_ quits (~asthasr@162.210.29.120) (Client Quit) |
| 2020-11-04 12:36:40 | → | avdb joins (~avdb@ip-62-235-73-30.dsl.scarlet.be) |
| 2020-11-04 12:36:40 | × | knupfer quits (~Thunderbi@dynamic-046-114-148-101.46.114.pool.telefonica.de) (Read error: Connection reset by peer) |
| 2020-11-04 12:37:18 | <idnar> | merijn: hahaha |
| 2020-11-04 12:37:26 | → | ahmr88 joins (~ahmr88@cpc85006-haye22-2-0-cust131.17-4.cable.virginm.net) |
| 2020-11-04 12:38:18 | × | bitmagie quits (~Thunderbi@200116b80654c700253602a817d4606f.dip.versatel-1u1.de) (Quit: bitmagie) |
| 2020-11-04 12:38:45 | <idnar> | @type \f x -> coerce (f (coerce x)) |
| 2020-11-04 12:38:46 | <lambdabot> | error: |
| 2020-11-04 12:38:46 | <lambdabot> | • Variable not in scope: coerce :: t1 -> t3 |
| 2020-11-04 12:38:47 | <lambdabot> | • Perhaps you meant ‘coerced’ (imported from Control.Lens) |
| 2020-11-04 12:38:49 | × | nbloomf quits (~nbloomf@2600:1700:ad14:3020:fc37:ff3f:9c12:2922) (Quit: My MacBook has gone to sleep. ZZZzzz…) |
| 2020-11-04 12:39:07 | → | GUEST93534 joins (~GUEST9353@124.123.107.91) |
| 2020-11-04 12:39:11 | <bqv> | unsafeCoerce? |
| 2020-11-04 12:39:21 | → | bitmagie joins (~Thunderbi@200116b80654c700253602a817d4606f.dip.versatel-1u1.de) |
| 2020-11-04 12:39:28 | <merijn> | unsafeCoerce is different and, well, unsafe :p |
| 2020-11-04 12:39:35 | <idnar> | no, I want the safe one |
| 2020-11-04 12:39:37 | <bqv> | thought that was his plan |
| 2020-11-04 12:39:39 | <bqv> | fair |
All times are in UTC.