Logs: freenode/#haskell
| 2020-10-18 00:14:29 | <koz_> | christo: Paste the code again? |
| 2020-10-18 00:14:36 | <ski> | er, sorry |
| 2020-10-18 00:14:39 | <ski> | christo ^ |
| 2020-10-18 00:14:47 | × | wroathe quits (~wroathe@c-68-54-25-135.hsd1.mn.comcast.net) (Ping timeout: 258 seconds) |
| 2020-10-18 00:14:52 | <christo> | • No instance for (RealFrac Integer) arising from a use of ‘floor’ |
| 2020-10-18 00:14:55 | <christo> | ooops sorry |
| 2020-10-18 00:15:15 | <koz_> | christo: You don't need floor in this case then. |
| 2020-10-18 00:15:18 | <koz_> | :t floor |
| 2020-10-18 00:15:20 | <lambdabot> | (RealFrac a, Integral b) => a -> b |
| 2020-10-18 00:15:28 | <Axman6> | floor also doesn['t wokr on Integers |
| 2020-10-18 00:15:30 | → | conal joins (~conal@64.71.133.70) |
| 2020-10-18 00:15:32 | <christo> | https://paste.tomsmeding.com/QutEatIe#file-1 |
| 2020-10-18 00:15:40 | <koz_> | You don't have a RealFrac anything, since if you use div, you don't get a fractional thing back. |
| 2020-10-18 00:15:42 | <ski> | christo : `fromInteger' can be used to convert from `Integer' to another numeric type |
| 2020-10-18 00:15:51 | <Axman6> | > 13 `div` 3 |
| 2020-10-18 00:15:53 | <lambdabot> | 4 |
| 2020-10-18 00:15:55 | × | elliott_ quits (~elliott_@pool-108-51-141-12.washdc.fios.verizon.net) (Read error: Connection reset by peer) |
| 2020-10-18 00:16:02 | <christo> | :t fromInteger |
| 2020-10-18 00:16:04 | <lambdabot> | Num a => Integer -> a |
| 2020-10-18 00:16:07 | × | ephemera_ quits (~E@122.34.1.187) (Remote host closed the connection) |
| 2020-10-18 00:16:28 | → | elliott_ joins (~elliott_@pool-108-51-141-12.washdc.fios.verizon.net) |
| 2020-10-18 00:16:35 | <ski> | (e.g., you could convert to `Rational' ..) |
| 2020-10-18 00:16:36 | <christo> | > fromInteger 2 |
| 2020-10-18 00:16:38 | <lambdabot> | 2 |
| 2020-10-18 00:16:42 | <christo> | > fromInteger 2.0 |
| 2020-10-18 00:16:44 | <lambdabot> | error: |
| 2020-10-18 00:16:44 | <lambdabot> | • Could not deduce (Fractional Integer) |
| 2020-10-18 00:16:44 | <lambdabot> | arising from the literal ‘2.0’ |
| 2020-10-18 00:16:59 | × | untseac quits (~emanuel@2001:818:e8dd:7c00:32b5:c2ff:fe6b:5291) (Remote host closed the connection) |
| 2020-10-18 00:17:01 | <ski> | > floor (fromInteger 18 / fromInteger 7) |
| 2020-10-18 00:17:04 | <lambdabot> | 2 |
| 2020-10-18 00:17:23 | → | ephemera_ joins (~E@122.34.1.187) |
| 2020-10-18 00:17:24 | <ski> | > 18 - 7 * floor (fromInteger 18 / fromInteger 7) |
| 2020-10-18 00:17:26 | <lambdabot> | 4 |
| 2020-10-18 00:17:28 | → | untseac joins (~emanuel@2001:818:e8dd:7c00:32b5:c2ff:fe6b:5291) |
| 2020-10-18 00:17:41 | <ski> | > 18 - 7 * floor (fromInteger 18 / fromInteger 7 :: Rational) |
| 2020-10-18 00:17:43 | <lambdabot> | 4 |
| 2020-10-18 00:18:17 | <christo> | :t (/) |
| 2020-10-18 00:18:17 | <ski> | (without the type ascription, it'll default to `Double', iirc) |
| 2020-10-18 00:18:18 | <lambdabot> | Fractional a => a -> a -> a |
| 2020-10-18 00:18:50 | <christo> | what does :: Rational do? some sort of type Cast or ? |
| 2020-10-18 00:19:54 | <Axman6> | :t \x -> fromInteger x |
| 2020-10-18 00:19:56 | <lambdabot> | Num a => Integer -> a |
| 2020-10-18 00:20:12 | <Axman6> | :t \x -> (fromInteger x :: Rational) |
| 2020-10-18 00:20:13 | <lambdabot> | Integer -> Rational |
| 2020-10-18 00:20:34 | <Axman6> | it's picking the type to use, there is no casting in Haskell* |
| 2020-10-18 00:22:03 | <christo> | ahh ok |
| 2020-10-18 00:22:12 | <christo> | so is Num like a generic or something? |
| 2020-10-18 00:22:23 | <koz_> | christo: Num is kind of like an interface. |
| 2020-10-18 00:22:35 | <koz_> | Something that is an instance of Num is 'kinda sorta number-like' in some sense. |
| 2020-10-18 00:22:56 | → | olligobber joins (olligobber@gateway/vpn/privateinternetaccess/olligobber) |
| 2020-10-18 00:22:59 | <Axman6> | @src Num |
| 2020-10-18 00:22:59 | <lambdabot> | class Num a where |
| 2020-10-18 00:22:59 | <lambdabot> | (+), (-), (*) :: a -> a -> a |
| 2020-10-18 00:22:59 | <lambdabot> | negate, abs, signum :: a -> a |
| 2020-10-18 00:22:59 | <lambdabot> | fromInteger :: Integer -> a |
| 2020-10-18 00:23:02 | <christo> | Hmm, as a haskell beginner may be a bit beyond my head |
| 2020-10-18 00:23:17 | <koz_> | christo: Type classes are a fairly important concept, even at beginner level. |
| 2020-10-18 00:23:59 | <koz_> | (in terms of how to use their instances, at least) |
| 2020-10-18 00:24:04 | <Axman6> | Num is the class of types which can do some number like things, such as addition, subtradction, multiplication this allows you to use the usual 1 + 2 * 3 syntax for your own types |
| 2020-10-18 00:24:45 | <Axman6> | @let data MyNum = Val Integer | Add MyNum My |
| 2020-10-18 00:24:46 | <lambdabot> | .L.hs:159:24: error: |
| 2020-10-18 00:24:47 | <lambdabot> | Not in scope: type constructor or class ‘My’ |
| 2020-10-18 00:24:47 | <lambdabot> | Perhaps you meant ‘Mu’ (imported from Lambdabot.Plugin.Haskell.Eval.Trus... |
| 2020-10-18 00:24:57 | <Axman6> | @let data MyNum = Val Integer | Add MyNum MyNum | |
| 2020-10-18 00:24:58 | <lambdabot> | Parse failed: Parse error: EOF |
| 2020-10-18 00:25:04 | <Axman6> | omg, typing on a couch is ahrd |
| 2020-10-18 00:25:15 | <koz_> | Axman6: It's those axe hands. |
| 2020-10-18 00:25:18 | <christo> | lol |
| 2020-10-18 00:25:27 | <koz_> | Too much couch stuffing everywhere. |
| 2020-10-18 00:25:32 | <Axman6> | @let data MyNum = Val Integer | Add MyNum MyNum | Mul MyNum MyNum |
| 2020-10-18 00:25:33 | <christo> | btw, my (%) infix operator works now |
| 2020-10-18 00:25:34 | <lambdabot> | Defined. |
| 2020-10-18 00:25:47 | <christo> | but need |
| 2020-10-18 00:25:55 | <christo> | maybe look into type classes then |
| 2020-10-18 00:25:55 | × | CodeWeaver quits (49eff865@c-73-239-248-101.hsd1.wa.comcast.net) (Remote host closed the connection) |
| 2020-10-18 00:25:56 | <Axman6> | koz_: congrats on your sane election btw |
| 2020-10-18 00:26:10 | <koz_> | Axman6: Thanks! I gotta say I wasn't too surprised by the outcome. |
| 2020-10-18 00:26:54 | <Axman6> | @let instance Num MyNum where a + b = Add a b; a * b = Mul a b; fromInteger i = Val i |
| 2020-10-18 00:26:55 | <lambdabot> | .L.hs:162:10: error: [-Wmissing-methods, -Werror=missing-methods] |
| 2020-10-18 00:26:55 | <lambdabot> | • No explicit implementation for |
| 2020-10-18 00:26:55 | <lambdabot> | ‘abs’, ‘signum’, and (either ‘negate’ or ‘-’) |
| 2020-10-18 00:27:17 | <Axman6> | @let instance Show MyNum |
| 2020-10-18 00:27:19 | <lambdabot> | .L.hs:162:10: error: [-Wmissing-methods, -Werror=missing-methods] |
| 2020-10-18 00:27:19 | <lambdabot> | • No explicit implementation for |
| 2020-10-18 00:27:19 | <lambdabot> | either ‘showsPrec’ or ‘show’ |
| 2020-10-18 00:27:30 | <Axman6> | @let deriving instance Show MyNum |
| 2020-10-18 00:27:31 | <lambdabot> | Defined. |
| 2020-10-18 00:27:46 | <Axman6> | % 1 + 2 * 3 :: MyNum |
| 2020-10-18 00:27:46 | <yahb> | Axman6: ; <interactive>:62:14: error: Not in scope: type constructor or class `MyNum' |
| 2020-10-18 00:28:04 | <ski> | > 1 + 2 * 3 :: MyNum |
| 2020-10-18 00:28:05 | <Axman6> | you're the worst yahb |
| 2020-10-18 00:28:07 | <lambdabot> | error: |
| 2020-10-18 00:28:07 | <lambdabot> | • No instance for (Num MyNum) arising from a use of ‘+’ |
| 2020-10-18 00:28:07 | <lambdabot> | • In the expression: 1 + 2 * 3 :: MyNum |
| 2020-10-18 00:29:02 | <Axman6> | koz_: we had a similar result over the pond in our territory election, so it was as good night |
| 2020-10-18 00:29:18 | <koz_> | Axman6: In that case, congratulations! |
| 2020-10-18 00:30:09 | → | tromp joins (~tromp@dhcp-077-249-230-040.chello.nl) |
| 2020-10-18 00:31:19 | <koz_> | Would someone be able to guide me in creating Nix environments wherein I can build _static_ Haskell applications for 32-bit x86? |
| 2020-10-18 00:31:40 | <koz_> | So like, a chonky binary I can copy over to another machine and just run. |
All times are in UTC.