Logs: liberachat/#haskell
| 2021-07-03 23:41:22 | <sciencentistguy> | i'm trying to generalise over binary operators in general |
| 2021-07-03 23:41:46 | <sciencentistguy> | so i want a function i can pass `(*)` or `mod` or anthing of type `a->a->a` |
| 2021-07-03 23:42:27 | × | wootehfoot quits (~wootehfoo@user/wootehfoot) (Quit: Leaving) |
| 2021-07-03 23:42:28 | <hpc> | without allowing something like const that's a -> b -> a? |
| 2021-07-03 23:42:57 | <sciencentistguy> | i don't need to disallow that |
| 2021-07-03 23:45:20 | <sciencentistguy> | so i have this signature at the moment: |
| 2021-07-03 23:45:23 | <sciencentistguy> | `lvBinaryOp :: (forall a. a -> a -> a) -> LispValue -> LispValue -> Maybe LispValue` |
| 2021-07-03 23:45:46 | <sciencentistguy> | and both of these fail to compile: `a = lvBinaryOp (+); b = lvBinaryOp (/)` |
| 2021-07-03 23:46:09 | <keltono> | what's the error? |
| 2021-07-03 23:46:12 | <sciencentistguy> | but their error messages suggest a fix (add the constraint to the signature of the function) that are mutually exclusive |
| 2021-07-03 23:46:41 | <shachaf> | Do you need the argument to be polymorphic? How are you using it? |
| 2021-07-03 23:46:44 | × | favonia quits (~favonia@user/favonia) (Ping timeout: 256 seconds) |
| 2021-07-03 23:46:45 | → | nate1 joins (~nate@108-233-125-227.lightspeed.sntcca.sbcglobal.net) |
| 2021-07-03 23:46:59 | <sciencentistguy> | keltono: "No instance for (Num a) arising from a use of ‘+’" and "No instance for (Fractional a) arising from a use of ‘/’" |
| 2021-07-03 23:47:27 | <sciencentistguy> | shachaf: i'm using it as a binary operator to number values (either an Integer, a Ratio, or a Double) |
| 2021-07-03 23:48:10 | <shachaf> | Well, it sounds like the problem here isn't with the type checker, it's with what you're trying to do. |
| 2021-07-03 23:48:28 | <shachaf> | Forget polymorphism for a moment. Imagine you had (+) :: Int -> Int -> Int and (/) :: Double -> Double -> Double |
| 2021-07-03 23:48:51 | <shachaf> | What would you want to do there? |
| 2021-07-03 23:48:59 | <sciencentistguy> | here's the context (here i just gave up and made 3 functions for the 3 different constraints i need to solve, but i really don't like the code duplication that causes) |
| 2021-07-03 23:49:01 | <sciencentistguy> | https://github.com/Sciencentistguy/haskeme/blob/654caa3bf770324de545bc23517786970d4bd40b/src/Evaluator.hs#L32 |
| 2021-07-03 23:49:35 | → | favonia joins (~favonia@user/favonia) |
| 2021-07-03 23:49:55 | <sciencentistguy> | s/3/2, lvIntegralOp is actually dead code |
| 2021-07-03 23:52:08 | × | nate1 quits (~nate@108-233-125-227.lightspeed.sntcca.sbcglobal.net) (Ping timeout: 272 seconds) |
| 2021-07-03 23:52:26 | × | betelgeuse quits (~john2gb@94-225-47-8.access.telenet.be) (Quit: The Lounge - https://thelounge.chat) |
| 2021-07-03 23:53:43 | <monochrom> | Nothing says you can't invent your own type class that fits LispValue better. |
| 2021-07-03 23:54:34 | × | azeem quits (~azeem@176.200.221.91) (Ping timeout: 265 seconds) |
| 2021-07-03 23:54:44 | <monochrom> | But first of all if you truly understood parametricity then you would not begin with "forall a. a->a->a" which cannot possibly do any arithmetic. |
| 2021-07-03 23:54:57 | × | stevenxl quits (~stevenlei@68.235.43.93) (Ping timeout: 258 seconds) |
| 2021-07-03 23:55:37 | <monochrom> | At best it has to be "forall a. C a => a -> a -> a" where C is a class that represents desired arithmetic. |
| 2021-07-03 23:56:00 | <sciencentistguy> | yeah that's what i've done in the actual code |
| 2021-07-03 23:56:04 | → | machinedgod joins (~machinedg@24.105.81.50) |
| 2021-07-03 23:57:27 | <monochrom> | But in all likelihood LispValue does not contain polymorphic content so there is no real reason to want polymorphic arithmetic operations on them. |
| 2021-07-03 23:58:10 | × | wolfshappen quits (~waff@irc.furworks.de) (Remote host closed the connection) |
| 2021-07-03 23:58:18 | <sciencentistguy> | I don't think i understand what you mean |
| 2021-07-03 23:58:28 | → | Philonous_ joins (~Philonous@user/philonous) |
| 2021-07-03 23:58:51 | <monochrom> | OK, what is the definition of LispValue, really? |
| 2021-07-03 23:59:03 | × | ChaiTRex quits (~ChaiTRex@user/chaitrex) (Ping timeout: 244 seconds) |
| 2021-07-03 23:59:06 | × | Philonous quits (~Philonous@user/philonous) (Read error: Connection reset by peer) |
| 2021-07-03 23:59:09 | <sciencentistguy> | https://github.com/Sciencentistguy/haskeme/blob/654caa3bf770324de545bc23517786970d4bd40b/src/Types.hs#L10 |
| 2021-07-03 23:59:24 | → | ChaiTRex joins (~ChaiTRex@user/chaitrex) |
| 2021-07-03 23:59:26 | → | wolfshappen joins (~waff@irc.furworks.de) |
| 2021-07-04 00:00:19 | × | o quits (~niko@libera/staff/niko) (Ping timeout: 622 seconds) |
| 2021-07-04 00:00:19 | <monochrom> | So you just need (SchemeNumber -> SchemeNumber -> SchemeNumber) not (forall whatever) |
| 2021-07-04 00:00:38 | <sciencentistguy> | that would work i guess |
| 2021-07-04 00:00:40 | → | azeem joins (~azeem@176.200.221.91) |
| 2021-07-04 00:00:48 | <sciencentistguy> | but that means i can't use `(+)` |
| 2021-07-04 00:00:56 | <sciencentistguy> | and that |
| 2021-07-04 00:00:59 | <sciencentistguy> | whoops |
| 2021-07-04 00:01:46 | <sciencentistguy> | the thing i'm trying to achieve here is "i want a function that takes a binary operator and applies it to the contents of two SchemeNumbers and returns a new SchemeNumber" |
| 2021-07-04 00:02:02 | <monochrom> | You cannot use (+) as soon as you try "(1 :: Integer) + (2 :: Rational)" already. Your cause is lost even before you began. |
| 2021-07-04 00:02:32 | <monochrom> | You already have to code up 8 cases of plus for SchemeNumber. May as well actually give it a name. |
| 2021-07-04 00:03:21 | → | merijn joins (~merijn@83-160-49-249.ip.xs4all.nl) |
| 2021-07-04 00:03:37 | <sciencentistguy> | i'd quite like to avoid having to duplicate that massive caseof for each operator though |
| 2021-07-04 00:03:41 | <sciencentistguy> | but i think that might be unavoidable |
| 2021-07-04 00:04:03 | <monochrom> | This is why Haskell doesn't go with Scheme's number hierarchy. |
| 2021-07-04 00:04:25 | <sciencentistguy> | yeah from what i've seen scheme's number hierarchy is a *mess* |
| 2021-07-04 00:04:56 | <monochrom> | (+) :: Num a => a->a->a because the alternative (Num a, Num b, Num c) => a -> b -> c would be madness, as Scheme has proved. |
| 2021-07-04 00:05:28 | → | nate1 joins (~nate@108-233-125-227.lightspeed.sntcca.sbcglobal.net) |
| 2021-07-04 00:06:33 | → | Pickchea joins (~private@user/pickchea) |
| 2021-07-04 00:08:38 | × | fengctor quits (~fengctor@bras-base-ngflon0508w-grc-11-76-68-2-143.dsl.bell.ca) (Read error: Connection reset by peer) |
| 2021-07-04 00:11:30 | <monochrom> | "The best way to win is not to play" applies. |
| 2021-07-04 00:14:06 | × | cheater quits (~Username@user/cheater) (Ping timeout: 252 seconds) |
| 2021-07-04 00:14:52 | × | nate1 quits (~nate@108-233-125-227.lightspeed.sntcca.sbcglobal.net) (Ping timeout: 265 seconds) |
| 2021-07-04 00:15:20 | → | stevenxl joins (~stevenlei@68.235.43.93) |
| 2021-07-04 00:16:12 | × | azeem quits (~azeem@176.200.221.91) (Ping timeout: 256 seconds) |
| 2021-07-04 00:16:25 | → | azeem joins (~azeem@176.200.221.91) |
| 2021-07-04 00:18:15 | → | cheater1__ joins (~Username@user/cheater) |
| 2021-07-04 00:18:34 | × | azeem quits (~azeem@176.200.221.91) (Read error: Connection reset by peer) |
| 2021-07-04 00:18:42 | → | yauhsien joins (~yauhsien@61-231-45-160.dynamic-ip.hinet.net) |
| 2021-07-04 00:18:47 | cheater1__ | is now known as cheater |
| 2021-07-04 00:19:44 | → | azeem joins (~azeem@dynamic-adsl-84-220-226-129.clienti.tiscali.it) |
| 2021-07-04 00:19:52 | × | stevenxl quits (~stevenlei@68.235.43.93) (Ping timeout: 258 seconds) |
| 2021-07-04 00:24:26 | × | cheater quits (~Username@user/cheater) (Ping timeout: 272 seconds) |
| 2021-07-04 00:24:40 | → | cheater joins (~Username@user/cheater) |
| 2021-07-04 00:25:06 | × | yauhsien quits (~yauhsien@61-231-45-160.dynamic-ip.hinet.net) (Ping timeout: 252 seconds) |
| 2021-07-04 00:26:08 | × | Tuplanolla quits (~Tuplanoll@91-159-68-239.elisa-laajakaista.fi) (Quit: Leaving.) |
| 2021-07-04 00:31:29 | → | Guest1 joins (~Guest1@2001:e68:543d:32f5:36dd:5585:5f23:735a) |
| 2021-07-04 00:32:08 | <Guest1> | can someone explain the zero for the error monad? I don't understand what is represented by "empty error". don't this depends on the kind of error itself? |
| 2021-07-04 00:33:56 | × | cheater quits (~Username@user/cheater) (Ping timeout: 272 seconds) |
| 2021-07-04 00:34:09 | × | wrunt quits (~ajc@vmx14030.hosting24.com.au) (Quit: WeeChat 1.9.1) |
| 2021-07-04 00:34:10 | → | cheater joins (~Username@user/cheater) |
| 2021-07-04 00:34:51 | <Axman6> | Guest1: can you link to what you're referring to? |
| 2021-07-04 00:35:37 | <Guest1> | scroll down to the The Error Monad here https://wiki.haskell.org/All_About_Monads |
| 2021-07-04 00:37:03 | <Guest1> | also, is zvon.org the man equivalent for haskell? google shows it more often than haskell.wiki, but this isn't always a good thing (e.g. cplusplus is preferred over cppreference when the latter is far superior) |
| 2021-07-04 00:37:33 | <Axman6> | I've never heard of zvon.org |
| 2021-07-04 00:37:53 | × | merijn quits (~merijn@83-160-49-249.ip.xs4all.nl) (Ping timeout: 258 seconds) |
| 2021-07-04 00:38:10 | <sciencentistguy> | Guest1: off topic, but i've never heard anyone say that cplusplus.com is better than cppreference |
| 2021-07-04 00:38:30 | <Guest1> | no, i meant to say google prefers it more, but cppreference is superior |
| 2021-07-04 00:39:45 | <Axman6> | I've never used the MonadError class, and I wouldn't be surprised if it's no longer a recommended way to deal with errors. Generally I used ExceptT, that seems to cover all my error needs and is well supported by the ecosystem |
| 2021-07-04 00:40:05 | <geekosaur> | ExceptT superseded ErrorT some time back, yes |
| 2021-07-04 00:42:51 | → | LukeHoersten joins (~LukeHoers@user/lukehoersten) |
| 2021-07-04 00:42:59 | → | nate1 joins (~nate@108-233-125-227.lightspeed.sntcca.sbcglobal.net) |
| 2021-07-04 00:43:20 | × | LukeHoersten quits (~LukeHoers@user/lukehoersten) (Client Quit) |
| 2021-07-04 00:43:27 | → | thornAvery joins (~thorn@121.220.33.124) |
| 2021-07-04 00:44:01 | × | sciencentistguy quits (~sciencent@hacksoc/ordinary-member) (Ping timeout: 258 seconds) |
| 2021-07-04 00:47:06 | × | pera quits (~pera@user/pera) (Ping timeout: 252 seconds) |
| 2021-07-04 00:48:47 | × | nate1 quits (~nate@108-233-125-227.lightspeed.sntcca.sbcglobal.net) (Ping timeout: 268 seconds) |
| 2021-07-04 00:49:20 | × | eggplantade quits (~Eggplanta@2600:1700:bef1:5e10:5061:15ea:118b:e58d) (Remote host closed the connection) |
| 2021-07-04 00:49:28 | → | wrunt joins (~ajc@vmx14030.hosting24.com.au) |
| 2021-07-04 00:49:59 | → | eggplantade joins (~Eggplanta@2600:1700:bef1:5e10:5061:15ea:118b:e58d) |
All times are in UTC.