Logs: liberachat/#haskell
| 2025-10-30 09:29:06 | <tomsmeding> | and FromTable :: String -> Formula (TimeSeries Double) ? |
| 2025-10-30 09:29:12 | <tomsmeding> | or something like it |
| 2025-10-30 09:30:55 | × | merijn quits (~merijn@77.242.116.146) (Ping timeout: 264 seconds) |
| 2025-10-30 09:30:56 | <kuribas> | ToQuery :: Ap (TimeSeries Formula a) -> SqlQuery |
| 2025-10-30 09:31:33 | <kuribas> | More likely ToQueries :: [HashMap Text (Ap (TimSeries Formula a))] -> [SqlQuery] |
| 2025-10-30 09:32:42 | <tomsmeding> | okay so here's my confusion, and I think the resolution to it: especially now that you present AddSeries -- a function-typed primitive in your little language -- having a functor-style interface to it feels weird to me, because 1. AddSeries by itself doesn't encode any kind of effect, and 2. being able to inspect that the query does AddSeries by itself is not particularly helpful. Instead, here I |
| 2025-10-30 09:32:44 | <tomsmeding> | would expect you to just have a custom AST that models your query language, with no mention of fmap or such. However, if you want to subsequently embed that little language in Haskell, you'll have to introduce an operator for embedded function application, and lo, perhaps <*> typechecks nicely |
| 2025-10-30 09:33:03 | <tomsmeding> | it would be Ap (TimeSeries Formula) a, but yeah |
| 2025-10-30 09:33:21 | <tomsmeding> | I think I would recommend you roll your own expression data type here instead of reusing Ap |
| 2025-10-30 09:33:36 | <kuribas> | Ah I see. No, I don't want fmap or <*>, but something similar on AST level. |
| 2025-10-30 09:33:40 | <tomsmeding> | right |
| 2025-10-30 09:34:13 | <tomsmeding> | perhaps your custom expression data type ends up having a little substructure that looks a lot like Ap, and if you really want, you can later extract that |
| 2025-10-30 09:34:47 | <tomsmeding> | but the convenience offered by the functions on Ap are probably not worth the semantical overhead of bringing in a free applicative when it "doesn't make any sense" because it's not the standard usage of a free applicative |
| 2025-10-30 09:35:19 | × | finsternis quits (~X@23.226.237.192) (Ping timeout: 240 seconds) |
| 2025-10-30 09:35:21 | <tomsmeding> | now you can still offer fmap and <*> as user API to your library if you want, that's independent from all this |
| 2025-10-30 09:35:42 | → | Googulator85 joins (~Googulato@2a01-036d-0106-03fa-9dbb-a0af-2124-a319.pool6.digikabel.hu) |
| 2025-10-30 09:35:45 | × | Googulator32 quits (~Googulato@2a01-036d-0106-03fa-9dbb-a0af-2124-a319.pool6.digikabel.hu) (Quit: Client closed) |
| 2025-10-30 09:36:32 | <tomsmeding> | data Expr a where { Constant :: a -> Expr a ; App :: Expr (a -> b) -> Expr a -> Expr b ; AddSeries :: Expr (TS D -> TS D -> TS D) ; ... } |
| 2025-10-30 09:37:12 | <tomsmeding> | instance Functor Expr where fmap f e = App (Constant f) e |
| 2025-10-30 09:37:16 | × | Frostillicus quits (~Frostilli@pool-71-174-119-69.bstnma.fios.verizon.net) (Ping timeout: 256 seconds) |
| 2025-10-30 09:37:28 | <tomsmeding> | instance Applicative Expr where { pure = Constant ; (<*>) = App } |
| 2025-10-30 09:38:01 | <tomsmeding> | from my best understanding of what you want to do, I think this is the most understandable |
| 2025-10-30 09:38:14 | <kuribas> | tomsmeding: the problem with fmap is that it introduces lambdas in my AST, which I cannot transform or inspect. |
| 2025-10-30 09:38:21 | <tomsmeding> | well, yeah |
| 2025-10-30 09:38:21 | → | finsternis joins (~X@23.226.237.192) |
| 2025-10-30 09:38:38 | <kuribas> | I want some "lifted fmap", which works over (Formula (a -> b)), not (a -> b) |
| 2025-10-30 09:38:44 | <tomsmeding> | kuribas: but you know that those introduced functions do not perform any query operations |
| 2025-10-30 09:39:15 | <tomsmeding> | kuribas: then presumably you also don't want a general `pure` |
| 2025-10-30 09:39:19 | <kuribas> | Which introduced functions? |
| 2025-10-30 09:39:25 | <tomsmeding> | because `fmap f x = pure f <*> x` |
| 2025-10-30 09:39:36 | <kuribas> | yeah, pure would introduce lambdas. |
| 2025-10-30 09:39:38 | × | bgt32 quits (~keutoi@106.222.233.20) (Ping timeout: 244 seconds) |
| 2025-10-30 09:39:46 | <tomsmeding> | kuribas: you say "lambdas", I say "functions" because not every function is a literal lambda expression :) |
| 2025-10-30 09:39:50 | <tomsmeding> | "closures" is also correct |
| 2025-10-30 09:39:55 | <kuribas> | sure |
| 2025-10-30 09:40:03 | <kuribas> | I did too much Python :) |
| 2025-10-30 09:40:20 | <kuribas> | Though lambdas in python are thorougly broken... |
| 2025-10-30 09:40:23 | <tomsmeding> | right, so if you want <*> but no general pure and no fmap at all, then define your own <*>-like operator |
| 2025-10-30 09:40:28 | <tomsmeding> | $* or something |
| 2025-10-30 09:40:32 | <tomsmeding> | kuribas: they are |
| 2025-10-30 09:40:47 | <tomsmeding> | and forget about Functor and Applicative at all |
| 2025-10-30 09:41:26 | <tomsmeding> | and if you have some `Constant :: ... => a -> Expr a` operation, don't forget to constrain it sufficiently that only constants you actually know how to deal with fit in there :) |
| 2025-10-30 09:41:38 | <kuribas> | I am currently using python for this project, but the language is not very expressive for this timeseries language. I wanted to model it in haskell first. |
| 2025-10-30 09:42:00 | <kuribas> | tomsmeding: indeed, Constant should be limited to some types. |
| 2025-10-30 09:42:08 | <tomsmeding> | doesn't python allow you to override function application on class instances? |
| 2025-10-30 09:42:22 | <kuribas> | yes it does. |
| 2025-10-30 09:42:36 | <kuribas> | I can build a formula language. But I cannot statically type id. |
| 2025-10-30 09:42:39 | <kuribas> | it |
| 2025-10-30 09:42:44 | <tomsmeding> | so that removes the need for a special-purpose application operator (my $*, modelled after <*>) |
| 2025-10-30 09:42:49 | <tomsmeding> | right |
| 2025-10-30 09:43:16 | × | srazkvt quits (~sarah@user/srazkvt) (Quit: Konversation terminated!) |
| 2025-10-30 09:43:20 | → | merijn joins (~merijn@77.242.116.146) |
| 2025-10-30 09:43:26 | <tomsmeding> | kuribas: ok so the answer to your initial question is just "yes" |
| 2025-10-30 09:43:31 | → | Frostillicus joins (~Frostilli@pool-71-174-119-69.bstnma.fios.verizon.net) |
| 2025-10-30 09:43:48 | × | trickard_ quits (~trickard@cpe-61-98-47-163.wireline.com.au) (Read error: Connection reset by peer) |
| 2025-10-30 09:43:55 | <tomsmeding> | except that the fact that TimeSeries has fmap and <*> is irrelevant here |
| 2025-10-30 09:44:01 | → | trickard_ joins (~trickard@cpe-61-98-47-163.wireline.com.au) |
| 2025-10-30 09:44:07 | <tomsmeding> | Expr will _not_ have fmap and <*> |
| 2025-10-30 09:44:16 | <kuribas> | Maybe I just to Expr f a where PureDouble :: Double -> Expr Double; FMap :: f (a -> b) -> Expr a -> Expr b; FApp :: Expr (a -> b) -> Expr a -> Expr b; ... |
| 2025-10-30 09:44:29 | <tomsmeding> | remove the f argument to Expr |
| 2025-10-30 09:44:32 | <tomsmeding> | but yes, that |
| 2025-10-30 09:44:49 | <tomsmeding> | oh you're using f; why have FMap too? |
| 2025-10-30 09:44:53 | <kuribas> | ah, but I liked the idea that I can use this to reduce to value... |
| 2025-10-30 09:44:54 | <tomsmeding> | isn't FApp enough? |
| 2025-10-30 09:45:10 | <tomsmeding> | what will you instantiate f to? |
| 2025-10-30 09:45:47 | <kuribas> | "Formula" for the AST, "Identity" for the result. |
| 2025-10-30 09:46:01 | <tomsmeding> | how is Formula different from Expr? |
| 2025-10-30 09:46:10 | <kuribas> | maybe not :) |
| 2025-10-30 09:46:23 | <tomsmeding> | I feel like you want your evaluator to be Expr a -> IO a |
| 2025-10-30 09:46:48 | <kuribas> | so FormulaExpr :: Formula a -> Expr a ? |
| 2025-10-30 09:46:54 | <tomsmeding> | what even is Formula lol |
| 2025-10-30 09:47:09 | <kuribas> | tomsmeding: just a finite set of functions. |
| 2025-10-30 09:47:14 | × | Frostillicus quits (~Frostilli@pool-71-174-119-69.bstnma.fios.verizon.net) (Remote host closed the connection) |
| 2025-10-30 09:47:24 | <kuribas> | For example operations supported by a database. |
| 2025-10-30 09:47:34 | <kuribas> | as a GADT |
| 2025-10-30 09:47:36 | → | Frostillicus joins (~Frostilli@pool-71-174-119-69.bstnma.fios.verizon.net) |
| 2025-10-30 09:47:39 | <tomsmeding> | I would call that Operation, or Function, perhaps |
| 2025-10-30 09:47:44 | <tomsmeding> | PrimOp, maybe |
| 2025-10-30 09:47:45 | <kuribas> | right |
| 2025-10-30 09:47:58 | <kuribas> | It's called formula in our current lisp system :) |
| 2025-10-30 09:48:03 | <tomsmeding> | but in that case: yes |
| 2025-10-30 09:48:08 | <tomsmeding> | ah |
| 2025-10-30 09:48:28 | <tomsmeding> | a "formula", to me, is an expression involving functions and arguments and stuff |
| 2025-10-30 09:48:52 | <tomsmeding> | x^2 + sqrt(y) is a formula; sqrt is a function |
| 2025-10-30 09:49:10 | <kuribas> | Formula a where SumSeries :: Formula ([Series Double] -> Series Double); ... |
| 2025-10-30 09:50:13 | <tomsmeding> | right, so I'll just read DbOperation where you write Formula |
| 2025-10-30 09:50:34 | <kuribas> | No, because it should be abstracted from DB. |
| 2025-10-30 09:50:39 | × | Googulator85 quits (~Googulato@2a01-036d-0106-03fa-9dbb-a0af-2124-a319.pool6.digikabel.hu) (Quit: Client closed) |
| 2025-10-30 09:50:43 | → | Googulator95 joins (~Googulato@2a01-036d-0106-03fa-9dbb-a0af-2124-a319.pool6.digikabel.hu) |
| 2025-10-30 09:50:46 | <merijn> | kuribas: So you're just trying to defunctionalize your timeseries operations? |
| 2025-10-30 09:50:48 | <tomsmeding> | okay but it's still an operation, not a combination of operations |
| 2025-10-30 09:50:49 | <kuribas> | And it's pure, not an operation. |
| 2025-10-30 09:50:57 | <tomsmeding> | sqrt is an operation, not a formula |
| 2025-10-30 09:51:05 | <tomsmeding> | sqrt(x) is a formula |
| 2025-10-30 09:51:20 | <tomsmeding> | your Formula has sqrt, not sqrt(x), hence I call it Operation, not Formula :p |
| 2025-10-30 09:51:35 | <kuribas> | But then this is more like a formula, since it doesn't have actual operations? |
| 2025-10-30 09:51:55 | <kuribas> | Anyway, let's call it Function then :) |
| 2025-10-30 09:52:06 | <tomsmeding> | https://github.com/AccelerateHS/accelerate/blob/master/src/Data/Array/Accelerate/AST.hs#L661-L753 |
| 2025-10-30 09:52:56 | <kuribas> | What the difference between operation and function? |
| 2025-10-30 09:53:04 | <tomsmeding> | opinion |
All times are in UTC.