datkin has quit [Remote host closed the connection]
datkin has joined #ocaml
cixaxa has quit [Ping timeout: 272 seconds]
hexreel has joined #ocaml
raphscallion has joined #ocaml
cdidd has quit [Remote host closed the connection]
iago has quit [Quit: Leaving]
pippijn_ is now known as pippijn
raphscallion has quit [Quit: raphscallion]
letrec has joined #ocaml
JoeyA has joined #ocaml
<JoeyA>
Is there a better way to create a string with a single character than String.make 1 c ? I'm guessing Printf.sprintf "%c" c would be quick, given that "%c" is parsed at compile-time (it appears).
<thelema_>
String.make 1 c is faster
<thelema_>
the format string is parsed at compile time to produce the type of the resulting expression, but at runtime, the %c is parsed again, as no type information is carried from compile to runtime
<JoeyA>
Ah
smerz has quit [Remote host closed the connection]
<thelema_>
smake (30.69 ns) is 96.7% faster than
<thelema_>
sprintf (919.96 ns)
<JoeyA>
Thanks
<JoeyA>
I installed ocaml-batteries-included on Ubuntu (which in turn installed libbatteries-ocaml-dev), but ocamlfind batteries/ocaml still doesn't work. Are the language extensions provided by Batteries unavailable with the Ubuntu package?
<thelema_>
those are *old* instructions
<thelema_>
for batteries in the toplevel, copy the battop file to your ~/.ocamlinit
<thelema_>
for other uses of batteries, use ocamlfind's -package argument
<thelema_>
or in ocamlbuild -use-findlib and the tag package(batteries)
<JoeyA>
thelema_: Thanks. I get "Unknown directive `thread'.".
<thelema_>
JoeyA: when doing what?
<JoeyA>
I copied /usr/lib/ocaml/batteries/battop.ml to ~/.ocamlinit (I didn't have that file yet). When I run ocaml from the command line, I get that message.
<JoeyA>
(as in, the ocaml REPL)
<thelema_>
ah. hmmm
<thelema_>
what version of findlib?
<thelema_>
oops, I gave you wrong instructinos
<JoeyA>
1.2.7+debian-1build3
<thelema_>
battop.ml is supposed to be loaded by the ocamlinit file that may or may not be in the same place
<thelema_>
that ocamlinit is what you should copy to ~/.ocamlinit
<thelema_>
yup, that will work just fine - it's just a small script that loads ocamlfind into the toplevel and then loads the battop.ml
<thelema_>
we broke it up this way to make things easier for people who already had .ocamlinit files
<JoeyA>
Thanks, that worked.
<JoeyA>
All that because for i = Char.code 'a' to Char.code 'z' do f (Char.chr i) done ;; seemed needlessly verbose to me. Is there a more concise way to loop over a range of characters?
<thelema_>
fwiw, Char.code is a noop, and .chr just does a range check
<thelema_>
batteries has its -- for characters to produce an enum
<thelema_>
You could use batteries' String.init to build the range and then String.iter
<thelema_>
but there's no real Char.incr
<thelema_>
I would accept a patch that adds support for Numeric.Discrete to BatChar
<JoeyA>
It's sad how String.iter f "abcdefghijklmnopqrstuvwxyz" is shorter than my for loop.
<thelema_>
let Char.succ c = Char.chr (Char.code c + 1)
<JoeyA>
How do I get -- to work for characters? 'a' -- 'z' produces a type error.
<JoeyA>
(expects ints)
<thelema_>
Char.('a' -- 'z') works under 3.12
<JoeyA>
Is the Char.(... arbitrary expression ...) standard OCaml syntax?
<thelema_>
just added in 3.12 as a local module open
<JoeyA>
Cool
<thelema_>
and by "just", I mean 1.5 years, maybe 2 now
<JoeyA>
heh
<thelema_>
time for me to go to bed. Cheers
<JoeyA>
Thanks for the help. G'night.
cdidd has joined #ocaml
ftrvxmtrx has quit [Quit: Leaving]
tmaedaZ is now known as tmaeda
raphscallion has joined #ocaml
<JoeyA>
I want to build up a list of items, then traverse them later in the order they were appended. In Haskell, I might use a difference list. Should I do the same in OCaml?
<JoeyA>
Or would it be better (or perhaps just as good) to build the list by prepending, then reverse it?
<_habnabit>
you mean traversing first-added to last-added?
<JoeyA>
Correct.
<_habnabit>
well, it kind of sounds like it might be easier to do it with a batteries enum
<_habnabit>
are you using batteries?
<JoeyA>
No, I'm not using batteries (though I did get it working earlier). I'd rather stick to the core language, since I'm a newbie (I wrote my first working program one or two days ago).
<_habnabit>
that's not much longer than the builtin module list
<_habnabit>
(and most of these are wrapping builtin modules)
<_habnabit>
or adding modules that should exist in the stdlib (like Option and Tuple)
raphscallion has quit [Ping timeout: 260 seconds]
<_habnabit>
there's examples in those docs, too
<JoeyA>
I don't understand the module system that well yet, so I'll pass (for the time being).
<_habnabit>
you don't need to understand it to use it
<JoeyA>
By the way, List.filter (a.k.a. List.find_all) builds a list and reverses it at the end.
<_habnabit>
okay?
ftrvxmtrx has joined #ocaml
ulfdoz has joined #ocaml
BiDOrD_ has joined #ocaml
BiDOrD has quit [Ping timeout: 246 seconds]
JoeyA has quit [Quit: Leaving]
ulfdoz has quit [Ping timeout: 265 seconds]
ankit9 has joined #ocaml
<adrien>
hi
emmanuel__ has joined #ocaml
ggherdov has joined #ocaml
ankit9 has quit [Ping timeout: 276 seconds]
pango is now known as pangoafk
emmanuel__ has quit [Ping timeout: 264 seconds]
Cyanure has joined #ocaml
ggherdov has left #ocaml []
djcoin has joined #ocaml
mika1 has joined #ocaml
cago has joined #ocaml
Cyanure has quit [Ping timeout: 252 seconds]
eni has joined #ocaml
Tobu has quit [Ping timeout: 260 seconds]
cdidd has quit [Remote host closed the connection]
Anarchos has joined #ocaml
s_p has joined #ocaml
Anarchos has quit [Ping timeout: 245 seconds]
Cyanure has joined #ocaml
Tobu has joined #ocaml
ankit9 has joined #ocaml
ankit9 has quit [Ping timeout: 276 seconds]
avsm has joined #ocaml
Submarine has joined #ocaml
Submarine has quit [Changing host]
Submarine has joined #ocaml
tufisi has joined #ocaml
ankit9 has joined #ocaml
cago has quit [Quit: Leaving.]
cago has joined #ocaml
avsm has quit [Quit: Leaving.]
larhat has quit [Quit: Leaving.]
machine2 has quit [Ping timeout: 260 seconds]
ftrvxmtrx has quit [Ping timeout: 265 seconds]
ftrvxmtrx has joined #ocaml
machine2 has joined #ocaml
Hussaind has joined #ocaml
avsm has joined #ocaml
avsm has quit [Ping timeout: 264 seconds]
TaXules has joined #ocaml
ankit9 has quit [Ping timeout: 276 seconds]
ankit9 has joined #ocaml
ankit9 has quit [Client Quit]
ankit9 has joined #ocaml
larhat has joined #ocaml
<reynir_>
I have no idea how to set up a build system for ocaml
willb has quit [Read error: Operation timed out]
willb has joined #ocaml
Tobu has quit [Ping timeout: 272 seconds]
_andre has joined #ocaml
err404 has joined #ocaml
<thelema_>
reynir_: try ocamlbuild
<reynir_>
thelema_: Ok, I will try that
err404 has quit [Remote host closed the connection]
<reynir_>
wow that works well
<reynir_>
I get this error: lexing: empty token
<thelema_>
reynir_: it's quite nice when it works, but it doesn't handle external deps in a way I'd like.
<thelema_>
reynir_: probably a syntax error in your tags file
<reynir_>
(I'm writing a parser using ocaml{lex,yacc}
<reynir_>
tags file?
<adrien>
_tags
<thelema_>
_tags
<thelema_>
gotta go, cheers
<reynir_>
I dont think I ahve such a file
Tobu has joined #ocaml
jamii has joined #ocaml
<reynir_>
Hmm, my lexer is broken
<reynir_>
it seems
jamii has quit [Ping timeout: 260 seconds]
ankit9 has quit [Read error: Connection reset by peer]
<reynir_>
lol
<reynir_>
I overshadowed the space reg exp pattern
reynir_ is now known as reynir
<reynir>
Thanks for the help
Kakadu has joined #ocaml
eni has quit [Ping timeout: 264 seconds]
Xizor has joined #ocaml
fraggle_ has quit [Read error: Connection reset by peer]
fraggle_ has joined #ocaml
Zedrikov has joined #ocaml
jamii has joined #ocaml
emmanuel__ has joined #ocaml
<Ptival>
Camlp4: Uncaught exception: DynLoader.Error ("/usr/lib/ocaml/bitstring/bitstring.cma", "error loading shared library: dllbitstring.so: dllbitstring.so: cannot open shared object file: No such file or directory")
Kakadu has left #ocaml []
Kakadu has joined #ocaml
skchrko has joined #ocaml
<thelema_>
Ptival: do you have a file dllbitstring.so anywhere, and is that location in your ocaml/ld.conf file?
<thelema_>
reynir: oops, I thought the lexing error was coming from ocamlbuild
<reynir>
thelema_: hehe. It was a stupid mistake on my part :)
<reynir>
I had a variable sp for the space character, but I also had one of "SP" in all cases
<reynir>
and then the space character wasn't lexed
<Ptival>
thelema_: the problem is that I have a shadowing installation of ocaml
ftrvxmtrx has quit [Quit: Leaving]
mcclurmc has joined #ocaml
eni has joined #ocaml
Kakadu has quit [Quit: Page closed]
<thelema_>
Ptival: that would do it as well
bkheops has joined #ocaml
<bkheops>
Bonjour, j'ai quelques questions sur les modules, quelqu'un pourrait m'aider? Hello , I've some questions about Modules, someone can help me ?
<adrien>
english here, french on #ocaml-fr, and only if you ask your actual questions
<thelema_>
bkheops: don't ask permission to ask, just ask
Submarine has quit [Quit: Leaving]
<bkheops>
ok thx :)
<reynir>
Is it possible to make ocamlyacc look *two* tokens ahead?
Cyanure has quit [Remote host closed the connection]
<thelema_>
reynir: you could make your lexer combine those tokens...
<bkheops>
I don't understand in the documentation this thing : module Name = (struct : sig). What is the link between struct and sig ?
<thelema_>
bkheops: struct defines the module, sig is the module type
<thelema_>
example: module AbstractInt = (struct type t = int let of_int x = x end : sig type t val of_int : int -> t end)
<bkheops>
ok I understand , in your example type t is abstract , it's like "private" in other language isn't ?
<Zedrikov>
doesn't rather "private" mean that nobody has access to the type?
<adrien>
it's ocaml, you need access to the type
<Zedrikov>
in abstract types, every one has access to the type (but not to its constructors)
<adrien>
but you can't build something of it
<Zedrikov>
adrien: you *can* but you *shouldn't*
<bkheops>
so the goal is to access to the type from functions
<bkheops>
or other module
<Zedrikov>
yes, to access to it, but not to rely on its implementation
<bkheops>
Ok thank's :)
<Zedrikov>
if you want to define a type on your module which is really "private", you just have to omit it in the signature
<Zedrikov>
struct type t0 = A | B type t1 = C | D type t2 = E | F end : sig type t0 = A | B type t1 end
<Zedrikov>
is a module with a hidden ("private") type t2, an abstract type t1 and a concrete type t0
smerz has joined #ocaml
smondet has joined #ocaml
letrec has quit [Ping timeout: 264 seconds]
jamii has quit [Read error: Connection reset by peer]
Kakadu has joined #ocaml
Kakadu has quit [Client Quit]
Kakadu has joined #ocaml
cago has quit [Quit: Leaving.]
mika1 has quit [Quit: Leaving.]
<hcarty>
Zedrikov: The only way you could create a value of an abstract type without using a function in the same module is by breaking the type system (ex. Obj.magic)
<Zedrikov>
hcarty: I know it. There is also a way to have a symbol of a given type through endless recursion
<Zedrikov>
hcarty: That is why I precised that you *shouldn't* rather than *can't*, although there are some cases where Obj.magic can be used (I think of the coq extraction mechanism)
<hcarty>
Zedrikov: Ah, I see - type ttt let rec f x : ttt = f x
<Zedrikov>
yes
<pippijn>
Zedrikov: I imagine the coq extraction mechanism to be similar to a C++ to C compiler
<Zedrikov>
Not at all
<mrvn>
hcarty: but f x never terminates so that is ok
<pippijn>
with casts for things that the ocaml type system is too weak for
<Zedrikov>
It just removes Prop from terms, and use Obj.t for dependant types
<thelema_>
f x promises to return a value of type ttt, and if it ever did, you'd get the value of the right type
<Zedrikov>
C++ to C have a lot of work to translate classes into simple functions
<mrvn>
but it never does to no value of ttt type is created
<pippijn>
ok
<Zedrikov>
Coq extraction is designed to be simple
<thelema_>
mrvn: agreed
<hcarty>
mrvn: I agree
<mrvn>
Zedrikov: in your to/t1/t2 example you forgot type t3 = private int
<mrvn>
t0 is an internal type while t3 is private
<hcarty>
Similar - let rec f x : ttt = raise Exit
<mrvn>
aeh, t2 is internal I ment
<Zedrikov>
I never use private
<mrvn>
Zedrikov: private allows the compiler to produce better code
<Zedrikov>
hcarty: You do not even need "rec" for that, and do not need either "f" to be a function
<hcarty>
Zedrikov: Ooops, yes - copy/paste error
<mrvn>
You should always use that when you only want to safeguard the creation of the value but not the representation
<Zedrikov>
mrvn: I do not say it is not usefull, just that I don't use it
Kakadu has quit [Quit: Konversation terminated!]
ftrvxmtrx has joined #ocaml
larhat has quit [Quit: Leaving.]
Kakadu has joined #ocaml
silver has quit [Read error: Connection reset by peer]
cdidd has joined #ocaml
emmanuel__ has quit [Read error: Connection reset by peer]
smondet has quit [Ping timeout: 260 seconds]
eni has quit [Ping timeout: 264 seconds]
emmanuel__ has joined #ocaml
bkheops has quit [Quit: Quitte]
<hcarty>
diml: I have something raising Not_found in some code using Lwt. I am passing -lwt-debug to the Lwt syntax extension, but this exception seems to be raised outside of Lwt. Any suggestions on how to track the cause down?
iago has joined #ocaml
err404 has joined #ocaml
<diml>
hcarty: the fact that it is raised outside of lwt is not the problem
<diml>
-lwt-debug use the standard ocaml backtrace with the same limitation: if an exception is raised and caught between the point where the original exception is caught and raised again, the original backtrace is lost
<malouin_>
I am using whatever godi gave me, hold on
<thelema_>
malouin_: that's probably 1.4
<malouin_>
1.4.1 according to ocamlfind
<thelema_>
yup, that still has a bug in Set.map. I'm tempted to release a 1.4.2 that fixes the bug
<thelema_>
If someone wants to prepare the release, I'll send it out, but I should spend my time on 2.0 to get it out
<malouin_>
thelema_: so it seemed to me like line 538 in the newest version should be Concrete.map s.cmp f s.set where it says Concrete.map Pervasives.compare f s.set ?
<malouin_>
I can't be sure becuase I don't have that version running
<malouin_>
actually maybe not, I'm probably seeing things in the nouse.
<malouin_>
noise
<thelema_>
batSet 2.0 has two varieties: Set.PSet (which you're looking at), which is the same as batteries 1 Set and just Set, which doesn't take a custom compare function and always uses Pervasives.compare.
<thelema_>
Because we don't take as an argument a compare function for the output map in PSet.map, we can only use Pervasives.compare, otherwise we'd only be able to map functions type 'a -> 'a, and not 'a -> 'b
<malouin_>
ah I see.
<thelema_>
this is a design compromise. We're not going to maintain PSet further, as it's strictly better to use either Set or Set.Make
<thelema_>
depending on whether you want Pervasives.compare or not
<malouin_>
I agree.
<malouin_>
I thought it was odd that you could provide a comparison function to the polymorphic set when I first read it.
oriba_ has joined #ocaml
larhat has joined #ocaml
<thelema_>
that's how it used to work. We're migrating away from that with 2.0
NihilistDandy has joined #ocaml
<NihilistDandy>
Hi, all, back again for some homework help
<NihilistDandy>
I think my substitution cases are correct (though if there's a glaring error, it'd be helpful to know), so now I'm on to the last few cases of eval.
<NihilistDandy>
I'm having some trouble reasoning out the logic
<thelema_>
What's the problem with Plus, Minus and Equal in eval?
<NihilistDandy>
I don't think there's a problem with those
<NihilistDandy>
Sorry, I should have left the undefined Let, Appl, Function, and Fix in there
<NihilistDandy>
Oh, and If.
<NihilistDandy>
This started as an arithmetic interpreter which we're now extending into a more useful language.
<NihilistDandy>
Though If is the easy one, I think
<thelema_>
oh, you dont know how to evaluate an appl?
<thelema_>
don't you evaluate the argument and then substitute the argument in the body and then evaluate the body?
<NihilistDandy>
I haven't actually looked at that one. I've been a bit preoccupied with Fix and Function. I think Appl will just be applying exp0 to exp1
<NihilistDandy>
Hmm
<thelema_>
does function declaration evaluate?
larhat has quit [Read error: Connection reset by peer]
<thelema_>
(or is Function something else?)
larhat has joined #ocaml
<NihilistDandy>
Function is our equivalent to fun, as I understand it
<thelema_>
as to fix, just keep running the function on the value until the output value is the same as the input, no?
<thelema_>
oh, creates a closure?
<NihilistDandy>
Right
<mrvn>
thelema_: function is a function x -> e
<NihilistDandy>
Hi again, mrvn :)
<mrvn>
And for fix the expression will do a recursive call. Just evaluate it
<mrvn>
NihilistDandy: Although I'm not quite sure how you would do that without having a global environment for eval where you can bind the function.
<mrvn>
NihilistDandy: When we did this at university we bound values to idents in the environment, which gets passed to eval, and a 'Var "x"' would look up the value of "x" in the environment. We didn't do substitutions.
<NihilistDandy>
Hmm
<mrvn>
I assume the syntax for eval is given?
<NihilistDandy>
Most of it is defined in the abstract syntax, but we use Ocaml as an oracle
<mrvn>
The question is wether you are supposed to use subst in there
<NihilistDandy>
Let me check the notes
<NihilistDandy>
I don't know if it explicitly said one way or the other
<mrvn>
let get_env env x = List.assoc x env let set_env env x v = (x, v) :: env
<NihilistDandy>
Looks like subst is a necessary part of these latter definitions, yes
<mrvn>
let rec eval env = function | Var x -> get_env env x | Let (x, e1, e2) -> let e1 = eval env e1 in let env = set_env x e1 in eval env e2 | ...
emmanuel__ has quit [Ping timeout: 264 seconds]
<mrvn>
NihilistDandy: Hmm. So say you have let rec f x = f x
emmanuel__ has joined #ocaml
<NihilistDandy>
Okay
<mrvn>
is that Fix ("f", "x", Appl ("f", "x"))?
<NihilistDandy>
Yes
<mrvn>
So to evaluate that you can't substitue Appl ("f", "x") for f.
<mrvn>
Buf you could substitute Fix ("f", "x", Appl ("f", "x")) for f and evaluate.
emmanuel__ has quit [Max SendQ exceeded]
mort___ has joined #ocaml
<NihilistDandy>
So, | Fix (z,x,e) -> eval (subst (Fix(Var("f"), Var(
<NihilistDandy>
Hit return too early. Hang on
<mrvn>
Fix("f"... No Var in there
emmanuel__ has joined #ocaml
<mrvn>
Actualy in Fix (z, x, e) the x is always unbound, it is an open expression and can't be evaluated. You have to have Appl (Fix (z, x, e), y)
<NihilistDandy>
Oh, that makes sense
emmanuel__ has quit [Excess Flood]
<mrvn>
I would do match e with | Function _ -> | Fix _ -> e | Appl (e1, e2) -> let e1 = eval e1 in let e2 = eval e2 in match e1 with Function (x, e) -> ... | Fix (f, x, e) -> ...
emmanuel__ has joined #ocaml
emmanuel__ has quit [Ping timeout: 264 seconds]
<mrvn>
NihilistDandy: In subst: | Plus (e1',e2') -> Plus(subst e1' e2 x, subst e2' e1 x)
<mrvn>
NihilistDandy: why e1 in the last subst?
<mrvn>
same in And + Or
<thelema_>
also, why subst exp exp2 val, why not subst exp var val?
<NihilistDandy>
The Plus was a definition he gave us in class, so I just used it for the others
<NihilistDandy>
The text preceding: "Since Fix expressions are values (as recursive functions), they evaluate to themselves. The necessary modification to the D semantics comprises an additional rule form for application, to accomodate the case when a recursive function is applied."
<NihilistDandy>
I think my If case in eval is the right one. He gave us two inference rules for If, one for True and one for False
<mrvn>
NihilistDandy: As said Function and Fix evaluate to themself.
<NihilistDandy>
Ah, right
<mrvn>
NihilistDandy: you are missing evals in the IF
<NihilistDandy>
Added eval t and eval e
<mrvn>
If (true, Plus (Int 1, Int 2), Int 0) -> Int 3
emmanuel__ has quit [Read error: Connection reset by peer]
<NihilistDandy>
Awesome
<mrvn>
NihilistDandy: Var x does not evaluate to Var x. That is not a Closed expression and can never happen. Better to put an assert false there or raise NotClosed.
<mrvn>
If you use Var x -> raise notClosed you can skip the closedp call at the start.
emmanuelux has joined #ocaml
<Ptival>
NihilistDandy: your eval is also missing a context...
<NihilistDandy>
Yeah, I just put that as a placeholder since it through a non-exhaustive pattern match warning at me
<mrvn>
Ptival: there is no context (or environment)
Anarchos has joined #ocaml
<Ptival>
or maybe not
<NihilistDandy>
Yet
<NihilistDandy>
We're adding that in the next incarnation
<Ptival>
ok
<mrvn>
NihilistDandy: adding an environment gets rid of all the subst.
<NihilistDandy>
Thank god
<Ptival>
oh right, you'll subst
<mrvn>
NihilistDandy: have you got eval for Let yet?
<NihilistDandy>
Not yet. I'm looking for the inf rule. The more I look at them the easier it is to turn them into code
<NihilistDandy>
Which should be Appl(e1, e2) -> let e1 = eval e1 in let e2 = eval e2 in match e1 with Function(x, e) ->...
<NihilistDandy>
hmm
<mrvn>
# eval (Appl (Function (Ident "x", Plus (Var (Ident "x"), Int 1)), Int 3));;
<mrvn>
- : Dast.expr = Int 4
<mrvn>
NihilistDandy: ... == e[v'/x] => v
<NihilistDandy>
eval (subst e v x)
<NihilistDandy>
Or am I transposing e and v, again?
<mrvn>
v being e2
<mrvn>
let v = eval e2 in
<mrvn>
let v' = eval e2 in to match the appl.jpg precisely.
<mrvn>
NihilistDandy: do you get Int 4 for my example?
<NihilistDandy>
I haven't run it, yet. Still making sure I'm working out Appl correctly. Hang on, I'll give it a shot
<Anarchos>
NihilistDandy why not use named parameters with ~val:v notation in the definition of subst ?
<mrvn>
Anarchos: because the prof didn't
<Anarchos>
mrvn he should
<hcarty>
Anarchos: I'm sure the professor is looking forward to hearing your feedback :-)
larhat has quit [Read error: Connection reset by peer]
emmanuelux has quit [Remote host closed the connection]
<Anarchos>
hcarty well i could find bugs easier to track when i can name the parameters...
larhat has joined #ocaml
<mrvn>
Anarchos: the naming of vars is critical for me too
<NihilistDandy>
mrvn: I do get Int 4 :)
<Anarchos>
it is time to go to sleep
<Anarchos>
see you soon, folks
Anarchos has quit [Quit: Vision[0.9.7-H-090423]: i've been blurred!]
<mrvn>
AppllFix next
emmanuel__ has joined #ocaml
<NihilistDandy>
I don't actually know if we're meant to implement that, yet. It's not in the AST, and apparently the makefile they use breaks if you add things :/
machine2 has quit [Ping timeout: 250 seconds]
<mrvn>
NihilistDandy: Huh? It is in the ast you pasted
<NihilistDandy>
Oh, a Fix case of Appl. Derp
<NihilistDandy>
Just being dense :D
<mrvn>
That one is fun. You get a double subst.
iago has joined #ocaml
<mrvn>
All this helping makes we want to write my own laguage and compiler again
<NihilistDandy>
I'm enjoying the experience with this interpreter. Might rewrite it and clean it up after we get through the last part
<mrvn>
rewrite it with GADTs so it is typesafe
OvrKilT3rminator has quit [Quit: Bye all, see you next time!]
machine2 has joined #ocaml
<NihilistDandy>
In Ocaml? I asked my professor about GADTs and it sounded like they weren't viable (or at least uncommon). I think they were the only positive thing he's had to say about Haskell :D
<NihilistDandy>
But yeah, there are a lot of things I would change about this implementation if I could do it without breaking things
<adrien>
GADTs exist in ocaml but not in a released version
<adrien>
ask again around June
<NihilistDandy>
Oh, cool
<mrvn>
NihilistDandy: you can somewhat implement them in current ocaml but that becomes ugly. The next ocaml release will have them directly.
emmanuel__ has quit [Remote host closed the connection]
<NihilistDandy>
I look forward to it. I'm mostly a Haskeller, myself, but Ocaml's been fun so far
<mrvn>
NihilistDandy: The nice thing is that with GADTs you can define your Dast so that an If can only have an expression evaluating to bool as first parameter.
<mrvn>
No more "Raise TypeMismatch"
emmanuelux has joined #ocaml
<NihilistDandy>
And no more million cases of closedp. :D
<mrvn>
why?
<NihilistDandy>
Actually, I'm thinking of a saner type model, in general. My bad.
<NihilistDandy>
BinOp instead of Plus, Minus, And, Or
<NihilistDandy>
And so on like that
s_p has quit [Ping timeout: 272 seconds]
<mrvn>
I don't get the closedp anyway. Just evaluate Var (Ident "x") -> raise NotClosed and avoid closedp alltogether.
<mrvn>
BinOp (( + ), x, y)?
<NihilistDandy>
Something like that, yes
<NihilistDandy>
Boilerplate bothers me :D
djcoin has joined #ocaml
<NihilistDandy>
So the Fix case I have is eval (subst (subst e e1 z) e1 x), but again I don't think my substitution is right.
<mrvn>
and it isn't.
<NihilistDandy>
Ah, got it
<NihilistDandy>
Second e1 should be e2
<mrvn>
that is one error
<mrvn>
Fix (z, x, e)?
<NihilistDandy>
Is there another? I ran your fib example and it worked
<mrvn>
you you have a let e1 = Fix (z, x, e) in there?
<mrvn>
you need a bigger test case that covers the rest of your AST.
<mrvn>
let rec fib n = if (n = 0 || n = 1 && not false) then 1 else fib (n-1) + fib (n-2)
emmanuelux has quit [Remote host closed the connection]
<mrvn>
let rec fib n = if (n = 0 || n = 1 && (fun x -> not x) false) then 1 else fib (n-1) + fib (n-2)
<mrvn>
hmm, missing let
<mrvn>
let rec fib n = if (n = 0 || n = 1 && (fun x -> not x) false) then 1 else let i = fib (n-1) in i + fib (n-2)
<mrvn>
There, that covers all the correct code paths. Next you need some examples that raise the various TypeMismatch.
<NihilistDandy>
Good point
<NihilistDandy>
Computers are better at checking code, anyway :D
emmanuel__ has joined #ocaml
<NihilistDandy>
Thanks for all the help. You definitely helped me actually get it.
<mrvn>
Will you continue writing a compiler and what architecture will it be for?
<NihilistDandy>
I don't think the class is working up to a compiler, and I don't plan on writing one in the near future
<NihilistDandy>
Maybe in the summer.
<NihilistDandy>
Why, making sure to avoid my work? :D
reynir_ has joined #ocaml
everyonemines has joined #ocaml
reynir has quit [Ping timeout: 252 seconds]
s_p has joined #ocaml
Xizor has quit []
djcoin has quit [Ping timeout: 250 seconds]
<NihilistDandy>
mrvn: I translated your that covers all the success cases into the (much nicer) syntax used by the compiled interpreter, and it works nicely. :)
<NihilistDandy>
*your fibs
<NihilistDandy>
Now to switch it all around to force a break :D
djcoin has joined #ocaml
NihilistDandy has quit [Quit: ["Textual IRC Client: www.textualapp.com"]]
iZsh has joined #ocaml
s_p has quit [Read error: Connection reset by peer]
s_p has joined #ocaml
Kakadu has quit [Quit: Konversation terminated!]
s_p has quit [Read error: Connection reset by peer]
s_p has joined #ocaml
emmanuel__ has quit [Remote host closed the connection]
s_p has quit [Read error: Connection reset by peer]
s_p has joined #ocaml
emmanuel__ has joined #ocaml
s_p has quit [Read error: Connection reset by peer]
s_p has joined #ocaml
s_p has quit [Client Quit]
djcoin has quit [Quit: WeeChat 0.3.2]
larhat has quit [Quit: Leaving.]
err404 has quit [Remote host closed the connection]
everyonemines has quit [Quit: Leaving.]
letrec has joined #ocaml
datkin has quit [Read error: Connection reset by peer]