Home liberachat/#haskell: Logs Calendar

Logs: liberachat/#haskell

←Prev  Next→ 1,803,859 events total
2021-07-29 19:10:17 <dsal> You don't need `getX` when you have `gets`
2021-07-29 19:10:19 <dsal> :t gets
2021-07-29 19:10:20 <lambdabot> MonadState s m => (s -> a) -> m a
2021-07-29 19:10:33 <Drew[m]> There's also `traverse`, rather than traversal.
2021-07-29 19:10:35 × pfurla_ quits (~pfurla@ool-182ed2e2.dyn.optonline.net) (Quit: gone to sleep. ZZZzzz…)
2021-07-29 19:10:58 <dsal> :t traversed
2021-07-29 19:11:00 <lambdabot> (Indexable Int p, Traversable f1, Applicative f2) => p a (f2 b) -> f1 a -> f2 (f1 b)
2021-07-29 19:11:43 falafel joins (~falafel@pool-96-255-70-50.washdc.fios.verizon.net)
2021-07-29 19:11:45 <deejaytee> echoone: that's been a source of difficulty for me in learning J - while at first parts of speech are useful for remembering what does what, it starts to clash later on
2021-07-29 19:12:14 <EvanR> map seems a bit ambiguous... probably because this is a purely mathematical idea to me
2021-07-29 19:12:15 <deejaytee> but I suppose it's better than no terminology whatsoever
2021-07-29 19:12:22 <dsal> I've seen people get hung up on "how do I read this in English?" Such a weird concept. If I could even express my problems in English, I'd probably do that in the first place.
2021-07-29 19:12:28 <EvanR> math doesn't really verb anything
2021-07-29 19:12:51 × waleee quits (~waleee@2001:9b0:216:8200:d457:9189:7843:1dbd) (Quit: WeeChat 3.2)
2021-07-29 19:12:54 <roboguy_> EvanR: what about "acting on"
2021-07-29 19:13:07 <roboguy_> or "pulling back along"
2021-07-29 19:13:19 <EvanR> right, group action. Sounds like a case of math people trying to get inspiration from language, like us
2021-07-29 19:13:29 <EvanR> pullback definitely
2021-07-29 19:13:33 <EvanR> it's verby
2021-07-29 19:13:40 <EvanR> 'a pullback' lol
2021-07-29 19:14:04 <EvanR> a case of math terms becoming ambiuously part-of-speeched
2021-07-29 19:14:37 × fluffyballoon quits (~fluffybal@pat-verona-h.epic.com) (Quit: Client closed)
2021-07-29 19:14:49 <EvanR> lens gets a lot of help from adjectives
2021-07-29 19:15:13 fluffyballoon joins (~fluffybal@pat-verona-h.epic.com)
2021-07-29 19:15:22 × fossdd quits (~fossdd@sourcehut/user/fossdd) (Ping timeout: 240 seconds)
2021-07-29 19:15:27 <EvanR> but group actions, pullbacks, and lenses still aren't "doing" more or less than anything else
2021-07-29 19:15:43 fossdd joins (~fossdd@sourcehut/user/fossdd)
2021-07-29 19:15:44 <lechner> Hi, how do I best print each element of an array on a separate line, prepended by a space, please?
2021-07-29 19:15:48 <dsal> `map` is also a little weird because you can also think of it as just sort of sticking a transformation on list accessors. It doesn't *actually* build a new list after applying your function to every element in the list.
2021-07-29 19:15:58 <dsal> lechner: mapM_ print thing
2021-07-29 19:16:17 <dsal> Oh, if you want to add a space, you can stick one in the action there.
2021-07-29 19:16:35 <EvanR> yes lazy evaluation makes verbing even less applicable, if you wanted to think of verbs causing the compuer to heat up and do things
2021-07-29 19:16:36 <dsal> mapM_ (\x -> putStr " " >> print x) thing
2021-07-29 19:16:38 <roboguy_> :t unlines
2021-07-29 19:16:39 <lambdabot> [String] -> String
2021-07-29 19:17:26 waleee joins (~waleee@2001:9b0:216:8200:d457:9189:7843:1dbd)
2021-07-29 19:17:32 <EvanR> verbs <-> do work
2021-07-29 19:17:35 × raehik quits (~raehik@cpc95906-rdng25-2-0-cust156.15-3.cable.virginm.net) (Ping timeout: 258 seconds)
2021-07-29 19:17:45 <dsal> @undo do work
2021-07-29 19:17:45 <lambdabot> work
2021-07-29 19:17:50 <dsal> There's no way out!
2021-07-29 19:17:52 <EvanR> fix error
2021-07-29 19:18:38 × finsternis quits (~X@23.226.237.192) (Remote host closed the connection)
2021-07-29 19:19:04 × echoone quits (~echoone@188.74.32.13) (Quit: Client closed)
2021-07-29 19:19:12 <EvanR> actually this entire train of thought about programming = a bunch of verbs to make stuff 'happen' in a row might be the initial key thing to tell people to forget when starting haskell
2021-07-29 19:19:22 raehik joins (~raehik@cpc95906-rdng25-2-0-cust156.15-3.cable.virginm.net)
2021-07-29 19:20:31 mjs2600 joins (~mjs2600@c-24-91-3-49.hsd1.vt.comcast.net)
2021-07-29 19:20:54 <dsal> The intuition starts to break down with infinite lists, but yeah, it's helpful. It's also helpful when you do stuff like `map f . map g`. If you think about the `map` doing something, it suddenly seems expensive. If you think about it just shoving filters on the thing, you won't spend hours trying to make your code more complicated to do what RULEs can do.
2021-07-29 19:21:20 <Drew[m]> I'm fine with thinking that `map` "maps a function over a list", that it "does stuff"
2021-07-29 19:21:20 <Drew[m]> It just only does stuff when the stuff is needed.
2021-07-29 19:21:56 <lechner> that's another point
2021-07-29 19:21:57 <dsal> Sure. It's not a bad mental model, but it's not the only mental model. :)
2021-07-29 19:22:25 <EvanR> you can get pretty far in haskell imagining code running by rewriting expressions
2021-07-29 19:24:16 <EvanR> which is both an act and an expression of 'what this function means'
2021-07-29 19:24:51 <lechner> dsal: should your lambda above print the array element (which are of type String) in quotes?
2021-07-29 19:24:59 <lechner> elements
2021-07-29 19:25:14 <dsal> lechner: Yeah, that's what `print` does. I wasn't sure what the type was. You can use `putStrLn`
2021-07-29 19:25:22 × fossdd quits (~fossdd@sourcehut/user/fossdd) (Ping timeout: 240 seconds)
2021-07-29 19:25:29 <EvanR> the second thing there makes it easy to see you could reverse it without causing problems
2021-07-29 19:25:39 <dsal> lechner: It's good to understand what the parts were. :)
2021-07-29 19:25:53 fossdd joins (~fossdd@sourcehut/user/fossdd)
2021-07-29 19:25:54 <EvanR> imperative programming often involves doing things that can't be reversed
2021-07-29 19:26:11 <EvanR> e.g. updating arrays
2021-07-29 19:27:19 <maerwald> so what's the alternative to brick on windows?
2021-07-29 19:27:44 <lechner> dsal: could i also write mapM_ (\x -> putStrLn $ " " <> x) ?
2021-07-29 19:30:25 shapr hops
2021-07-29 19:31:20 <[exa]> lechner: a complimentary bit of compression: `mapM_ (putStrLn . (' ':) )`
2021-07-29 19:31:37 <Drew[m]> <EvanR> "you can get pretty far in..." <- Isn't that to a degree what STG does?
2021-07-29 19:31:43 × fluffyballoon quits (~fluffybal@pat-verona-h.epic.com) (Quit: Client closed)
2021-07-29 19:32:04 fluffyballoon joins (~fluffybal@pat-verona-h.epic.com)
2021-07-29 19:32:39 <dsal> lechner: I'll allow it. :)
2021-07-29 19:32:58 <EvanR> you can think of it like that
2021-07-29 19:33:16 <maerwald> so how do I use this from haskell https://github.com/migueldeicaza/gui.cs
2021-07-29 19:33:24 <dsal> lechner: There's mapM_ and forM_ -- I think I've used the latter once.
2021-07-29 19:33:26 <dsal> :t forM_
2021-07-29 19:33:27 <lambdabot> (Foldable t, Monad m) => t a -> (a -> m b) -> m ()
2021-07-29 19:33:33 × ubert quits (~Thunderbi@178.165.190.122.wireless.dyn.drei.com) (Ping timeout: 276 seconds)
2021-07-29 19:33:55 bontaq` joins (~user@ool-18e47f8d.dyn.optonline.net)
2021-07-29 19:34:10 jneira_ joins (~jneira_@28.red-80-28-169.staticip.rima-tde.net)
2021-07-29 19:34:28 <lechner> [exa]: so this would be my first point-free, but unfortunately I actually have to prepend muliple characters (" - "). Is that possible?
2021-07-29 19:34:41 <dsal> lechner: Find out! :)
2021-07-29 19:34:54 <lechner> with cons?
2021-07-29 19:35:14 <dsal> Understand what it's doing. There's not much magic there.
2021-07-29 19:35:23 <dsal> :t (' ':)
2021-07-29 19:35:25 <lambdabot> [Char] -> [Char]
2021-07-29 19:35:34 <dsal> :t putStrLn . (' ':)
2021-07-29 19:35:36 <lambdabot> [Char] -> IO ()
2021-07-29 19:36:11 <dsal> Do you understand sections?
2021-07-29 19:36:18 <lechner> i am doing it wrong
2021-07-29 19:36:45 <dsal> You *can* use `:` but it'd be a little weird.
2021-07-29 19:36:47 × Obo quits (~roberto@70.pool90-171-81.dynamic.orange.es) (Ping timeout: 252 seconds)
2021-07-29 19:37:13 Erutuon joins (~Erutuon@user/erutuon)
2021-07-29 19:37:14 <lechner> mapM_ (putStrLn . (" - ":)) (Task.inputs task) gives me No instance for (Data.String.IsString Char) arising from literal
2021-07-29 19:37:42 bontaq` is now known as bontaq
2021-07-29 19:37:43 <dsal> So, taking a step back.
2021-07-29 19:37:47 <dsal> :t (" - ":)
2021-07-29 19:37:48 <lambdabot> [[Char]] -> [[Char]]
2021-07-29 19:38:07 <[exa]> lechner: you confused "" and '', the second is only a single char that can be prepended with :
2021-07-29 19:38:10 <dsal> I don't think that's what you want.
2021-07-29 19:38:25 <[exa]> for strings, you need at least (" -" ++)

All times are in UTC.