Home liberachat/#haskell: Logs Calendar

Logs: liberachat/#haskell

←Prev  Next→ 1,804,030 events total
2021-08-09 06:43:12 <Cajun> and any actual work done in python is always done in C, its too slow for any intensive applications lol
2021-08-09 06:43:20 <dsal> I never liked java, though.
2021-08-09 06:43:21 × Athas quits (athas@sigkill.dk) (Quit: ZNC 1.8.2 - https://znc.in)
2021-08-09 06:43:53 <Cajun> i have a soft spot for java, it was the first language i learned ♥
2021-08-09 06:44:09 <dsal> Even though I used to use jython to prototype my ideas...
2021-08-09 06:44:24 <Cajun> what in the world is jython and do i want to know?
2021-08-09 06:44:43 × _xor quits (~xor@74.215.232.67) (Quit: WeeChat 3.2)
2021-08-09 06:45:14 <dsal> I learned java after writing a bunch of Eiffel so I got into it from the perspective of doing everything wrong. Then I learned smalltalk and found a new way they were doing everything wrong. Heh
2021-08-09 06:45:38 × Sgeo quits (~Sgeo@user/sgeo) (Read error: Connection reset by peer)
2021-08-09 06:45:51 Athas joins (athas@sigkill.dk)
2021-08-09 06:45:57 <dsal> Jython was a python implementation in java. Could use java classes as python classes and stuff.
2021-08-09 06:46:02 × aplainzetakind quits (~johndoe@captainludd.powered.by.lunarbnc.net) (Ping timeout: 258 seconds)
2021-08-09 06:46:21 <dsal> Java doesn't repl very well on its own
2021-08-09 06:46:28 sander joins (~sander@user/sander)
2021-08-09 06:46:33 <Cajun> i do like thinking of the means of approaching a task in java and in haskell and how they differ. one that ive thought of recently is heterogeneous lists
2021-08-09 06:47:26 × Guest246 quits (~chris@81.96.113.213) (Ping timeout: 268 seconds)
2021-08-09 06:47:46 <Cajun> and specifically being of their lowest possible type, not all `Objects` , thats basically cheating :p
2021-08-09 06:47:55 <dsal> The java way lets you defer as much as you want to runtime errors. :)
2021-08-09 06:48:20 takuan joins (~takuan@178-116-218-225.access.telenet.be)
2021-08-09 06:48:31 <tomsmeding> lechner: compiling aeson and vector takes >2GB of ram in my experience, and the world depends on those things
2021-08-09 06:48:35 dhouthoo joins (~dhouthoo@178-117-36-167.access.telenet.be)
2021-08-09 06:49:00 Guest71 joins (~Guest71@217.156.31.64)
2021-08-09 06:49:10 Guest71 is now known as random-jellyfish
2021-08-09 06:49:18 <dsal> Yeah. It was a little confusing for a while trying to figure out how to store values of different types in Haskell. I eventually just stopped wanting to do that. :)
2021-08-09 06:50:19 <Cajun> the sad part is (afaik) you can only use HLists if they are known during compile time
2021-08-09 06:50:42 × favonia quits (~favonia@user/favonia) (Ping timeout: 240 seconds)
2021-08-09 06:51:30 <Axman6> surely you could use singletons to have synamic ones, I feel like jle`'s posts on using the library given an example of being able to load what is essentially hlists at runtime
2021-08-09 06:52:02 <tomsmeding> Cajun: pattern-matching on gadts gives you type information, so surely you can build and work with HLists at runtime
2021-08-09 06:52:14 Akronymus joins (~Akronymus@85.31.8.181)
2021-08-09 06:53:06 <Cajun> well what about with just a lifted list and bog-standard types like `'[Int, Char, Identity (Maybe Bool)]`
2021-08-09 06:53:15 spruit11 joins (~quassel@2a02:a467:ccd6:1:90c7:da5b:b845:b6e9)
2021-08-09 06:53:24 <Axman6> that's usually how we represent HLists these days
2021-08-09 06:53:32 <Akronymus> What does the identity type actually do?
2021-08-09 06:53:59 <Cajun> its useful when you want to stuff something in a monad (like with Repa's `computeP` )
2021-08-09 06:54:07 <Axman6> data HList (xs :: [Type]) where HNil :: HList '[]; HCons :: a -> HList xs -> HList (x ': xs)
2021-08-09 06:54:42 <Cajun> yeah thats what i figured Axman6 , and those can only be used when they are known during compile time
2021-08-09 06:55:15 <Axman6> Akronymus: it's the trivial monad, it can be used in places whewre a function requires a monad but you don't need any monadic effects
2021-08-09 06:55:21 <Axman6> Cajun: why do you say that?
2021-08-09 06:55:36 <Axman6> It's not an unreasonable thing to say, but it's also not correct :P
2021-08-09 06:56:41 aplainzetakind joins (~johndoe@captainludd.powered.by.lunarbnc.net)
2021-08-09 06:57:05 <tomsmeding> % data HList xs where HNil :: HList '[] ; HCons :: a -> HList xs -> HList (a ': xs)
2021-08-09 06:57:06 <yahb> tomsmeding:
2021-08-09 06:57:36 <Akronymus> Axman6 Thanks. So it basically turns the value into a function that returns the value?
2021-08-09 06:57:37 <tomsmeding> % hlength :: HList xs -> Int ; hlength HNil = 0 ; hlength (HCons _ xs) = 1 + hlength xs
2021-08-09 06:57:37 <yahb> tomsmeding:
2021-08-09 06:57:43 chele joins (~chele@user/chele)
2021-08-09 06:57:49 <Axman6> % :t HCons 'x' (HCons True HNil)
2021-08-09 06:57:49 <yahb> Axman6: HList '[Char, Bool]
2021-08-09 06:57:58 × spruit11 quits (~quassel@2a02:a467:ccd6:1:90c7:da5b:b845:b6e9) (Ping timeout: 256 seconds)
2021-08-09 06:58:07 <Cajun> idk why but i remember reading that, maybe it was on something else
2021-08-09 06:58:12 <tomsmeding> % data Some f where Some :: f a -> Some f
2021-08-09 06:58:12 <yahb> tomsmeding:
2021-08-09 06:58:32 × oxide quits (~lambda@user/oxide) (Ping timeout: 268 seconds)
2021-08-09 06:59:09 <tomsmeding> % hrep :: Int -> a -> Some HList ; hrep 0 _ = Some HNil ; hrep n x = case hrep (n-1) x of Some xs -> Some (HCons x xs)
2021-08-09 06:59:09 <yahb> tomsmeding:
2021-08-09 06:59:38 <tomsmeding> % case hrep 5 'a' of Some xs -> hlength xs
2021-08-09 06:59:38 <yahb> tomsmeding: 5
2021-08-09 06:59:44 <tomsmeding> Cajun: runtime hlists!
2021-08-09 07:00:11 spruit11 joins (~quassel@2a02:a467:ccd6:1:90c7:da5b:b845:b6e9)
2021-08-09 07:00:33 <Cajun> well thats abusing existentials isnt it?
2021-08-09 07:00:37 <tomsmeding> hrep produces an hlist of unknown type list, so I have to either hide the type parameter with an existential, like I do with Some here, or use CPS
2021-08-09 07:00:44 <Cajun> cheater :P
2021-08-09 07:01:00 <Axman6> that's basically the whole point, to use existentials
2021-08-09 07:01:27 <tomsmeding> % hrep' :: Int -> a -> (forall xs. HList xs -> r) -> r ; hrep 0 _ k = k HNil ; hrep n x k = hrep (n-1) x $ \xs -> k (HCons x xs)
2021-08-09 07:01:27 <yahb> tomsmeding: ; <interactive>:92:1: error:; The type signature for hrep' lacks an accompanying binding; Perhaps you meant `hrep' (Defined at <interactive>:92:56)
2021-08-09 07:01:43 _xor joins (~xor@74.215.232.67)
2021-08-09 07:01:43 <tomsmeding> % hrep' :: Int -> a -> (forall xs. HList xs -> r) -> r ; hrep' 0 _ k = k HNil ; hrep' n x k = hrep (n-1) x $ \xs -> k (HCons x xs)
2021-08-09 07:01:43 <yahb> tomsmeding: ; <interactive>:93:93: error:; * Couldn't match expected type: (HList xs0 -> r) -> r; with actual type: Some HList; * The first argument of ($) takes one value argument, but its type `Some HList' has none; In the expression: hrep (n - 1) x $ \ xs -> k (HCons x xs); In an equation for hrep': hrep' n x k = hrep (n - 1) x $ \ xs -> k (HCons x xs); * Relevant binding
2021-08-09 07:01:49 <Cajun> i know you can do that with Vectors and `Any` along with managing the type level list intact and identical with the vector along with a bit of `unsafeCoerce`
2021-08-09 07:02:04 <tomsmeding> % hrep' :: Int -> a -> (forall xs. HList xs -> r) -> r ; hrep' 0 _ k = k HNil ; hrep' n x k = hrep' (n-1) x $ \xs -> k (HCons x xs)
2021-08-09 07:02:04 <yahb> tomsmeding:
2021-08-09 07:02:22 <tomsmeding> % hrep' 5 'a' (\xs -> hlength xs)
2021-08-09 07:02:22 <yahb> tomsmeding: 5
2021-08-09 07:02:26 <tomsmeding> Cajun: better? :P
2021-08-09 07:02:39 <tomsmeding> Also existentials != unsafeCoerce
2021-08-09 07:03:08 elf_fortrez joins (~elf_fortr@adsl-72-50-4-51.prtc.net)
2021-08-09 07:03:09 <Cajun> i never meant that, i just meant that you can get the type back by managing a typelevel list and a list of existentials
2021-08-09 07:03:17 <Cajun> not the type the value*
2021-08-09 07:03:36 × elf_fortrez quits (~elf_fortr@adsl-72-50-4-51.prtc.net) (Write error: Broken pipe)
2021-08-09 07:03:50 Obo joins (~roberto@70.pool90-171-81.dynamic.orange.es)
2021-08-09 07:03:58 × Erutuon quits (~Erutuon@user/erutuon) (Ping timeout: 272 seconds)
2021-08-09 07:04:02 elf_fortrez joins (~elf_fortr@adsl-72-50-4-118.prtc.net)
2021-08-09 07:04:03 <tomsmeding> If you already know what type is in there, you mean?
2021-08-09 07:04:12 <Cajun> yup! :)
2021-08-09 07:04:14 <tomsmeding> Otherwise you don't know what to unsafeCoerce to
2021-08-09 07:04:38 <tomsmeding> Can also put a TypeRep in the HList with it
2021-08-09 07:05:07 <Axman6> superrecord uses a SmallArray Any under the hood, so you avoid the linear overhead of an actual linked list
2021-08-09 07:05:08 epolanski joins (uid312403@id-312403.brockwell.irccloud.com)
2021-08-09 07:05:12 <Cajun> im thinking of a specific example of OpenProducts and this function: https://paste.tomsmeding.com/hHTlYqIL
2021-08-09 07:05:23 <Axman6> and IIRC generics-sop is looking at doing the same thing
2021-08-09 07:06:42 <Cajun> tomsmeding: like a tuple of the TypeRep and Existential?
2021-08-09 07:07:26 <tomsmeding> Well, using an HList1
2021-08-09 07:08:00 <tomsmeding> % data HList1 f xs where HNil1 :: HList1 f '[] ; HCons :: f a -> HList1 f xs -> HList1 f (a ': xs)
2021-08-09 07:08:00 <yahb> tomsmeding:
2021-08-09 07:08:10 <tomsmeding> Oh crap shadowing HCons now
2021-08-09 07:08:33 <tomsmeding> Then put in something that pairs a value with a something describing its type
2021-08-09 07:09:57 <Cajun> man type level stuff sometimes throws me for a loop, so many extensions to remember and its just so different from anything else lol
2021-08-09 07:10:16 × euouae quits (~euouae@user/euouae) (Ping timeout: 246 seconds)
2021-08-09 07:11:14 <tomsmeding> Also, real runtime use case of plain HList (so not HList1): expression evaluation on an type-safe AST represented with a GADT
2021-08-09 07:11:19 <tomsmeding> A tagless evaluator

All times are in UTC.