Logs: liberachat/#haskell
| 2025-10-20 18:17:26 | <EvanR> | splitWhen :: (a -> Bool) -> [a] -> [[a]] is in there |
| 2025-10-20 18:18:07 | × | tabaqui quits (~tabaqui@167.71.80.236) (Ping timeout: 260 seconds) |
| 2025-10-20 18:19:06 | × | wbrawner quits (~wbrawner@static.56.224.132.142.clients.your-server.de) (Ping timeout: 248 seconds) |
| 2025-10-20 18:21:11 | → | wbrawner joins (~wbrawner@static.56.224.132.142.clients.your-server.de) |
| 2025-10-20 18:22:04 | <tomsmeding> | EvanR: are you sure it's scanl that you need? |
| 2025-10-20 18:22:58 | <tomsmeding> | and no, such a function is not in the standard library |
| 2025-10-20 18:23:14 | <tomsmeding> | which is very convenient for teachers, because then they can ask students to implement it :) |
| 2025-10-20 18:23:43 | <EvanR> | well scanl will do it, but I found it easier to write a direct recursion |
| 2025-10-20 18:23:47 | <monochrom> | Yeah if something is in the standard library, then I can only put it on exams. |
| 2025-10-20 18:26:00 | → | Frostillicus joins (~Frostilli@pool-71-174-119-69.bstnma.fios.verizon.net) |
| 2025-10-20 18:26:04 | <tomsmeding> | EvanR: what I'm confused about is how you sensibly combine scanl and break in this case; I could do it with either, but not sure how to usefully use both together |
| 2025-10-20 18:26:22 | <tomsmeding> | you could do it with break and unfoldl |
| 2025-10-20 18:26:59 | <EvanR> | @src unfoldl |
| 2025-10-20 18:26:59 | <lambdabot> | Source not found. Sorry about this, I know it's a bit silly. |
| 2025-10-20 18:27:30 | <EvanR> | yeah unfoldl would work |
| 2025-10-20 18:27:55 | → | Lycurgus joins (~juan@user/Lycurgus) |
| 2025-10-20 18:28:09 | <EvanR> | you just have to munge a Maybe as opposed to just analyzing the pair coming out of break |
| 2025-10-20 18:29:58 | → | target_i joins (~target_i@user/target-i/x-6023099) |
| 2025-10-20 18:30:24 | <tomsmeding> | scanl forces you to iterate over a particular list, and I'm not clear on what that list would be |
| 2025-10-20 18:30:30 | × | Googulator7 quits (~Googulato@2a01-036d-0106-03fa-0485-6a66-0733-0e38.pool6.digikabel.hu) (Quit: Client closed) |
| 2025-10-20 18:30:40 | → | Googulator7 joins (~Googulato@92-249-221-245.pool.digikabel.hu) |
| 2025-10-20 18:33:02 | <EvanR> | you're right, it would be a scanl to implement the entire shebang |
| 2025-10-20 18:33:05 | → | tabaqui joins (~tabaqui@167.71.80.236) |
| 2025-10-20 18:34:35 | → | rvalue- joins (~rvalue@about/hackers/rvalue) |
| 2025-10-20 18:35:01 | × | rvalue quits (~rvalue@about/hackers/rvalue) (Ping timeout: 246 seconds) |
| 2025-10-20 18:36:52 | <yabobay> | okkk i got it |
| 2025-10-20 18:37:26 | <EvanR> | :t unfoldl |
| 2025-10-20 18:37:27 | <lambdabot> | error: |
| 2025-10-20 18:37:27 | <lambdabot> | • Variable not in scope: unfoldl |
| 2025-10-20 18:37:27 | <lambdabot> | • Perhaps you meant one of these: |
| 2025-10-20 18:37:34 | <EvanR> | :t unfoldr |
| 2025-10-20 18:37:35 | <lambdabot> | (b -> Maybe (a, b)) -> b -> [a] |
| 2025-10-20 18:37:43 | <EvanR> | @src unfoldr |
| 2025-10-20 18:37:43 | <lambdabot> | unfoldr f b = case f b of |
| 2025-10-20 18:37:43 | <lambdabot> | Just (a, b') -> a : unfoldr f b' |
| 2025-10-20 18:37:43 | <lambdabot> | Nothing -> [] |
| 2025-10-20 18:37:45 | <bwe> | Having a data constructor that carries only `Maybe _` records. How can I generically identify and collect only those records that are missing? Example: https://paste.tomsmeding.com/QNAkizLd |
| 2025-10-20 18:39:01 | × | gustrb quits (~gustrb@191.243.134.87) (Ping timeout: 264 seconds) |
| 2025-10-20 18:39:33 | <bwe> | (I don't want to implement a case monster for MyCollectorA and MyCollectorB; I feel it could be done easily with HashMaps yet I loose with them the strictness of storing values to only specific records.) |
| 2025-10-20 18:40:10 | <bwe> | (Maybe the closest bet would be some Validation package, so I'd appreciate it if someone with experience in that could point me to some that fits my use case.) |
| 2025-10-20 18:41:41 | → | peterbecich joins (~Thunderbi@172.222.148.214) |
| 2025-10-20 18:41:53 | <EvanR> | well to just write the function you could hit each field with *> Just "a", *> Just "b", *> Just "c" respectively, then catMaybes |
| 2025-10-20 18:41:57 | rvalue- | is now known as rvalue |
| 2025-10-20 18:42:13 | <EvanR> | but something tells me the whole question could be improved looking at the bigger picture |
| 2025-10-20 18:43:11 | <EvanR> | ok, and there are a lot of fields |
| 2025-10-20 18:43:37 | <EvanR> | doing stuff field by field like that might benefit from extensible records |
| 2025-10-20 18:44:30 | <EvanR> | whose record type often comes with a functor f on every field that you can use in natural transformations |
| 2025-10-20 18:44:31 | <bwe> | EvanR: The bigger picture is scraping some data from different sources using ld+json and meta / item properties. Since the data quality varies with different sources, I need to know which data is missing from the machine readable provided one. For them I need to supplement it by writing manual parsers. |
| 2025-10-20 18:44:33 | <EvanR> | f = Maybe in this case |
| 2025-10-20 18:44:55 | × | jmcantrell quits (~weechat@user/jmcantrell) (Ping timeout: 240 seconds) |
| 2025-10-20 18:45:16 | ← | yabobay parts (~pizza@2a02:85f:fcd5:1601:439e:d9b3:6a5d:d567) (Konversation terminated!) |
| 2025-10-20 18:46:00 | × | Lycurgus quits (~juan@user/Lycurgus) (Quit: alsoknownas.renjuan.org ( juan@acm.org )) |
| 2025-10-20 18:46:41 | <EvanR> | if the data is not strictly structured maybe represent it using dynamic types, like the json Value type |
| 2025-10-20 18:46:52 | <EvanR> | the parser for such a type is the validation |
| 2025-10-20 18:48:14 | <bwe> | …which would go more into the direction of HashMaps, isn't it? Is there such thing like HashMap with only predefined keys (instead of free text)? |
| 2025-10-20 18:49:26 | <EvanR> | yes, dependent map |
| 2025-10-20 18:49:50 | <bwe> | Never heard about this. |
| 2025-10-20 18:50:06 | <EvanR> | it's extensible record adjacent |
| 2025-10-20 18:50:39 | → | SlackCoder joins (~SlackCode@208.26.91.234) |
| 2025-10-20 18:51:10 | × | trickard_ quits (~trickard@cpe-53-98-47-163.wireline.com.au) (Read error: Connection reset by peer) |
| 2025-10-20 18:51:23 | → | trickard_ joins (~trickard@cpe-53-98-47-163.wireline.com.au) |
| 2025-10-20 18:52:35 | <bwe> | So, which packages should I consider? |
| 2025-10-20 18:56:41 | <EvanR> | let me try to clarify, just using something like the json Value (which might be a hashmap of more values) would be pretty unstructured |
| 2025-10-20 18:57:22 | <EvanR> | dependent-map is more structured, and would let you do something with the original question in a well typed way, but might still be too rigid for whatever else you're trying to do |
| 2025-10-20 18:58:28 | × | peterbecich quits (~Thunderbi@172.222.148.214) (Ping timeout: 246 seconds) |
| 2025-10-20 19:00:01 | × | caconym7478798 quits (~caconym@user/caconym) (Quit: bye) |
| 2025-10-20 19:00:42 | → | caconym7478798 joins (~caconym@user/caconym) |
| 2025-10-20 19:00:53 | <bwe> | EvanR: json Value: Yes, because I would pattern match by String values anyway instead of concrete record names. |
| 2025-10-20 19:02:15 | → | gustrb joins (~gustrb@191.243.134.87) |
| 2025-10-20 19:02:22 | <EvanR> | yeah you could zip together the list of possible field names with the result of looking up that field |
| 2025-10-20 19:02:47 | <EvanR> | and output the field name if it's missing, or nothing, and collect at the end |
| 2025-10-20 19:03:18 | <bwe> | okay, I am thinking now I might roll a new, additional, minimal data constructor with non-Maybe, having all required fields, and if any isn't provided by the `Maybe a` upstream constructor, I let it emit a `These a b` type. |
| 2025-10-20 19:04:08 | <EvanR> | having your formal record types be reserved for cases where all the require fields exist probably would simplify things |
| 2025-10-20 19:04:20 | <EvanR> | up to that point use a more unstructured representation |
| 2025-10-20 19:04:34 | <EvanR> | the bridge between them is the parser/validator |
| 2025-10-20 19:04:58 | <bwe> | It's sort of the data transfer object vs. the non-Maybe variant. And the translator inbetween both should tell what's missing. |
| 2025-10-20 19:05:09 | <bwe> | yeah, that'd be the parser/validator. |
| 2025-10-20 19:05:33 | <bwe> | And I am searching for a way to do it differently than pattern matching over all fields or creating a case monster. |
| 2025-10-20 19:06:10 | <EvanR> | have you seen how json value -> application type parsers are done? |
| 2025-10-20 19:06:12 | <EvanR> | using applicative |
| 2025-10-20 19:07:00 | × | gustrb quits (~gustrb@191.243.134.87) (Ping timeout: 252 seconds) |
| 2025-10-20 19:09:43 | → | merijn joins (~merijn@host-vr.cgnat-g.v4.dfn.nl) |
| 2025-10-20 19:10:04 | <EvanR> | e.g. going from Object v = {x: 9, y: 3.14} to data Coord = Coord {x :: Double, y :: Double}, write Coord <$> v.:"y" <*> v.:"z" |
| 2025-10-20 19:10:23 | <EvanR> | or a more involved parser if there are non trivial requirements on the json |
| 2025-10-20 19:12:07 | <EvanR> | the above parser only yields a Coord if the x and y fields exist and parse into Doubles |
| 2025-10-20 19:13:20 | × | trickard_ quits (~trickard@cpe-53-98-47-163.wireline.com.au) (Read error: Connection reset by peer) |
| 2025-10-20 19:14:23 | <probie> | bwe: cobbled together, but if all the fields are `Maybe`, you can do this with generics https://play.haskell.org/saved/T08yEkzo |
| 2025-10-20 19:16:00 | <mastarija> | Does anyone know if there are any utilities in the `base` package for working with type level lists? e.g. Concat type family? |
| 2025-10-20 19:16:07 | → | trickard_ joins (~trickard@cpe-53-98-47-163.wireline.com.au) |
| 2025-10-20 19:16:08 | <mastarija> | I feel like there was something. |
| 2025-10-20 19:16:16 | × | qqe quits (~qqq@185.54.23.200) (Quit: Lost terminal) |
| 2025-10-20 19:16:19 | × | merijn quits (~merijn@host-vr.cgnat-g.v4.dfn.nl) (Ping timeout: 246 seconds) |
| 2025-10-20 19:16:24 | <tomsmeding> | there's some basic stuff for Nats, but I don't recall anything for lists |
| 2025-10-20 19:16:34 | <haskellbridge> | <loonycyborg> Only DataKinds |
| 2025-10-20 19:16:36 | <haskellbridge> | <loonycyborg> and some supporting modules |
| 2025-10-20 19:16:41 | <haskellbridge> | <loonycyborg> like Natural and Symbol |
| 2025-10-20 19:17:00 | <mastarija> | Hm... I guess I've mixed that up with Symbol |
| 2025-10-20 19:17:06 | <haskellbridge> | <loonycyborg> Even DataKinds on its own is pretty powerful though |
| 2025-10-20 19:19:10 | → | tccq joins (~user@user/tccq) |
| 2025-10-20 19:21:44 | <tccq> | Are there decent solutions for jump-to-def and complete symbol names in emacs these days? haskell-mode is good and I like C-c C-c for compilation but the completion doesn't work for locals as far as I can tell. Also even with hls+eglot, jump to def doesn't work for anything outside the current project. I assume that's for lack of source files for system libs? But not even being able to fetch the type seems somewhat harsh. What are |
All times are in UTC.