<discocaml>
<barconstruction> Ok here's I am after fixing the bitwise negation -> boolean negation typos.
<discocaml>
<barconstruction> Does anyone have a suggestion on how to debug this
<companion_cube>
What's to debug at this point?
<dh`>
well
<dh`>
it seems like assert(!isnan(x)) ought to fire if x actually contains 0xfff8000000000000
<dh`>
are you sure you aren't building the C with assertions disabled?
<companion_cube>
:D
<dh`>
also have you done anything else that would lead the compiler to conclude the whole thing is UB?
<companion_cube>
Good point, I'd run the whole thing in Godbolt
gzar has quit [Quit: WeeChat 4.2.2]
nickiminjaj has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jabuxas has joined #ocaml
<anadon>
Why would `List.hd (List.rev char_list)` be giving me the error "Warning 8: this pattern-matching is not exhaustive. Here is an example of a case that is not matched: _::_::_"?
<dh`>
that's not a pattern-matching
<anadon>
The input of one function is passed to another with correct typing information, so that doesn't explain the issue to me.
<discocaml>
<darrenldl> are you sure thats where the error comes from?
<discocaml>
<yawaramin> getting a syntax error in this snippet. you are also using a couple of incorrect operators, instead of `and`, use `&&`. instead of `==`, use `=`
<anadon>
Still only *just* learning the language
<dh`>
yeah, and after fixing that it doesn't typecheck :-(
<discocaml>
<yawaramin> tip: you can use a quoted string literal to avoid having to backslash-escape: `let path = {|/bin:/usr/bin:/home/user/horrible\:path|}`
<dh`>
the calls to List.nth aren't passing the list (just n) and the lambda syntax in the folds is wrog
<discocaml>
<yawaramin> this: `String.fold_left ( char_list, c = if s`
<discocaml>
<yawaramin> should be: `String.fold_left (fun char_list c -> if s`
<discocaml>
<yawaramin> or just define it as a named function immediately above
<dh`>
preferably the latter
<dh`>
also consider using shorter lines :-|
<discocaml>
<yawaramin> also instead of `String.append` you should almost certainly use a `Buffer.t`. and instead of `List.append` you should almost certainly prepend with the cons operator `::` and then reverse the list at the end
<anadon>
OK. I'll work those in as I can figure out how to.
<anadon>
But I'm going to bed. It is almost 1AM here.
<discocaml>
<yawaramin> `print_newline paths` should be something like `let () = List.iter print_endline paths`
<dh`>
also it looks to me like the use of strings vs. lists isn't consistent
<dh`>
I don't immediately see how the online playground got far enough to start complaining about incomplete matches
<dh`>
but you might want to consider match List.rev char_list with | [] -> false | '\\' :: _ -> true and so forth instead of mucking with hd and nth
<dh`>
easier to read
jabuxas has joined #ocaml
trillion_exabyte has quit [Ping timeout: 268 seconds]
trillion_exabyte has joined #ocaml
Serpent7776 has joined #ocaml
jabuxas has quit [Quit: oops :p]
bartholin has joined #ocaml
waleee has joined #ocaml
wingsorc has quit [Quit: Leaving]
waleee has quit [Ping timeout: 264 seconds]
waleee has joined #ocaml
<discocaml>
<contextfreebeer> you aren't allowed to do casts like this, they violate the strict aliasing rule. if you want to do type punning like this (in C) you are supposed to use a union
<discocaml>
<barconstruction> Thanks. In this case I suspect it happens to be correct, as if I eliminate that cast and return the float to the OCaml program and use Int64.bits_of_float then I get the same value of 0xFFF800000000. However I understand that the compiler is not at all guaranteed to do that.
<discocaml>
<barconstruction>
<discocaml>
<barconstruction> In any case I learned last night that the owl library compiled by default with the -ffast-math flag which performs a number of unsafe optimizations and in particular assumes away isnan calls because you're telling the compiler that there are no nan's. So I assume if I change the build configuration to eliminate -Ofast and related flags I will get the correct answer.
mbuf has joined #ocaml
<discocaml>
<contextfreebeer> Ah, quite possibly
trillion_exabyte has quit [Ping timeout: 240 seconds]
trillion_exabyte has joined #ocaml
gzar has joined #ocaml
<anadon>
Improved my escaped path splitting codes, but I'm having what looks like one last issue before I really need nit-picking to improve what I've written. https://pastebin.com/F5i1A83T
<anadon>
I guess this comes down to, how do I return a stack when I push to it?
<octachron>
You can just return the stack that you pushed too with "...;c".
<octachron>
Note however that Stacks are a horrible fit to your issue, and your code is accidentally quadratic.
<anadon>
When I tried using semicolons earlier they did not work, and they don't seem to be working now.
<anadon>
'You can just return the stack that you pushed too with "...;c".' -- ?
<octachron>
Yes, and the issue in your updated code has nothing to do with the new `;`.
<anadon>
Which is?
<octachron>
How are your interpreting the compiler error message?
<octachron>
Or worded in a different way, why is there a type error on "let proto_paths = String.fold_left a Stack.create() path" ?
<anadon>
@page { size: 8.27in 11.69in; margin: 0.79in } p { line-height: 115%; margin-bottom: 0.1in; background: transparent } “This expression has type string Stack.t -> char -> string Stack.t but an expression was expected of type ('a -> 'b) -> char -> 'a -> 'b Type string Stack.t = string Stdlib__Stack.t is not compatible with type 'a -> 'b”
<anadon>
where ‘a → ‘b is really a ‘c of String Stack, meaning the compiler is looking for a pattern match of a function for ‘c → char ‘c and the type “string Stack.t” is that and is also a name for “ string Stdlib__Stack.t” but the resolved names are just not clean. So I have no idea why it is complaining. It looks correct and like it has sufficient information.
<anadon>
GDI libreOffice
<octachron>
anadon, as a beginner, you should consider that the typechecker is always right.
<octachron>
The error message is pointing out the fact that in "String.fold_left a Stack.create () path" the `fold_left` function is expecting to return a value of the same type as `Stack.create`.
<anadon>
"string Stack.t" and "string Stdlib__Stack.t" are so close that I fall back to C++ instincts of type coercion.
<octachron>
This point is a distraction (and should not happen with a correct setup). `Stack.t` is `Stdlib__Stack.t`.
<anadon>
So I was right to disregard the typechecker.
<octachron>
Nope.
<octachron>
You should never disregard the typechecker in a strongly typed language. Your call to `fold_left` is ill-typed.
<octachron>
Hint: Contrarily to C++, functions are first classes in OCaml.
<octachron>
Hint 2: How many arguments do you count in the `fold_left` call?
<anadon>
If that's the error message it gives me, it is a misdirection. All I can tell is that there is an error. Because it fixated on String Stack = String Stdlib_Stack, it takes away from where any issues really are. I will defend myself on that.
<anadon>
I count 3 parameters.
<discocaml>
<Kali> you passed 4
<discocaml>
<Kali> a
<discocaml>
<Kali> Stack.create
<discocaml>
<Kali> ()
<discocaml>
<Kali> path
<discocaml>
<Kali> you need parentheses around (Stack.create ()) for it to be treated as one argument
<anadon>
The typechecker wanted () after Stack.create
<anadon>
That is a sharp edge. I can't have been those only one to have had that issue.
<discocaml>
<Kali> it is a common beginner issue but you quickly grow out of it
<anadon>
How do I debug this thing, now? It is wrong somewhere and it is entirely on me for doing this part wrong.
pi3ce has quit [Quit: No Ping reply in 180 seconds.]
pi3ce has joined #ocaml
<discocaml>
<darrenldl> you start off with an empty stack
Tuplanolla has joined #ocaml
<discocaml>
<darrenldl> scratch what i said
<discocaml>
<Kali> you switched (Stack.create ()) and proto_paths
<octachron>
No? Iterating over the empty stack is not useful? The issue is more the Stack.pop at the start in `b` when the accumulator stack is empty.
<discocaml>
<Kali> oh, yes
<discocaml>
<Kali> you need to change `Stack.pop string_stack` to `if Stack.length string_stack = 0 then "" else Stack.pop string_stack`, i believe
<discocaml>
<Kali> also, the resulting strings are backwards, so you'll need to reverse those
<anadon>
Getting it.
<anadon>
I know there are issues. I'm flexing muscles I haven't used in years. Working on it.
<anadon>
octachron: You're taking issue with my use of stacks overall. Why? What do you see that I do not?
<octachron>
You are building strings with "^": this is quadratic in the size of the built strings.
<anadon>
What does that have to do with stacks?
<octachron>
Using stack to store characters also increases the memory footprint by a factor 16
<octachron>
Overall, my impression is that stacks afford you very little, compared to directly splitting the strings with a recursive function.
<anadon>
Ignoring that the strings are reversed, because that's really uninteresting, I had asked about a streaming processing method a number of days ago and explicitly told to do this instead. So this is neither optimal or idiomatic. What exactly is expected here?
<discocaml>
<limp.biskit> is a simple recursive function adding data into a buffer not the best data thing for this?
<discocaml>
<limp.biskit> not purely functional but it would be functioning
<anadon>
This uses syntax which I have not yet encountered.
<anadon>
I'm going to need some time to parse this.
<anadon>
octachron: Your code is giving me the error "This expression has type string but an expression was expected of type char"
<anadon>
just " -> ' made it happy, nvm
<anadon>
"This function has type char -> char -> int -> int -> string -> string list It is applied to too many arguments; maybe you forgot a `;'." So still not quite working.
<anadon>
I'm taking this as an "exercise left for the reader" situation.
<octachron>
no, wrong escape character: "let split_path s = split '\\' ':' 0 0 s"
Guest11 has joined #ocaml
Guest53 has joined #ocaml
Guest11 has quit [Ping timeout: 250 seconds]
Guest53 has quit [Quit: Client closed]
bibi__ has quit [Quit: Konversation terminated!]
<discocaml>
<leviroth> Broadly speaking I am confused by the desire to handle escaping in PATH. By my reading of the standard, there is no provision for escaping, and you're just encouraged to not use `:` in paths that might become part of PATH.
<discocaml>
<leviroth> (And note that attempting to add escaping in the consumer of PATH is not strictly "backwards compatible", as it causes you to misinterpret paths that contain `\`.)
<dh`>
you clearly didn't compile it :-) ("mdoule")
ebb has quit [Max SendQ exceeded]
<octachron>
I did add the submodule at the last minute, I am not sure how this is relevant?
ebb has joined #ocaml
<dh`>
it's not
trillion_exabyte has quit [Read error: Connection reset by peer]
trillion_exabyte has joined #ocaml
<dh`>
however, _running_ it reveals that it doesn't handle trailing : correctly, and it doesn't reduce \: to just :
ebb has quit [Max SendQ exceeded]
<dh`>
it also doesn't reduce \\ to \ and (relatedly) doesn't split if it gets \\:
<dh`>
the desired behavior for \\ wasn't specified that I recall but in general if you want to be able to have the escape character appear it has to escape itself
ebb has joined #ocaml
<dh`>
and, dealing with these cases is going to add complexity :-)
ebb has quit [Max SendQ exceeded]
<octachron>
Agreed, the ESC ESC will need to be split. Not sure what is the right specification for trailing `:` and reducing `\\` to `\` or not.
<octachron>
And the reduction will mean switching to a buffer rather than a string range for the current word.
ebb has joined #ocaml
<octachron>
Anyway that was mostly me musing on my feelings that most of the time list of chars are a costly detour
ebb has quit [Max SendQ exceeded]
ebb has joined #ocaml
ebb has quit [Max SendQ exceeded]
ebb has joined #ocaml
wingsorc has joined #ocaml
<dh`>
trailing : should definitely produce an empty string into the output list (as should ::)