caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Error: Unbound value abs_num
@ 2013-07-21 10:47 zech.ph
  2013-07-21 11:25 ` David Allsopp
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: zech.ph @ 2013-07-21 10:47 UTC (permalink / raw)
  To: caml-list

Hi,

I'm new to OCaml and already struggling around with the seemingly easiest
things.
Following some introductory texts I wanted to play around a little with the
toplevel and its various features, among others, using provided modules. For
this, I thought about loading nums.cma and try some of its defined functions,
but it just does not work. See below for what I do in the toplevel and the
respective output.

> ocaml
        OCaml version 4.00.1
# #load "nums.cma";;
# abs_num 4;;
Error: Unbound value abs_num
# abs 4;;
- : int = 4

From my point it looks like I do not miss anything, yet, I just can't call
abs_num. And I don't know why. I'm working on a Fedora 19 x64. I checked
Bugzilla, but couldn't find any Fedora related issues (at least for this
behavior).

Thanks for any help,

Phil

PS: I know about the beginner's list at yahoo, however, I chose this one as I
don't like their style of forced social integration using different
services...I hope this is ok...

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Caml-list] Error: Unbound value abs_num
  2013-07-21 10:47 [Caml-list] Error: Unbound value abs_num zech.ph
@ 2013-07-21 11:25 ` David Allsopp
  2013-07-21 11:33 ` Jean-Marc Alliot
  2013-07-21 11:44 ` zech.ph
  2 siblings, 0 replies; 5+ messages in thread
From: David Allsopp @ 2013-07-21 11:25 UTC (permalink / raw)
  To: zech.ph; +Cc: caml-list

zech.ph@gmail.com wrote:

> Hi,
> 
> I'm new to OCaml and already struggling around with the seemingly easiest
> things.
> Following some introductory texts I wanted to play around a little with the
> toplevel and its various features, among others, using provided modules. For
> this, I thought about loading nums.cma and try some of its defined functions,
> but it just does not work. See below for what I do in the toplevel and the
> respective output.
> 
>> ocaml
>        OCaml version 4.00.1
> # #load "nums.cma";;
> # abs_num 4;;
> Error: Unbound value abs_num

You need to qualify the identifier or open the module - abs_num is in the Num module (which you've correctly #load'd with nums.cma) so you either say:

Num.abs_num 4;;
or
open Num;;
abs_num 4;;

however you'll then hit another problem - abs_num needs a num not an int so you really mean:

Num.abs_num (Num.Int 4);;

> # abs 4;;
> - : int = 4
> 
> From my point it looks like I do not miss anything, yet, I just can't call
> abs_num. And I don't know why. I'm working on a Fedora 19 x64. I checked
> Bugzilla, but couldn't find any Fedora related issues (at least for this
> behavior).

It's unlikely when beginning that you'll hit either a big in OCaml or your distro - better to stick with the assumption that you've made a mistake and ask for help (as you have!)


David

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Caml-list] Error: Unbound value abs_num
  2013-07-21 10:47 [Caml-list] Error: Unbound value abs_num zech.ph
  2013-07-21 11:25 ` David Allsopp
@ 2013-07-21 11:33 ` Jean-Marc Alliot
  2013-07-21 11:44 ` zech.ph
  2 siblings, 0 replies; 5+ messages in thread
From: Jean-Marc Alliot @ 2013-07-21 11:33 UTC (permalink / raw)
  To: caml-list

Basic mistake :-)

Loading is not the same as opening.

You can either do (after #load):
# open Num;;
# abs_num;;
- : Num.num -> Num.num = <fun>

Or qualify the function with th module name:
# Num.abs_num;;
- : Num.num -> Num.num = <fun>

And then don't forget abs_num needs a Num as an argument (and returns a Num)
# abs_num (Num.Int 4);;
- : Num.num = Int 4

And it's Num.Int and not Num.int (it is a constructor, not a function).



Le 21/07/2013 12:47, zech.ph@gmail.com a écrit :
> Hi,
>
> I'm new to OCaml and already struggling around with the seemingly easiest
> things.
> Following some introductory texts I wanted to play around a little with the
> toplevel and its various features, among others, using provided modules. For
> this, I thought about loading nums.cma and try some of its defined functions,
> but it just does not work. See below for what I do in the toplevel and the
> respective output.
>
>> ocaml
>          OCaml version 4.00.1
> # #load "nums.cma";;
> # abs_num 4;;
> Error: Unbound value abs_num
> # abs 4;;
> - : int = 4
>
> >From my point it looks like I do not miss anything, yet, I just can't call
> abs_num. And I don't know why. I'm working on a Fedora 19 x64. I checked
> Bugzilla, but couldn't find any Fedora related issues (at least for this
> behavior).
>
> Thanks for any help,
>
> Phil
>
> PS: I know about the beginner's list at yahoo, however, I chose this one as I
> don't like their style of forced social integration using different
> services...I hope this is ok...
>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Caml-list] Error: Unbound value abs_num
  2013-07-21 10:47 [Caml-list] Error: Unbound value abs_num zech.ph
  2013-07-21 11:25 ` David Allsopp
  2013-07-21 11:33 ` Jean-Marc Alliot
@ 2013-07-21 11:44 ` zech.ph
  2013-07-21 11:45   ` zech.ph
  2 siblings, 1 reply; 5+ messages in thread
From: zech.ph @ 2013-07-21 11:44 UTC (permalink / raw)
  To: caml-list

Hi,

thanks a lot for your helping and clearing up my understanding!

@David: The idea to search for a potential bug was just due to that it's a
freshly installed system and, e.g.; scala currently cannot be installed from
the repositories due to some missing dependencies...so I just thought about it
being something similar (in terms of a bug due to a new release...).

But anyway, thanks a lot!

Cheers,

Phil

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Re: [Caml-list] Error: Unbound value abs_num
  2013-07-21 11:44 ` zech.ph
@ 2013-07-21 11:45   ` zech.ph
  0 siblings, 0 replies; 5+ messages in thread
From: zech.ph @ 2013-07-21 11:45 UTC (permalink / raw)
  To: caml-list, zech.ph

your help ;)

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-07-21 11:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-21 10:47 [Caml-list] Error: Unbound value abs_num zech.ph
2013-07-21 11:25 ` David Allsopp
2013-07-21 11:33 ` Jean-Marc Alliot
2013-07-21 11:44 ` zech.ph
2013-07-21 11:45   ` zech.ph

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).