Home liberachat/#haskell: Logs Calendar

Logs: liberachat/#haskell

←Prev  Next→ 1,804,533 events total
2021-08-27 13:54:49 <[exa]> not sure but likely, given the original haskell had lazy lists for IO
2021-08-27 13:55:06 <kuribas> if you think of set notation as comprehensions...
2021-08-27 13:55:08 <dminuoso> at the end, list comprehensions are just an adaption of set builder syntax in math
2021-08-27 13:55:31 <dminuoso> If you squint a bit, <- even looks similar to ∈
2021-08-27 13:55:44 <[exa]> kuribas: also check out MonadComprehensions
2021-08-27 13:56:07 × arjun quits (~Srain@user/arjun) (Ping timeout: 240 seconds)
2021-08-27 13:56:17 <[exa]> isn't there any SQL package that would build SQL queries from this?
2021-08-27 13:56:41 fendor_ joins (~fendor@77.119.210.198.wireless.dyn.drei.com)
2021-08-27 13:56:52 <Rembane_> Sounds a bit like Selda.
2021-08-27 13:57:33 <[exa]> we actually used selda, but never reached that far
2021-08-27 13:57:38 <kuribas> [exa]: my query builder is a monad, so it would work with monad comprehensions :)
2021-08-27 13:58:17 <[exa]> good, good, more set notation! (*laughs in godel numerals*)
2021-08-27 13:58:21 <Hecate> https://github.com/tchoutri/pg-entity <- my query builder is a bit simpler
2021-08-27 13:59:10 × fendor quits (~fendor@178.165.207.147.wireless.dyn.drei.com) (Ping timeout: 240 seconds)
2021-08-27 13:59:39 <Drew[m]> kuribas: You don't even need to go back to set builder notation. Miranda had list comprehensions, and Haskell was heavily inspired by that.
2021-08-27 14:00:35 <kuribas> [exa]: I cannot see much reason motivate using monad comprehensions.
2021-08-27 14:00:40 mastarija joins (~mastarija@78-3-210-70.adsl.net.t-com.hr)
2021-08-27 14:00:45 <kuribas> Hecate: you query builder is just SQL :)
2021-08-27 14:00:57 <kuribas> Hecate: but then, does it compose?
2021-08-27 14:01:29 <kuribas> Hecate: "It is my personal belief, firmly rooted in experience, that we should not aim to produce statically-checked SQL and have it "verified" by the compiler. "
2021-08-27 14:01:34 <kuribas> Hecate: I very much agree :)
2021-08-27 14:01:43 <Hecate> :)
2021-08-27 14:02:34 <Hecate> you can't arbitrarily compose it, because it's made for capturing wider patterns, rather than spewing SQL from an eDSL
2021-08-27 14:02:37 <Hecate> :D
2021-08-27 14:02:46 <Hecate> (which makes it simpler to develop and test)
2021-08-27 14:02:52 <[exa]> kuribas: what about: [(userID x, tweet x) | x <- tweets, y <- friendsOf user, userId x `in` userId y]
2021-08-27 14:03:13 <kuribas> Hecate: I find being able to type check the types of columns and table very useful though.
2021-08-27 14:04:35 <kuribas> [exa]: do x <- tweets; y <- friendsOf user; guard $ userId x `in` userId y; pure (userID x, tweet x)
2021-08-27 14:05:13 <[exa]> kuribas: yeah ofcourse, but reads less like SELECT ... FROM ... WHERE ...
2021-08-27 14:05:25 <kuribas> ah right...
2021-08-27 14:05:31 <[exa]> not that it would be wrong tho
2021-08-27 14:07:07 <kuribas> doesn't f# has this kind of syntax?
2021-08-27 14:07:12 <kuribas> or C# even...
2021-08-27 14:08:06 <kuribas> ah f# has query expressions, C# linq
2021-08-27 14:09:23 <kuribas> https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/query-expressions
2021-08-27 14:13:28 × zaquest quits (~notzaques@5.128.210.178) (Remote host closed the connection)
2021-08-27 14:13:40 × azeem quits (~azeem@176.201.20.14) (Ping timeout: 252 seconds)
2021-08-27 14:16:30 zaquest joins (~notzaques@5.128.210.178)
2021-08-27 14:16:58 × vpan quits (~vilius@212.117.1.172) (Ping timeout: 252 seconds)
2021-08-27 14:18:27 <hololeap> shouldn't this short-circuit when i==6 ? foldMap (\i -> if i > 5 then Just (First i) else Nothing) [0..]
2021-08-27 14:18:35 burnsidesLlama joins (~burnsides@dhcp168-011.wadham.ox.ac.uk)
2021-08-27 14:20:10 wroathe joins (~wroathe@c-68-54-25-135.hsd1.mn.comcast.net)
2021-08-27 14:20:10 × wroathe quits (~wroathe@c-68-54-25-135.hsd1.mn.comcast.net) (Changing host)
2021-08-27 14:20:10 wroathe joins (~wroathe@user/wroathe)
2021-08-27 14:20:23 <janus> > foldMap (\i -> if i > 5 then Just (First i) else Nothing) [0..]
2021-08-27 14:20:25 <lambdabot> error:
2021-08-27 14:20:25 <lambdabot> Ambiguous occurrence ‘First’
2021-08-27 14:20:25 <lambdabot> It could refer to
2021-08-27 14:20:31 <[exa]> hololeap: you seem to imply that all numbers that come after 5 are larger than 5
2021-08-27 14:20:35 <[exa]> :]
2021-08-27 14:21:12 <int-e> > First 1
2021-08-27 14:21:13 <hololeap> [exa]: it's more that I expected First to short-circuit it somehow when it hits its first `Just (First Int)` result
2021-08-27 14:21:14 <lambdabot> error:
2021-08-27 14:21:14 <lambdabot> • No instance for (Num (Maybe ())) arising from a use of ‘e_11’
2021-08-27 14:21:14 <lambdabot> • In the expression: e_11
2021-08-27 14:21:14 <janus> aaah
2021-08-27 14:21:20 <janus> so you'd need to map first in first ?
2021-08-27 14:21:22 <int-e> > First (Just 1)
2021-08-27 14:21:23 <lambdabot> First {getFirst = Just 1}
2021-08-27 14:21:27 × MQ-17J quits (~MQ-17J@d14-69-206-129.try.wideopenwest.com) (Ping timeout: 240 seconds)
2021-08-27 14:21:35 <hololeap> (this is Data.Semigroup.First, btw)
2021-08-27 14:21:37 <[exa]> hololeap: ah so I see that now
2021-08-27 14:21:40 <janus> then foldMap wouldn't need to know about monotonic properties of the sequence
2021-08-27 14:21:41 <kuribas> :t First
2021-08-27 14:21:42 <lambdabot> Maybe a -> First a
2021-08-27 14:22:04 <kuribas> > foldMap (\i -> if i > 5 then Just (First i) else Nothing) [0::Int..]
2021-08-27 14:22:06 <lambdabot> <hint>:1:63: error: Operator applied to too few arguments: Int..
2021-08-27 14:22:14 martin02 joins (~silas@141.84.69.76)
2021-08-27 14:22:28 <kuribas> Looks like a type error...
2021-08-27 14:22:34 <hololeap> % f = foldMap (\i -> if i > 5 then Just (Data.Semigroup.First i) else Nothing)
2021-08-27 14:22:36 <yahb> hololeap:
2021-08-27 14:22:41 <hololeap> % :t f
2021-08-27 14:22:41 <yahb> hololeap: (Foldable t, Ord a, Num a) => t a -> Maybe (Data.Semigroup.First a)
2021-08-27 14:22:49 <hololeap> % f [0..]
2021-08-27 14:22:52 <yahb> hololeap: *** Exception: heap overflow
2021-08-27 14:23:07 × burnsidesLlama quits (~burnsides@dhcp168-011.wadham.ox.ac.uk) (Ping timeout: 250 seconds)
2021-08-27 14:23:13 <janus> % f [0..10]
2021-08-27 14:23:15 <yahb> janus: Just (First {getFirst = 6})
2021-08-27 14:23:48 <geekosaur> beware of that, "Int.." is parsed as operator (.) in module Int
2021-08-27 14:24:08 <kuribas> > foldMap (\i -> if i > 5 then Just (Data.Semigroup.First i) else Nothing) [0::Expr .. 6]
2021-08-27 14:24:10 <lambdabot> error:
2021-08-27 14:24:10 <lambdabot> Not in scope: data constructor ‘Data.Semigroup.First’
2021-08-27 14:24:10 <lambdabot> No module named ‘Data.Semigroup’ is imported.
2021-08-27 14:24:27 × hannessteffenhag quits (~hannesste@ip4d14ffc8.dynamic.kabel-deutschland.de) (Ping timeout: 240 seconds)
2021-08-27 14:24:36 <janus> bummer that yahb doesn't have Expr
2021-08-27 14:24:47 × nilof quits (~olofs@90-227-86-119-no542.tbcn.telia.com) (Ping timeout: 240 seconds)
2021-08-27 14:24:49 <[exa]> hololeap: don't you need foldMap' ?
2021-08-27 14:25:19 MQ-17J joins (~MQ-17J@d14-69-206-129.try.wideopenwest.com)
2021-08-27 14:25:23 <[exa]> foldMap doc says it's left-associative, so it looks to me that it can't short-circuit
2021-08-27 14:26:04 <[exa]> oh no I'm reading the wrong docs :D
2021-08-27 14:26:26 <hololeap> % f' = foldMap' (\i -> if i > 5 then Just (Data.Semigroup.First i) else Nothing)
2021-08-27 14:26:27 <yahb> hololeap:
2021-08-27 14:26:33 <hololeap> % f' [0..]
2021-08-27 14:26:35 <yahb> hololeap: *** Exception: heap overflow
2021-08-27 14:27:20 × mikoto-c1 quits (~mikoto-ch@ip-83-134-2-136.dsl.scarlet.be) (Quit: mikoto-c1)
2021-08-27 14:27:40 mikoto-chan joins (~mikoto-ch@ip-83-134-2-136.dsl.scarlet.be)
2021-08-27 14:28:46 <int-e> hololeap: Just (First 0) <> undefined doesn't short-cut, at which point you've lost already. The reason being, the Monoid instance for Maybe doesn't know that the inner monoid has short-cutting capabilities.
2021-08-27 14:29:17 <int-e> > Just [1] <> Nothing <> Just [2] -- you can't stop at Nothing
2021-08-27 14:29:19 <lambdabot> Just [1,2]
2021-08-27 14:29:53 <Taneb> > First 0 <> undefined

All times are in UTC.