Home freenode/#haskell: Logs Calendar

Logs: freenode/#haskell

←Prev  Next→ 502,152 events total
2020-11-05 19:28:40 <lambdabot> +++ OK, passed 100 tests.
2020-11-05 19:28:50 × twopoint718 quits (~cjw@fsf/member/twopoint718) (Quit: My MacBook has gone to sleep. ZZZzzz…)
2020-11-05 19:29:22 <tomsmeding> so let combine x y = hash (x `xor` permute y)
2020-11-05 19:29:29 <tomsmeding> merkle trees?
2020-11-05 19:29:35 arampa joins (5e454e4c@94.69.78.76)
2020-11-05 19:29:48 <tomjaguarpaw> Well, I am basically trying to implement a merkle tree.
2020-11-05 19:29:55 <tomjaguarpaw> The question is what hash algorithm I should use.
2020-11-05 19:30:03 <tomjaguarpaw> They seem to use one called "tiger hash"
2020-11-05 19:30:34 × todda7 quits (~torstein@ppp-2-84-30-242.home.otenet.gr) (Ping timeout: 256 seconds)
2020-11-05 19:31:51 <tomsmeding> is this not basically asking how to construct a hash that takes arbitrary-length input from one that takes fixed-length input?
2020-11-05 19:32:39 <tomjaguarpaw> No, it's fixed length plus nesting
2020-11-05 19:32:53 <tomjaguarpaw> *arbitrary length plus arbitrary nesting
2020-11-05 19:33:10 <tomjaguarpaw> Well, the arbitrary length is a good start, but has other mitigations
2020-11-05 19:33:56 <tomsmeding> if you can hash two blocks of data into one block of data, you can trivially hash arbitrary-length data, right?
2020-11-05 19:34:17 thir joins (~thir@p200300f27f0b7e00f4e9381c2bf90854.dip0.t-ipconnect.de)
2020-11-05 19:34:32 <tomsmeding> from that perspective, being able to combine two hashes is ~equivalent to being able to handle arbitrary-length data
2020-11-05 19:35:00 aarvar joins (~foewfoiew@c.24.56.239.179.static.broadstripe.net)
2020-11-05 19:35:03 ransom_ joins (~c4264035@c-73-243-2-10.hsd1.co.comcast.net)
2020-11-05 19:35:06 aarvar parts (~foewfoiew@c.24.56.239.179.static.broadstripe.net) ()
2020-11-05 19:35:06 <tomjaguarpaw> I don't think it's so simple in the presence of the property x `combine` x `combine` y == y
2020-11-05 19:35:25 × jfredett quits (~quassel@95.211.153.89) (Ping timeout: 265 seconds)
2020-11-05 19:35:27 <tomjaguarpaw> The Data.Hashable [a] instance also tracks the length of the list for this reason
2020-11-05 19:35:29 <tomsmeding> well you also wouldn't want [x, x, y] to hash to the same as [y]
2020-11-05 19:35:37 <tomsmeding> right
2020-11-05 19:35:37 <tomjaguarpaw> Correct
2020-11-05 19:35:48 <tomjaguarpaw> So Data.Hashable lacks some desirable property
2020-11-05 19:36:10 <int-e> well, (x `combine` x) `combine` y would be kind of okay
2020-11-05 19:36:24 <int-e> with that particular definition
2020-11-05 19:36:45 × ransom quits (c4264035@gateway/vpn/protonvpn/c4264035) (Ping timeout: 240 seconds)
2020-11-05 19:37:37 int-e wonders how terrible combine x y = 3*x `xor` 5*y would be, for non-adverserial purposes of course.
2020-11-05 19:37:58 <tomsmeding> tomjaguarpaw: I see you say that Python's hash works for you; how do you define 'combine' there?
2020-11-05 19:38:27 × thir quits (~thir@p200300f27f0b7e00f4e9381c2bf90854.dip0.t-ipconnect.de) (Ping timeout: 244 seconds)
2020-11-05 19:39:05 × wroathe quits (~wroathe@c-68-54-25-135.hsd1.mn.comcast.net) (Ping timeout: 240 seconds)
2020-11-05 19:39:06 <tomsmeding> I do believe that something of the form of 'combine x y = (x `rotateL` 15) `xor` (y `rotateR` 2)' is quite usual
2020-11-05 19:39:31 <arampa> hi, noob question regarding an assignment: I have a custom data type which represents intervals of Int numbers (e.g., (3,5)) and a function which takes a list and generates an interval based on the values of that list. I get the following error: <interactive>:431:1: error: • Ambiguous type variable ‘a0’ arising from a use of ‘print’
2020-11-05 19:39:31 <arampa> prevents the constraint ‘(Show a0)’ from being solved. Probable fix: use a type annotation to specify what ‘a0’ should be. These potential instances exist: instance (Show a, Show b) => Show (Either a b) -- Defined in ‘Data.Either’ instance Show Ordering -- Defined in ‘GHC.Show’ instance Show
2020-11-05 19:39:31 × ggole quits (~ggole@2001:8003:8119:7200:3462:7213:ea5b:f472) (Quit: Leaving)
2020-11-05 19:39:32 <arampa> Integer -- Defined in ‘GHC.Show’ ...plus 24 others ...plus 53 instances involving out-of-scope types (use -fprint-potential-instances to see them all) • In a stmt of an interactive GHCi command: print it
2020-11-05 19:39:48 <int-e> @where paste
2020-11-05 19:39:48 <lambdabot> Help us help you: please paste full code, input and/or output at eg https://paste.tomsmeding.com
2020-11-05 19:40:16 <tomsmeding> should that thing get a proper domain name
2020-11-05 19:40:27 <arampa> https://paste.tomsmeding.com/nmri084o
2020-11-05 19:40:57 <arampa> the interesting thing is that, if I use this function by itself, i.e., not as part of a typeclass, it seems to work fine
2020-11-05 19:41:00 <int-e> tomsmeding: what's improper about it :-P (I imagine it pings you quite a bit though)
2020-11-05 19:41:19 <tomsmeding> arampa: the function by itself looks fine; how are you using it to produce that error?
2020-11-05 19:41:45 <arampa> https://paste.tomsmeding.com/A37O6NQu
2020-11-05 19:41:48 <Uniaika> tomsmeding: 5€ if you manage to get it hosted by haskell.org :P
2020-11-05 19:41:58 × jakob_ quits (~textual@p200300f49f1622009dd67ec3b5219616.dip0.t-ipconnect.de) (Quit: My Laptop has gone to sleep. ZZZzzz…)
2020-11-05 19:42:02 <tomsmeding> Uniaika: life goals
2020-11-05 19:42:30 <tomsmeding> arampa: I assume that you give this definition in a particular instance of that class?
2020-11-05 19:42:33 jakob_ joins (~textual@p200300f49f1622009dd67ec3b5219616.dip0.t-ipconnect.de)
2020-11-05 19:42:35 <tomsmeding> which one? :)
2020-11-05 19:42:44 × jakob_ quits (~textual@p200300f49f1622009dd67ec3b5219616.dip0.t-ipconnect.de) (Client Quit)
2020-11-05 19:42:45 <int-e> arampa: that's not the complete code. please also include the error message (as a comment, for example). but as a guess, your custom datatype could use a "deriving Show".
2020-11-05 19:43:12 jakob_ joins (~textual@p200300f49f1622009dd67ec3b5219616.dip0.t-ipconnect.de)
2020-11-05 19:43:30 × jakob_ quits (~textual@p200300f49f1622009dd67ec3b5219616.dip0.t-ipconnect.de) (Client Quit)
2020-11-05 19:43:46 <arampa> https://paste.tomsmeding.com/YX1a14kM
2020-11-05 19:43:58 <arampa> this is how I'd use it on an empty list, for example
2020-11-05 19:44:02 jakob_ joins (~textual@p200300f49f1622009dd67ec3b5219616.dip0.t-ipconnect.de)
2020-11-05 19:44:05 <tomjaguarpaw> tomsmeding: In Python I would do combine(x, y) == hash((x, y))
2020-11-05 19:44:18 × jakob_ quits (~textual@p200300f49f1622009dd67ec3b5219616.dip0.t-ipconnect.de) (Client Quit)
2020-11-05 19:44:51 <arampa> my goal is to make my Interval type an instance of the Code typeclass. It is already an instance of Show (without using deriving)
2020-11-05 19:44:52 jakob_ joins (~textual@p200300f49f1622009dd67ec3b5219616.dip0.t-ipconnect.de)
2020-11-05 19:45:04 × cr3 quits (~cr3@192-222-143-195.qc.cable.ebox.net) (Ping timeout: 246 seconds)
2020-11-05 19:45:05 × jakob_ quits (~textual@p200300f49f1622009dd67ec3b5219616.dip0.t-ipconnect.de) (Client Quit)
2020-11-05 19:45:33 <int-e> arampa: you also need to specify what the result type should be; it's impossible for ghc to know which instance of `Code` it's supposed to use.
2020-11-05 19:45:54 × conal quits (~conal@107.181.166.217) (Quit: Computer has gone to sleep.)
2020-11-05 19:46:17 <int-e> encode [] :: <whatever your type name is>
2020-11-05 19:46:58 <arampa> encode [] :: Interval works fine
2020-11-05 19:47:22 × Franciman quits (~francesco@host-79-36-167-172.retail.telecomitalia.it) (Quit: Leaving)
2020-11-05 19:48:08 <arampa> but if I do this https://paste.tomsmeding.com/YCKBD5QM
2020-11-05 19:48:11 <int-e> This is a bit obscure, but the `a0` refers to the result type that ghc couldn't infer and is trying to print. The `print` is implicitly added by ghci when evaluating a plain expression
2020-11-05 19:48:53 <tomsmeding> tomjaguarpaw: here's how python does tuple hashes as far as I can see: https://github.com/python/cpython/blob/f522a57ec77921ee2e60bd4ccda3c8daa5a43e95/Objects/tupleobject.c#L368
2020-11-05 19:48:56 <arampa> and I run it this way, https://paste.tomsmeding.com/b4qkf9SN this is what happens
2020-11-05 19:48:59 <int-e> your `encode` is a member of a type class; it could have plenty of different implementations.
2020-11-05 19:49:13 <int-e> so you have to specify the type at the point where `encode` is used.
2020-11-05 19:49:58 × Tario quits (~Tario@198.252.153.28) (Ping timeout: 246 seconds)
2020-11-05 19:50:10 <tomjaguarpaw> tomsmeding: Thanks, yes, I may copy that
2020-11-05 19:50:54 <arampa> so, encode [] :: Interval would be enough for my purposes? I do not use this function in any other functions
2020-11-05 19:51:19 <arampa> or do you mean that I should define Interval in the type signature?
2020-11-05 19:51:23 <arampa> sorry I get a bit confused
2020-11-05 19:52:09 cr3 joins (~cr3@192-222-143-195.qc.cable.ebox.net)
2020-11-05 19:52:17 <int-e> arampa: encode [] :: Interval is sufficient. Annotating that `Empty` value is actually pointless; ghc will infer the type from the constructor.
2020-11-05 19:54:10 <int-e> arampa: If you type `:t encode`, ghci will tell you that the type of `encode` is `Code a => [Int] -> a`. That doesn't mention Interval at all, which is why ghc(i) needs help to determine the result type.
2020-11-05 19:54:34 <arampa> okay I understand, thank you so much!
2020-11-05 19:55:10 acidjnk_new2 joins (~acidjnk@p200300d0c718f6890d36626cfb994f1d.dip0.t-ipconnect.de)
2020-11-05 19:55:18 twopoint718 joins (~cjw@fsf/member/twopoint718)
2020-11-05 19:56:08 tswett joins (aee69d95@unaffiliated/tswett)
2020-11-05 19:56:22 × machinedgod quits (~machinedg@142.169.78.93) (Read error: Connection reset by peer)
2020-11-05 19:58:04 alp joins (~alp@2a01:e0a:58b:4920:51b5:8281:3384:97c9)
2020-11-05 19:58:34 machinedgod joins (~machinedg@207.253.244.210)
2020-11-05 19:59:01 × tswett quits (aee69d95@unaffiliated/tswett) (Remote host closed the connection)
2020-11-05 20:00:09 <fendor> finally, I found someone from university, doing the functional programming course
2020-11-05 20:00:18 <fendor> *from my
2020-11-05 20:00:42 rprije joins (~rprije@124.148.131.132)
2020-11-05 20:01:01 × justsomeguy quits (~justsomeg@unaffiliated/--/x-3805311) ()
2020-11-05 20:01:56 × jollygood2 quits (~bc8165ab@217.29.117.252) (Quit: http://www.okay.uz/ (Session timeout))
2020-11-05 20:03:04 × heatsink quits (~heatsink@107-136-5-69.lightspeed.sntcca.sbcglobal.net) (Remote host closed the connection)
2020-11-05 20:04:15 × justan0theruser quits (~justanoth@unaffiliated/justanotheruser) (Ping timeout: 272 seconds)
2020-11-05 20:05:37 × Rudd0 quits (~Rudd0@185.189.115.103) (Ping timeout: 264 seconds)

All times are in UTC.