<Skolem>
For practice, I'm trying to define the type of lambda-calculus expressions with "type expr = Var of string | Abstraction of expr * expr | Application of expr * expr". However, I would like to restrict the first part of an Abstraction to be a Var. For instance, I would like this to be an ill-formed expr: Abstraction(Abstraction(Var "foo", Var "bar"), Var("bar")), but right now it is accepted as valid. Is there any way to have the type system
<Skolem>
reject these kinds of ill-formed expressions?
<Skolem>
Also, I would like to restrict the first part of an Application to be an Abstraction.
surikator has quit [Quit: Scientific discovery is just maximal compression of strings. Nothing more, nothing less.]
iratsu has joined #ocaml
everyonemines has joined #ocaml
sebz has joined #ocaml
Modius has joined #ocaml
ttamttam has joined #ocaml
ttamttam has quit [Remote host closed the connection]
mdelaney-afk has quit [Quit: mdelaney-afk]
<flux>
skolem, well, you could just do type var = string and type expr = Var of var | Abstraction of var * expr | .. etc? alternatively, you could use polymorphic variants, that allow the same constructors to be used for different types
<Skolem>
Wow, thanks. Let me try that.
jkoppel has joined #ocaml
<Skolem>
With the first suggestion, Abs(Var("a"), Var("b")) gives me a syntax error, but I'd like that to be valid. (This is all hypothetical since I'm really just using this as an excuse to learn the type system.)
<jkoppel>
Why does (function [x] a -> x + a) give a syntax error?
<everyonemines>
You have a list creation in the function definition.
<everyonemines>
Don't do that.
<jkoppel>
How do I pattern match a singleton list?
<everyonemines>
List.hd ?
<jkoppel>
I don't think I can pattern match with that
<jkoppel>
In which pattern matching on lists is A-OK
<Skolem>
jkoppel:I don't know how to match a singleton list either,but if you match a non-singleton list first, then what remains will be a singleton.
<Skolem>
match k with x::xs -> ... | x -> (singleton)
<jkoppel>
Why does OCaml not like pattern-matching on lists?
<jkoppel>
Skolem: x :: xs captures singletons
<jkoppel>
Would need x :: y :: xs
<Skolem>
Oh, right.
<jkoppel>
This is just absolutely icky
<Skolem>
I think what you were trying to do works.
<Skolem>
match [1;2;3] with [x] -> 1 | x::xs -> 2 | [] -> 3;; (* returns 2 *)
<Skolem>
match [1] with [x] -> 1 | x::xs -> 2 | [] -> 3;; (* yields 1 *)
<jkoppel>
Here's the actual function I'm porting
<jkoppel>
fun delimit' [] s = s
<jkoppel>
| delimit' [x] s = s ^ x
<jkoppel>
| delimit' (x :: xs) s = delimit' xs (s ^ x ^ ", ")
<jkoppel>
I would have thought that this should become
<jkoppel>
let rec delimit' = function [] s -> s
<jkoppel>
| [x] s -> s ^ x
<jkoppel>
| (x :: xs) s -> delimit' xs (s ^ x ^ ", ")
<jkoppel>
But nope; that's a syntax error
<Skolem>
I don't know SML - what is the [] doing as the first argument to delimit'?
<jkoppel>
It's pattern matching on empty lists
<Skolem>
Ah, I see. OK.
<jkoppel>
Also, your suggestion is also producing a syntax error
<Skolem>
The standard library function String.concat does what you want.
<Skolem>
But in terms of writing it yourself....
<jkoppel>
I'm trying to keep the porting as local as possible to minimize bugs. Luckily, this function is private so I can swap it out for a library function fearlessly
<Skolem>
I think it would be something like: let rec delimit' c lst = match lst with [x] -> c ^ x | x::xs -> c ^ x ^ (delimit' c xs) | nil -> "";;
<Skolem>
I could have written [] instead of nil.
everyonemines has quit [Quit: Leaving.]
Skolem has quit [Quit: Skolem]
jkoppel has quit [Quit: jkoppel]
ygrek has joined #ocaml
edwin has joined #ocaml
sebz has quit [Quit: Computer has gone to sleep.]
sebz has joined #ocaml
sebz has quit [Quit: Computer has gone to sleep.]
sebz has joined #ocaml
sebz has quit [Quit: Computer has gone to sleep.]
sebz has joined #ocaml
<adrien>
hah, stumbled on this quote through lwn: In hindsight however, I think the complexity of Swig has exceeded anyone's ability to fully understand it (including my own).
wishi has quit [Read error: Connection reset by peer]
wagle has quit [Read error: Connection reset by peer]
ikaros has quit [Quit: Ex-Chat]
wishi has joined #ocaml
wishi has quit [Read error: Connection reset by peer]
wishi has joined #ocaml
ftrvxmtrx has joined #ocaml
DimitryKakadu has joined #ocaml
<edwin>
adrien: where do I get GtkSignal in lablgtk-react?
<edwin>
adrien: tells me unbound value GtkSignal.connect_property
<edwin>
ah its part of lablgtk2
surikator has quit [Quit: Computer is sleeping. I'm probably not.]
<DimitryKakadu>
hi all!
<DimitryKakadu>
any ideas how to convert OCaml string to bytes (like in qt's QByteArray)?
<asmanur>
you want a int array out of a string ?
<NaCl>
DimitryKakadu: run a for loop on the string that runs int_of_char on each element in the string and returns the results into an array
<DimitryKakadu>
thanks
<DimitryKakadu>
I've thought about encoding and was a little suspicious
<asmanur>
(for the loop, you can use Array.init)
<DimitryKakadu>
I'll go with my way
<DimitryKakadu>
btw, I'm rewriting qt's moc now
<NaCl>
wut
<DimitryKakadu>
to let users of lablqt to create own signals and slots in a clear way
<DimitryKakadu>
and I'm looking in C++ and write OCaml)
<DimitryKakadu>
maybe it's a bad idea
<DimitryKakadu>
but it's interesting
<NaCl>
Ah, well, good luck
bzzbzz has joined #ocaml
surikator has joined #ocaml
lopex has joined #ocaml
bobry has quit [Quit: Leaving.]
bobry has joined #ocaml
sebz has joined #ocaml
sebz has quit [Quit: Computer has gone to sleep.]
jkoppel has joined #ocaml
<adrien>
edwin: :o
<adrien>
edwin: also, for lablgtk-react, you'd have to use my "adrien/mix" branch of lablgtk, or at least the "adrien/react" one
<adrien>
edwin: but it's highly experimental stuff although I hope to make an announcement soon
<edwin>
adrien: ok, will wait
sebz has joined #ocaml
<adrien>
edwin: you had something particular in minmind?
<edwin>
no, I just read richard jones's blog and seen a reference to your lib there
<adrien>
heh :-)
<adrien>
I think I figured out my last bit but I can't really code now
<adrien>
squatting some hotel's wifi, and hoping it won't rain before openstreetmap.org gives me my answer
<edwin>
although for solving the n^2 problem a MVC approach might work too
<edwin>
changes in the UI update the model, the model recomputes what needs to be recomputed, and the view re-renders whats changed
<edwin>
well thats what your lib does too
<adrien>
I mostly don't care about CPU perf for now, almost only programmer complexity
<adrien>
I'd like to tell you to look at the current code but it needs some comments even though it's not very long
surikator has quit [Quit: Computer is sleeping. I'm probably not.]
jkoppel has quit [Quit: jkoppel]
<edwin>
btw will you use oasis for the final version? The current version of the Makefile only works with bash (due to {,} expansion). If you'd like I can write some short oasis thingy
<adrien>
yes, I plan to use oasis but haven't had the time
<adrien>
and I think I'll do it myself because I need an occasion to learn :P
<edwin>
k :)
<adrien>
(and then we'll move lablgtk to oasis, rrrrrrr)
<adrien>
ok, have to go now, I won't squat this hotel wifi for the rest of the day :P
<edwin>
bye
surikator has joined #ocaml
<adrien>
DimitryKakadu: and why aren't String_val and caml_copy_string good?
<adrien>
(the wifi reception is much better with the laptop on the pavement \o/ )
<adrien>
anyway, gone now, will read again in maybe 40 minutes
wagle has joined #ocaml
surikator has quit [Quit: Scientific discovery is just maximal compression of strings. Nothing more, nothing less.]
<DimitryKakadu>
adrien: forget, I wasn't talking about binding code.
<DimitryKakadu>
Hmmm, I'm very lazy
<DimitryKakadu>
there two approachs to rewrite moc
<DimitryKakadu>
I can write tool which read some ocaml functions signatures and creates some class (that inherits QObject) with a public slot for every signature
<DimitryKakadu>
it is an easy way
<DimitryKakadu>
and will need to have moc to compile something with lablqt
<DimitryKakadu>
A difficult way is to rewrite entire moc, to generate directly C++ metaobject functions.
<DimitryKakadu>
I think that first way is faster to implement. I should go with first way.
<DimitryKakadu>
Any comments?
oriba has joined #ocaml
Kevin has quit [Remote host closed the connection]
Anarchos has joined #ocaml
ftrvxmtrx has quit [Quit: Leaving]
sebz has quit [Quit: Computer has gone to sleep.]
sebz has joined #ocaml
sebz has quit [Client Quit]
jamii has quit [Ping timeout: 260 seconds]
sebz has joined #ocaml
joewilliams is now known as joewilliams_away
arubin has joined #ocaml
sebz has quit [Quit: Computer has gone to sleep.]
dnolen has joined #ocaml
sebz has joined #ocaml
jaar has quit [Ping timeout: 260 seconds]
fraggle_ has quit [Ping timeout: 260 seconds]
jaar has joined #ocaml
sebz has quit [Quit: Computer has gone to sleep.]
sebz has joined #ocaml
fraggle_ has joined #ocaml
ftrvxmtrx has joined #ocaml
sebz has quit [Quit: Computer has gone to sleep.]
sebz has joined #ocaml
sebz has quit [Client Quit]
Modius has quit [Quit: "Object-oriented design" is an oxymoron]
lpereira has joined #ocaml
ftrvxmtrx has quit [Quit: Leaving]
zorun has joined #ocaml
DimitryKakadu has quit [Quit: Konversation terminated!]
edwin has quit [Remote host closed the connection]
yroeht has quit [Ping timeout: 260 seconds]
dnolen has quit [Quit: dnolen]
yroeht has joined #ocaml
ygrek has quit [Quit: Leaving]
krktz has quit [Remote host closed the connection]
goncalo has joined #ocaml
Amorphous has quit [Ping timeout: 260 seconds]
dnolen has joined #ocaml
Skolem has quit [Quit: Skolem]
junsuijin has joined #ocaml
Amorphous has joined #ocaml
taupin has quit [Ping timeout: 252 seconds]
taupin has joined #ocaml
Anarchos has quit [Quit: Vision[0.9.7-H-090423]: i've been blurred!]
rgrinberg has joined #ocaml
<rgrinberg>
how do I copy a file in ocaml?
lpereira has quit [Quit: Leaving.]
wtetzner has quit [Remote host closed the connection]
Cyanure has quit [Ping timeout: 260 seconds]
wagle has quit [Remote host closed the connection]
wagle has joined #ocaml
wagle has quit [Remote host closed the connection]
wagle has joined #ocaml
sebz has joined #ocaml
ulfdoz_ has joined #ocaml
sebz has quit [Client Quit]
rgrinberg has quit [Remote host closed the connection]