1 Replies - 1411 Views - Last Post: 19 January 2011 - 08:56 AM

#1 Guest_Mr. Mann*


Reputation:

OCaml Recursive or Kleene Star types

Posted 18 January 2011 - 10:40 PM

Alright so I've been attempting a few problems for like 10 hours over the past couple days with no luck.

One problem is to model propositional logic (ie. True OR True, True, False AND True, etc.)

I was trying to define a type

type id = T | F;;
type op = AND | OR;;
type logic = id | id*op*logic;;



to accept stuff like:
T
F
(T,AND,T)
(F,OR,T)
etc.

Of course, OCaml doesn't like it. Is there a way to make it to accept a type similar to that?

OCaml accepts something like
type id = int;;


or
type id = Int of int | String of string;;


but it isn't ok with multiple types without the "of typex" part

It's not ok with
type id = int | string;;


or
type id = int | (int*int);;


or
type id = int | (int*id);;



That last one would be really nice to have, so is there a way to do it?

Is This A Good Question/Topic? 0

Replies To: OCaml Recursive or Kleene Star types

#2 Guest_Mr. Mann*


Reputation:

Re: OCaml Recursive or Kleene Star types

Posted 19 January 2011 - 08:56 AM

Nevermind, I figured it out.
Was This Post Helpful? 0

Page 1 of 1