Logs: freenode/#haskell
| 2021-05-16 09:55:08 | → | acidjnk_new joins (~acidjnk@p200300d0c72b95208d2194a61b0d7b67.dip0.t-ipconnect.de) |
| 2021-05-16 09:56:32 | <maerwald> | the types are weak, but I'm not aware that SQL does random type coercion? |
| 2021-05-16 09:56:55 | <kuribas> | define SQL |
| 2021-05-16 09:57:21 | <kuribas> | MySQL will do type coercion rather than raise a type error normally. |
| 2021-05-16 09:57:54 | <maerwald> | so the standard doesn't define it? |
| 2021-05-16 09:58:18 | <kuribas> | what standard? |
| 2021-05-16 09:58:21 | × | merijn quits (~merijn@83-160-49-249.ip.xs4all.nl) (Ping timeout: 260 seconds) |
| 2021-05-16 09:59:27 | <maerwald> | there are multiple? |
| 2021-05-16 09:59:49 | <aldum> | there's an SQL standard, and various implementations adhere to it to various degrees |
| 2021-05-16 09:59:59 | <aldum> | as it's customary with standards... |
| 2021-05-16 10:00:30 | → | Rudd0 joins (~Rudd0@185.189.115.103) |
| 2021-05-16 10:01:55 | <maerwald> | Would be interesting to know whether the standard says something about type safety |
| 2021-05-16 10:02:13 | × | frozenErebus quits (~frozenEre@37.231.244.249) (Ping timeout: 240 seconds) |
| 2021-05-16 10:03:37 | <aldum> | prolly not very safe, it does have NULL after all |
| 2021-05-16 10:04:23 | × | oish quits (~charlie@228.25.169.217.in-addr.arpa) (Ping timeout: 268 seconds) |
| 2021-05-16 10:05:39 | → | ddellacosta joins (~ddellacos@86.106.143.72) |
| 2021-05-16 10:06:15 | → | Ariakenom joins (~Ariakenom@2001:9b1:efb:fc00:8515:6952:6c0e:748) |
| 2021-05-16 10:08:18 | × | a6a45081-2b83 quits (~aditya@171.76.17.86) (Remote host closed the connection) |
| 2021-05-16 10:09:27 | → | ddellac__ joins (~ddellacos@ool-44c73afa.dyn.optonline.net) |
| 2021-05-16 10:09:56 | → | Schrostfutz joins (~Schrostfu@p4fc0a70a.dip0.t-ipconnect.de) |
| 2021-05-16 10:10:24 | × | ddellacosta quits (~ddellacos@86.106.143.72) (Ping timeout: 265 seconds) |
| 2021-05-16 10:10:46 | → | alexander joins (~alexander@2a02:587:dc19:ab00:49f:5b0e:f658:23e8) |
| 2021-05-16 10:11:15 | alexander | is now known as Guest72179 |
| 2021-05-16 10:12:40 | → | hamflx joins (79e123b8@121.225.35.184) |
| 2021-05-16 10:13:47 | <Schrostfutz> | Hi, I'm trying to parse a binary file using attoparsec and have trouble with ByteString literals. I use the `string` function with a string literal, but get a type mismatch between ByteString & [Char]. I probably specify a String literal instead of ByteString but I did it similar to the documentation... What might I be doing wrong? Disclaimer: I'm a complete novice, trying to learn by doing |
| 2021-05-16 10:15:14 | × | ddellac__ quits (~ddellacos@ool-44c73afa.dyn.optonline.net) (Ping timeout: 265 seconds) |
| 2021-05-16 10:17:40 | → | Pickchea joins (~private@unaffiliated/pickchea) |
| 2021-05-16 10:18:32 | × | Alleri___ quits (~textual@2603-7000-3040-0000-3dfd-96ce-a198-b5b2.res6.spectrum.com) (Quit: My MacBook has gone to sleep. ZZZzzz…) |
| 2021-05-16 10:18:52 | <__monty__> | Schrostfutz: I can see the confusion, the example code is written to work for both attoparsec and parsec. I think you'll need to enable overloaded strings, add `{-# LANGUAGE OverloadedStrings #-}` to the top of your file. |
| 2021-05-16 10:18:52 | × | ixlun quits (~user@109.249.184.235) (Read error: Connection reset by peer) |
| 2021-05-16 10:19:11 | × | chris__ quits (~chris@81.96.113.213) (Ping timeout: 240 seconds) |
| 2021-05-16 10:19:34 | × | TK__ quits (~cinch@2601:1c0:5201:2100:9992:f75f:4988:2a3c) (Ping timeout: 245 seconds) |
| 2021-05-16 10:19:38 | → | ixlun joins (~user@109.249.184.235) |
| 2021-05-16 10:19:50 | <Schrostfutz> | __monty__: Thanks a bunch, that fixed it! |
| 2021-05-16 10:20:00 | <__monty__> | \o/ |
| 2021-05-16 10:20:19 | → | Guest_52 joins (5214e4fd@82.20.228.253) |
| 2021-05-16 10:20:24 | × | vgtw quits (~vgtw@gateway/tor-sasl/vgtw) (Remote host closed the connection) |
| 2021-05-16 10:20:41 | → | vgtw joins (~vgtw@gateway/tor-sasl/vgtw) |
| 2021-05-16 10:20:44 | × | pavonia quits (~user@unaffiliated/siracusa) (Quit: Bye!) |
| 2021-05-16 10:21:57 | <__monty__> | Schrostfutz: One thing to note is that if you want control over the encoding of the characters you'll have to explicitly convert from String to a ByteString with the correct encoding. |
| 2021-05-16 10:22:08 | → | Qwerky joins (~qwerky@178.197.228.14) |
| 2021-05-16 10:23:27 | × | Qwerky quits (~qwerky@178.197.228.14) (Remote host closed the connection) |
| 2021-05-16 10:24:11 | → | Qwerky joins (~qwerky@178.197.228.14) |
| 2021-05-16 10:24:13 | <Schrostfutz> | __monty__: Thanks for the heads-up, I started with Parsec and used the encoding to read the binary file before noticing that Parsec won't allow me to parse binary numbers (if I understood that correctly). Probably I'll have to do the conversion by hand at some point. What module can I find the appropriate functions in? |
| 2021-05-16 10:24:34 | × | hamflx quits (79e123b8@121.225.35.184) (Quit: Connection closed) |
| 2021-05-16 10:29:19 | × | Guest_52 quits (5214e4fd@82.20.228.253) (Quit: Connection closed) |
| 2021-05-16 10:32:16 | → | oish joins (~charlie@228.25.169.217.in-addr.arpa) |
| 2021-05-16 10:32:46 | × | Pickchea quits (~private@unaffiliated/pickchea) (Ping timeout: 240 seconds) |
| 2021-05-16 10:33:56 | × | Qwerky quits (~qwerky@178.197.228.14) (Remote host closed the connection) |
| 2021-05-16 10:34:54 | → | frozenErebus joins (~frozenEre@37.231.244.249) |
| 2021-05-16 10:36:43 | <xenon-> | what do you mean it won't allow you to parse binary numbers? |
| 2021-05-16 10:37:56 | → | Alleria__ joins (~textual@2603-7000-3040-0000-3dfd-96ce-a198-b5b2.res6.spectrum.com) |
| 2021-05-16 10:38:07 | <xenon-> | oh, the file is bianary.. didn't read entire sentenc3e |
| 2021-05-16 10:38:13 | <xenon-> | I'm not sure if Pasrec allows that |
| 2021-05-16 10:38:27 | → | ddellacosta joins (~ddellacos@86.106.143.137) |
| 2021-05-16 10:39:36 | → | nicholasbulka joins (~nicholasb@2601:900:4301:da0:8c8b:ebd7:353b:3970) |
| 2021-05-16 10:40:04 | × | oish quits (~charlie@228.25.169.217.in-addr.arpa) (Ping timeout: 252 seconds) |
| 2021-05-16 10:42:04 | × | Alleria__ quits (~textual@2603-7000-3040-0000-3dfd-96ce-a198-b5b2.res6.spectrum.com) (Ping timeout: 245 seconds) |
| 2021-05-16 10:42:34 | <Schrostfutz> | xenon-: I managed to convince it to read the file but there's no functions to read those. So I switched to attoparsec only to notice that it also doesn't provide them by default... |
| 2021-05-16 10:42:36 | <__monty__> | Schrostfutz: It depends on the encoding and which type you're working with. For UTF-8 and String, look at the utf8-string package. For Text, look at the text package. |
| 2021-05-16 10:42:51 | → | juuandyy joins (~juuandyy@90.106.228.121) |
| 2021-05-16 10:43:14 | × | ddellacosta quits (~ddellacos@86.106.143.137) (Ping timeout: 268 seconds) |
| 2021-05-16 10:43:15 | <__monty__> | Schrostfutz: The problem is there's too many ways of representing integers or even floats in a binary format. |
| 2021-05-16 10:44:28 | <Schrostfutz> | __monty__: Thanks! But for things like integers there's just big/little endian, isn't there? |
| 2021-05-16 10:45:44 | <__monty__> | No, one's complement, two's complement, variable length encodings... |
| 2021-05-16 10:46:33 | <__monty__> | Haskell's Integer for example would need a variable length encoding. |
| 2021-05-16 10:47:08 | <Schrostfutz> | Hm, true... So I'll write my own then. Was it then even necessary/sensible to switch to attoparsec If I'll write my own functions for that anyway? |
| 2021-05-16 10:47:35 | → | Pickchea joins (~private@unaffiliated/pickchea) |
| 2021-05-16 10:48:45 | <Schrostfutz> | I also got another type mismatch issue, expected type Char -> IO (), Actual type [Char] -> IO () in the second argument of >>= (putStrLn): http://sprunge.us/5LcIaV But I defined the function to return String, so I don't see how it returns a char. |
| 2021-05-16 10:49:16 | <__monty__> | Schrostfutz: Depends, attoparsec is more specialized to binary formats. If you can provide sensible error messages though, megaparsec's probably much nicer to work with. |
| 2021-05-16 10:49:26 | → | Qwerky joins (~qwerky@178.197.228.14) |
| 2021-05-16 10:50:06 | <Schrostfutz> | Okay, then I'll stick to attoparsec for now. Focus is anyway not completing the task but learning the language so I can figure out my type mismatches myself. |
| 2021-05-16 10:51:18 | <__monty__> | Learning to work with megaparsec has a little bit more utility than attoparsec imho. But either's probably fine as a means rather than a goal. |
| 2021-05-16 10:52:03 | <__monty__> | @type >>= |
| 2021-05-16 10:52:05 | <lambdabot> | error: parse error on input ‘>>=’ |
| 2021-05-16 10:52:10 | <__monty__> | @type (>>=) |
| 2021-05-16 10:52:11 | <lambdabot> | Monad m => m a -> (a -> m b) -> m b |
| 2021-05-16 10:52:32 | <__monty__> | Schrostfutz: Can you match that type to `readStream >>= putStrLn`? |
| 2021-05-16 10:53:00 | <__monty__> | Oh, but pretend readStream's been applied to something. |
| 2021-05-16 10:53:20 | <__monty__> | So `readStream someByteString >>= putStrLn`. |
| 2021-05-16 10:53:52 | × | Qwerky quits (~qwerky@178.197.228.14) (Ping timeout: 240 seconds) |
| 2021-05-16 10:55:15 | × | juuandyy quits (~juuandyy@90.106.228.121) (Quit: Konversation terminated!) |
| 2021-05-16 10:55:32 | <Schrostfutz> | So this is how I understand it (terminology is probably way off...): readStream returns a String that is within the IO Monad so I have `IO String -> (String -> IO b)` -> IO b. putStrLn has type String -> IO (), so b == (), and I get `IO String -> (String -> IO ()) -> IO ()`? |
| 2021-05-16 10:56:20 | → | juuandyy joins (~juuandyy@90.106.228.121) |
| 2021-05-16 10:57:24 | → | Rudd0^ joins (~Rudd0@185.189.115.103) |
| 2021-05-16 10:58:08 | <__monty__> | Where do you get IO? Afaict readStream takes a String and returns a ByteString. |
| 2021-05-16 10:58:31 | × | Rudd0 quits (~Rudd0@185.189.115.103) (Read error: Connection reset by peer) |
| 2021-05-16 11:00:25 | <Schrostfutz> | __monty__: Ah! I thought it was implicitly added into the monad, but I suppose I'll have to `liftM` it |
| 2021-05-16 11:00:26 | → | zephyz joins (~zephyz@109.175.155.98) |
| 2021-05-16 11:00:27 | × | p3n quits (~p3n@2a00:19a0:3:7c:0:d9c6:7cf6:1) (Quit: ZNC 1.8.2 - https://znc.in) |
| 2021-05-16 11:01:47 | → | p3n joins (~p3n@217.198.124.246) |
| 2021-05-16 11:03:00 | <__monty__> | Not quite, you're still inputting a ByteString, not IO ByteString. |
| 2021-05-16 11:04:18 | <__monty__> | So either use (pure (or return) . readStream) or fmap readStream over the previous action. `readStream <$> (hGetContents stdin)`. |
| 2021-05-16 11:07:32 | × | Rudd0^ quits (~Rudd0@185.189.115.103) (Ping timeout: 246 seconds) |
| 2021-05-16 11:08:06 | × | nrl^ quits (~hph@ip98-184-89-2.mc.at.cox.net) () |
| 2021-05-16 11:09:07 | → | chris__ joins (~chris@81.96.113.213) |
| 2021-05-16 11:11:29 | → | ddellacosta joins (ddellacost@gateway/vpn/mullvad/ddellacosta) |
| 2021-05-16 11:12:45 | × | stree quits (~stree@68.36.8.116) (Ping timeout: 265 seconds) |
| 2021-05-16 11:14:07 | × | Gurkenglas quits (~Gurkengla@unaffiliated/gurkenglas) (Remote host closed the connection) |
| 2021-05-16 11:14:33 | → | Gurkenglas joins (~Gurkengla@unaffiliated/gurkenglas) |
All times are in UTC.