Home freenode/#haskell: Logs Calendar

Logs: freenode/#haskell

←Prev  Next→ 502,152 events total
2021-03-17 00:26:44 <fen> in a haskell program, i want to be able to declare values of this kind of "deep" polynomial
2021-03-17 00:26:57 <fen> so i just need a representation of it, which i dont want to have to use HLists for
2021-03-17 00:26:58 <Gurkenglas> May I see the code that turned out a drag?
2021-03-17 00:27:19 × sw1nn quits (~sw1nn@2a00:23c7:622f:2c00:377a:cf20:5183:83de) (Ping timeout: 272 seconds)
2021-03-17 00:27:54 <Gurkenglas> https://hackage.haskell.org/package/bound-2.0.3/docs/Bound.html may be what you want
2021-03-17 00:28:04 × dhil quits (~dhil@80.208.56.181) (Ping timeout: 256 seconds)
2021-03-17 00:28:06 × Deide quits (~Deide@217.155.19.23) (Quit: Seeee yaaaa)
2021-03-17 00:28:42 <fen> wow, thats perfect
2021-03-17 00:30:23 <fen> actually i changed my mind, its overkill
2021-03-17 00:30:59 <Gurkenglas> ekmett, building the libraries you're gonna need in 9 years. he works at MIRI lately, guess what that means for AI timelines :P
2021-03-17 00:31:09 <fen> since i can refer to things by position... i guess the lookup over list version is gonna have to do...
2021-03-17 00:33:33 ph88_ joins (~ph88@2a02:8109:9e00:7e5c:85cc:3a34:36cf:1a53)
2021-03-17 00:33:38 × NinjaTrappeur quits (~ninja@unaffiliated/ninjatrappeur) (Ping timeout: 264 seconds)
2021-03-17 00:34:09 acarrico joins (~acarrico@dhcp-68-142-39-249.greenmountainaccess.net)
2021-03-17 00:34:17 × cole-h_ quits (~cole-h@c-73-48-197-220.hsd1.ca.comcast.net) (Ping timeout: 265 seconds)
2021-03-17 00:34:41 <fen> i guess the "part thats a drag" is basically just having to have values that contain the index values and wanting to use lengthed lists to preven it accessing forwards terms
2021-03-17 00:35:31 <fen> and the only reason its a drag is because i cant write abstractions over all these parametric lengthed containers
2021-03-17 00:36:51 <fen> so then my program is a list of lines, on each line a variable indexed by the line number is defined as a sum using predfined opperators and having access to the values defined on previous lines
2021-03-17 00:37:05 <fen> the whole thing is parametric and so can be tuned
2021-03-17 00:37:40 <fen> so its like a deep net that can be initialised by, and read off into *polynomials*
2021-03-17 00:38:33 <Gurkenglas> you just want something that can be interpreted as either an imperative program or a polynomial right
2021-03-17 00:39:01 <fen> well you kind of compile it to the polynomial form by rewriting the terms
2021-03-17 00:39:16 <fen> the important thing is the initialisation
2021-03-17 00:39:16 sw1nn joins (~sw1nn@2a00:23c7:622f:2c00:b196:7c21:3dc:6adc)
2021-03-17 00:39:41 <fen> since a polynomial fit surface is easy to identify, but normally impossible to use as an initial condition
2021-03-17 00:40:08 <solidus-river> huh, i'm running into an issue i'm not sure how to fix with the type system and maybe
2021-03-17 00:40:11 <solidus-river> https://paste.tomsmeding.com/9E5msPRS
2021-03-17 00:41:01 <Gurkenglas> @let DoubleTerm = Halt | Let Double (Double -> DoubleTerm)
2021-03-17 00:41:01 <lambdabot> Parse failed: Parse error: |
2021-03-17 00:41:07 <Gurkenglas> @let data DoubleTerm = Halt | Let Double (Double -> DoubleTerm)
2021-03-17 00:41:09 <lambdabot> Defined.
2021-03-17 00:41:32 NinjaTrappeur joins (~ninja@unaffiliated/ninjatrappeur)
2021-03-17 00:41:54 <monochrom> solidus-river: You need an extra data constructor, e.g., newtype Funny = MkFunny (Maybe Int).
2021-03-17 00:42:41 <monochrom> I have chosen MkFunny to be the name of the data constructor. You can replace it by a name of your choice.
2021-03-17 00:42:45 <fen> would anyone like to help me write it?
2021-03-17 00:42:58 dfeuer joins (~dfeuer@pool-173-79-253-62.washdc.fios.verizon.net)
2021-03-17 00:43:14 <solidus-river> monochrom: thanks! so whenever you do a newType if your going to be creating it you shoudl add some extra info in the constructor?
2021-03-17 00:43:51 <monochrom> This is not extra info. This is just needing a constructor, and it needing a name.
2021-03-17 00:44:30 <Gurkenglas> > let program = Let 1 $ \x -> Let 2 $ \y -> Let (x+y) $ \a1 -> Let (y+a1/2) $ \a2 -> Let (a1 * a2) $ \a3 -> Halt in program -- fen
2021-03-17 00:44:32 <lambdabot> Let 1.0 <Double -> DoubleTerm>
2021-03-17 00:45:24 <solidus-river> huh, i'm confused about data vs newtype
2021-03-17 00:46:00 <monochrom> They share commonalities. And then you can understand "newtype" as "data" but severe restrictions.
2021-03-17 00:46:10 <solidus-river> what you said worked for newtype but i also had a `newtype SimEvent = Int ByteString` but i had to change it to `data SimEvent = MkEvent Int Bytestring`
2021-03-17 00:46:55 <Axman6> newtypes can specifically only wrap a single type
2021-03-17 00:47:02 <monochrom> "newtype" allows one field only. That's why. If you want "I have 2 fields, an Int field and a ByteString field", you're forced back to "data".
2021-03-17 00:47:19 <Gurkenglas> @let values :: DoubleTerm -> [Double]; values Halt = []; values (Let x f) = x : values (f x)
2021-03-17 00:47:21 <lambdabot> Defined.
2021-03-17 00:47:25 <Axman6> they are a type safe alias for another type - it's in the name, it basically gives a new type to an existing type
2021-03-17 00:47:32 <Gurkenglas> > values $ Let 1 $ \x -> Let 2 $ \y -> Let (x+y) $ \a1 -> Let (y+a1/2) $ \a2 -> Let (a1 * a2) $ \a3 -> Halt
2021-03-17 00:47:34 <lambdabot> [1.0,2.0,3.0,3.5,10.5]
2021-03-17 00:47:59 <solidus-river> monochrom: thanks, wasn't sure if i was doingsomething wrong byt changing it
2021-03-17 00:48:39 <Axman6> newtype Password = Password ByteString -- PAssword is distinct from ByteString in the type system, but at runtime is the same as ByteString, which might be important for performance
2021-03-17 00:50:45 <fen> Gurkenglas: thats pretty rad, only using one lambda at each stage just to bring it into haskell scope
2021-03-17 00:51:53 <solidus-river> Axman6 thanks, so if i want a newtype for my other type i need to find some tuple type holder, but that might be just extra work for nothing at this point
2021-03-17 00:52:38 <fen> Gurkenglas: the problem is that i dont know how to generate such an expression progematically
2021-03-17 00:52:46 <monochrom> Yes, "newtype P = MkP (Int, BS)" is OK. But more tedious than "data P = MkP Int BS".
2021-03-17 00:52:52 <Gurkenglas> fen, from what input?
2021-03-17 00:53:30 <monochrom> Then again you may also consider using (Int, BS) directly and not bother thinking up a type name.
2021-03-17 00:53:38 <fen> well its a polynomial, so just a product of Double powers which with an overall multiplicative weighting are the parameters
2021-03-17 00:54:02 <Axman6> solidus-river: well, newtype SimEvent = SimEvent (Int, ByteString) works, but is probably more annoying than data SimEvent = SimEvent Int ByteString (and if you need it, data SimEvent = SimEvent {-# UNPACK #-} !Int {-# UNPACK #-} !ByteString might be even better in terms of performance, if you don't need laziness)
2021-03-17 00:54:20 <fen> 2 * x**1.1 * y**2
2021-03-17 00:54:42 <fen> so i guess i need a lengthed list of input variables aswell
2021-03-17 00:54:53 rajivr joins (uid269651@gateway/web/irccloud.com/x-uascrnncsdwthllt)
2021-03-17 00:55:11 <fen> note these are just the monomials appearing on each line
2021-03-17 00:55:37 <Gurkenglas> fen, i dont get it, what example input value would you like me to write a program to map to what output value
2021-03-17 00:55:42 <solidus-river> Axman what does the UNPACK macro do? also I'm reading that forkIO is pre-emptive on memory allocation, does that mean I should be taking extra care when trying to do multiThreading on different sockets with forkIO? (manual sleeps etc)
2021-03-17 00:55:46 <fen> the whole thing has a complicated number of parameters, but you can just lookup over the few most recent terms
2021-03-17 00:56:02 <solidus-river> i'm ending my loops with yield, but i'm worried if i'm waiting for data over a socket for 10 seconds other threads are doing squat
2021-03-17 00:57:41 × codygman` quits (~user@47.186.207.161) (Ping timeout: 265 seconds)
2021-03-17 00:58:01 <fen> polynomial (Cons x xs) a@(Cons x (Cons y Empty)) -> Cons (monomial x a) $ polynomial xs a
2021-03-17 00:58:35 × zebrag quits (~inkbottle@aaubervilliers-654-1-101-29.w86-212.abo.wanadoo.fr) (Quit: Konversation terminated!)
2021-03-17 00:58:58 zebrag joins (~inkbottle@aaubervilliers-654-1-101-29.w86-212.abo.wanadoo.fr)
2021-03-17 00:59:07 <fen> polynomial :: List (n::Nat) ... argh
2021-03-17 00:59:18 <fen> cant write the contents type for the type of x
2021-03-17 00:59:26 <fen> because it has variable length
2021-03-17 00:59:38 × jespada quits (~jespada@90.254.243.187) (Ping timeout: 245 seconds)
2021-03-17 00:59:51 <fen> so the list has to have length parametric entries
2021-03-17 00:59:59 <fen> very complicated, sry
2021-03-17 01:00:35 <Axman6> solidus-river: UNPACK changes the above definition from the C equivalent of struct { int * theInt; byteString * theByteString } into struct { int theInt; int byteStringLength; uint8_t * theByteStringData } - it removes a level of indirection by putting the Int ans the firlds of the bytestring directly into the SimEvent constructor (in a way you don't need to care about reconstructing them)
2021-03-17 01:00:36 <Gurkenglas> so pretend haskell is less statically typed and risk that i will not implement the correct most static type
2021-03-17 01:01:06 <fen> then i guess you just put (:) []
2021-03-17 01:01:41 × royal_screwup21 quits (52254809@gateway/web/cgi-irc/kiwiirc.com/ip.82.37.72.9) (Quit: Connection closed)
2021-03-17 01:01:47 <Gurkenglas> exference might do that but im trying to guess what you want.
2021-03-17 01:02:00 royal_screwup21 joins (52254809@gateway/web/cgi-irc/kiwiirc.com/ip.82.37.72.9)
2021-03-17 01:02:09 jespada joins (~jespada@90.254.243.187)
2021-03-17 01:02:22 <solidus-river> Axman6: thats super cool, didn't know it was possible to get that level of perf control
2021-03-17 01:02:33 jacks2 joins (~bc8134e3@217.29.117.252)
2021-03-17 01:02:43 <fen> Polynomial :: [[Double]] -> [Double] -> Polynomial
2021-03-17 01:02:47 <Gurkenglas> (Cons x xs) a@(Cons x (Cons y Empty)) binds x twice, are you sure?
2021-03-17 01:02:57 <fen> no thats a typo
2021-03-17 01:03:09 <Gurkenglas> rewrite that input-output pair then
2021-03-17 01:03:10 <Axman6> solidus-river: it's no C or Ada level of control, but it can help with locality
2021-03-17 01:04:31 mceier_ joins (~mceier@89-68-132-187.dynamic.chello.pl)
2021-03-17 01:04:46 <Axman6> I'm looking forward to Word*# becomming actually 8 bits, that'll be a nice day
2021-03-17 01:05:26 <solidus-river> Axman6: in what context do you use haskell?
2021-03-17 01:05:47 <fen> polynomial [(1.1,[1,2]),(2.2,[3,4])] [5,6] = 1.1 * 5**1 * 6**2 + polynomial [(2.2,[3,4])] [5,6]
2021-03-17 01:06:14 <Axman6> All of them
2021-03-17 01:06:22 <Axman6> Haskell is Life
2021-03-17 01:06:22 <fen> oh no! it doesnt use the created value
2021-03-17 01:07:09 × royal_screwup21 quits (52254809@gateway/web/cgi-irc/kiwiirc.com/ip.82.37.72.9) (Ping timeout: 265 seconds)

All times are in UTC.