Home liberachat/#haskell: Logs Calendar

Logs: liberachat/#haskell

←Prev  Next→ 1,803,439 events total
2021-07-25 17:20:50 <arkanoid> so what I'm asking is if there's a way to raise security level by checking if Int is used or overflow is triggered at runtime in all code, including the imported one
2021-07-25 17:20:59 <davean> Cale: I've really wanted to choose the behaviors for my types :/
2021-07-25 17:21:04 <davean> I've often wanted saturation
2021-07-25 17:21:05 × aliosablack quits (~chomwitt@ppp-94-67-193-120.home.otenet.gr) (Ping timeout: 258 seconds)
2021-07-25 17:21:06 <dsal> Can someone help me with a type definition? I'm trying to do stuff with `linear` such that I can build out arbitrary ranges of points. i.e., I've got `class Projector a b where project :: a -> b -> [a]` and I want to be able to have a `V a` and a value of `a` and produce a list of `V`s from the given point to point + size in every dimension.
2021-07-25 17:21:32 <Cale> I think if you want to use signalling int, you also probably want an interface to its functionality which is entirely unlike Num
2021-07-25 17:21:32 <dsal> So I've got `instance (Enum a, Integral a) => Projector (V2 a) a` which seems to do the right thing, but requires `AllowAmbiguousTypes` to work. That seems odd to me.
2021-07-25 17:21:40 <Cale> i.e. you want operations which produce Maybe results
2021-07-25 17:22:10 <nitrix> (+?) :: SafeNum n => n -> n -> Maybe n ?
2021-07-25 17:22:28 <Cale> Yeah
2021-07-25 17:22:32 × johnw quits (~johnw@2600:1700:cf00:db0:4d8f:94c5:5bf3:4c24) (Ping timeout: 255 seconds)
2021-07-25 17:23:01 <nitrix> Probably annoying to write expressions in, lifting everything all the time.
2021-07-25 17:23:16 <monochrom> "you would go bind"
2021-07-25 17:23:27 Clint squints.
2021-07-25 17:23:30 <arkanoid> nitrix: I might be hunting witches, but it's a safe thing to do if there's no proof that they doesn not exist
2021-07-25 17:23:41 <dsal> The class definition doesn't seem to imply any dependency between `a` and `b` which there probably should be.
2021-07-25 17:23:50 johnw joins (~johnw@76-234-69-149.lightspeed.frokca.sbcglobal.net)
2021-07-25 17:24:46 <dsal> Oh, and that's my answer, I just defined a functional dependency. Neat.
2021-07-25 17:25:05 lavaman joins (~lavaman@98.38.249.169)
2021-07-25 17:28:00 waleee joins (~waleee@2001:9b0:216:8200:d457:9189:7843:1dbd)
2021-07-25 17:28:08 <arkanoid> I also see that the fromInteger function does not return Error/Maybe, but just a Num, which Int is, so that means that also conversion in unchecked by default. https://wiki.haskell.org/Converting_numbers
2021-07-25 17:28:23 × azeem quits (~azeem@dynamic-adsl-84-220-213-65.clienti.tiscali.it) (Ping timeout: 255 seconds)
2021-07-25 17:28:47 <geekosaur> int-cast package
2021-07-25 17:28:50 × LukeHoersten quits (~LukeHoers@user/lukehoersten) (Ping timeout: 255 seconds)
2021-07-25 17:29:06 × lavaman quits (~lavaman@98.38.249.169) (Ping timeout: 240 seconds)
2021-07-25 17:29:19 azeem joins (~azeem@176.200.214.29)
2021-07-25 17:29:55 × merijn quits (~merijn@83-160-49-249.ip.xs4all.nl) (Ping timeout: 265 seconds)
2021-07-25 17:31:43 LukeHoersten joins (~LukeHoers@user/lukehoersten)
2021-07-25 17:32:02 <arkanoid> no, I'm not looking for a solution in my code, I'm looking for a solution that checks if the code I'm importing and calling contains these unchecked errors. As for now I have only 2 solutions: test my calling functions for all input domains OR check manually all the imported/called code
2021-07-25 17:32:23 <nitrix> Ideally both.
2021-07-25 17:33:03 <dsal> arkanoid: This is one of the reasons we like property tests.
2021-07-25 17:34:53 burnsidesLlama joins (~burnsides@client-8-87.eduroam.oxuni.org.uk)
2021-07-25 17:36:05 <arkanoid> it depends on the input domain. I'm dealing with a 25 dimensional model that's already works in python and another imperative language I'm planning to use, but I wanted to learn haskell to get better handle complexity. This is a show stopper to me
2021-07-25 17:36:33 <nitrix> I understand where you're coming from, you now have to trust code written by others instead of relying on the language enforcing these things, which can be frustrating and require additional work if you're the paranoid type. Though, I want to address the "unsafe" you keep bringing up. A mismatch between your expectation and the specification isn't what makes a feature unsafe; it just means your expectations are wrong.
2021-07-25 17:37:21 <nitrix> The code is safe. It exhibits the very behavior it's meant to do -- assuming it's the behavior you wanted.
2021-07-25 17:37:22 <arkanoid> debatable. Overflow check is part of the safe check list
2021-07-25 17:37:40 <nitrix> I disagree.
2021-07-25 17:37:40 × tlaxkit quits (~hexchat@170.253.39.204) (Quit: Leaving)
2021-07-25 17:38:06 × azeem quits (~azeem@176.200.214.29) (Ping timeout: 256 seconds)
2021-07-25 17:38:32 azeem joins (~azeem@dynamic-adsl-84-220-213-65.clienti.tiscali.it)
2021-07-25 17:38:58 × burnsidesLlama quits (~burnsides@client-8-87.eduroam.oxuni.org.uk) (Ping timeout: 240 seconds)
2021-07-25 17:39:20 <arkanoid> nitrix: just check how other high level languages deal with it. C# for example gives the possibility to enable checked calculations (checked block)
2021-07-25 17:39:38 <nitrix> You're conflating "surprising"/"error-prone" with "safety".
2021-07-25 17:39:53 Guest92 joins (~Guest92@50.47.115.102)
2021-07-25 17:40:32 xff0x_ joins (~xff0x@2001:1a81:5200:1d00:bb8d:5843:c31e:244e)
2021-07-25 17:41:14 <arkanoid> overflows compromise program's reliability and security, though safe programming wants you to check that
2021-07-25 17:41:18 <monochrom> I used to defend the status quo of wrap-around because it benefitted some of my niche code. But I don't defend it now, my love of "w00t it does mod 2^64" is very, very niche. Most people don't want that.
2021-07-25 17:42:16 <monochrom> But the status quo doesn't need to be defended. It has been settled for so long that it is too costly to change.
2021-07-25 17:43:27 <monochrom> And while add-on is less costly than change, well let me tell you my favourite Aesop fable.
2021-07-25 17:43:34 <nitrix> A knife has a sharp edge and a blunt edge. You use the sharp edge towards the things it needs to cut and the blunt edge to apply pressure. If you accidently use it in the wrong orientation, you'll hurt yourself, and that's surprising. If it's not clear which side is which, then that's error-prone, but the knife isn't more or less safe because of it. It'll cut on it's sharp edge exactly like it's intended to do, whether it's vegetables or your fingers.
2021-07-25 17:44:06 <monochrom> The mice hold an internation mice conference to discuss how to mitigate the threat of cats.
2021-07-25 17:44:20 <nitrix> I've been on both side of the status-quo. I mostly just think that Haskell's safety has zero to do with it.
2021-07-25 17:44:28 <monochrom> They agree on two resolutions.
2021-07-25 17:44:50 <[exa]> arkanoid: this might sound harsh but if you want to do x^1000 outside of modular arithmetic, you want to do it on paper and not on computer
2021-07-25 17:44:59 <monochrom> 1. A bell is to be worn on the neck of the cat so every mouse can hear the cat coming.
2021-07-25 17:45:07 <monochrom> 2. Someone else should do it.
2021-07-25 17:45:51 lavaman joins (~lavaman@98.38.249.169)
2021-07-25 17:46:20 × Teacup_ quits (~teacup@user/teacup) (Quit: Teacup_)
2021-07-25 17:46:28 <[exa]> arkanoid: also, as famously proven in 1930's, where there are large integers, there won't be any provable security.
2021-07-25 17:47:07 Teacup joins (~teacup@user/teacup)
2021-07-25 17:48:14 mr-red joins (~drd@93-39-151-19.ip76.fastwebnet.it)
2021-07-25 17:50:13 × drd quits (~drd@93-39-151-19.ip76.fastwebnet.it) (Ping timeout: 258 seconds)
2021-07-25 17:50:36 <arkanoid> point is that while Haskell gives good control on the complexity of the task, gives less safety on the output than other imperative languages
2021-07-25 17:50:48 <arkanoid> while being less performant, too
2021-07-25 17:51:27 <nitrix> Here it comes.
2021-07-25 17:53:08 × mr-red quits (~drd@93-39-151-19.ip76.fastwebnet.it) (Ping timeout: 255 seconds)
2021-07-25 17:53:36 × dunkeln quits (~dunkeln@94.129.69.87) (Ping timeout: 265 seconds)
2021-07-25 17:54:11 drd joins (~drd@93-39-151-19.ip76.fastwebnet.it)
2021-07-25 17:55:00 <nitrix> We're thankful of your assessment and will take it into consideration for our next safety training. Safety is very important to us.
2021-07-25 17:55:45 [exa] imports some monadic explosives
2021-07-25 17:58:09 dunkeln joins (~dunkeln@94.129.69.87)
2021-07-25 17:58:44 gehmehgeh joins (~user@user/gehmehgeh)
2021-07-25 17:58:48 × drd quits (~drd@93-39-151-19.ip76.fastwebnet.it) (Read error: Connection reset by peer)
2021-07-25 17:59:34 drd joins (~drd@2001:b07:a70:9f1f:1562:34de:f50f:77d4)
2021-07-25 18:00:52 × gehmehgeh quits (~user@user/gehmehgeh) (Remote host closed the connection)
2021-07-25 18:01:32 gehmehgeh joins (~user@user/gehmehgeh)
2021-07-25 18:02:59 <nitrix> head :: [a] -> a, now that's potentially unsafe, though there's very little chance that ever changes.
2021-07-25 18:03:46 <Guest92> Haskell could support truthy and falsy values (for example by using a typeclass that represents values that can be converted to Bool) but it doesn't. Why not?
2021-07-25 18:04:18 <dsal> Guest92: why do you want this?
2021-07-25 18:04:44 <dsal> It's rather nice reducing truth to one possible value and false to another.
2021-07-25 18:05:07 <c_wraith> in python, 0 is falsy. In ruby, it's truthy. Which one of them is correct?
2021-07-25 18:05:18 <vaibhavsagar[m]> Guest92: you could write your own typeclass that implements the truthy/falsy logic
2021-07-25 18:05:28 × drd quits (~drd@2001:b07:a70:9f1f:1562:34de:f50f:77d4) (Quit: ZNC 1.8.2 - https://znc.in)
2021-07-25 18:05:32 <vaibhavsagar[m]> but you haven't. why not?
2021-07-25 18:05:40 <Guest92> that is correct
2021-07-25 18:06:03 <Guest92> I actually did as an experiment
2021-07-25 18:06:11 drd joins (~drd@93-39-151-19.ip76.fastwebnet.it)
2021-07-25 18:06:11 <vaibhavsagar[m]> the reason we don't do it in Haskell is that it's not actually a good idea
2021-07-25 18:06:27 <Guest92> ok, why not?
2021-07-25 18:06:32 <c_wraith> the broader context is that it's going the wrong direction. Booleans kind of are bad ideas.
2021-07-25 18:06:46 <c_wraith> Treating things as if they were booleans isn't any better.
2021-07-25 18:06:55 <nitrix> You would have to demonstrate the laws hold for things like Eq and that wouldn't be pretty.
2021-07-25 18:06:58 <flounders> Isn't that more like weak typing like what C does with char?
2021-07-25 18:07:07 <c_wraith> You should prefer pattern-matching on domain types
2021-07-25 18:07:19 <dsal> See also: Boolean blindness
2021-07-25 18:08:01 <Guest92> makes sense, thanks!
2021-07-25 18:09:06 × Guest92 quits (~Guest92@50.47.115.102) (Quit: Client closed)
2021-07-25 18:10:31 × curiousgay quits (~curiousga@77-120-186-48.kha.volia.net) (Ping timeout: 265 seconds)
2021-07-25 18:13:41 <arkanoid> nitrix: https://hackage.haskell.org/package/safeint-0.6/docs/Data-SafeInt.html exist for a reason. Other languages have compiler options to enable overflow check at program level, or better at code level. Where's haskell solution to this? Using Integer in my code is just the tip of the iceberg. Do haskell programmers grep "Int" in all imported code and process it manually?
2021-07-25 18:14:51 <dsal> I don't exactly understand your problem. If you use a data type that doesn't satisfy all of your requirements, then it won't satisfy all of your requirements.

All times are in UTC.