erlang

Erlang: module attribute

I am new to Erlang. Found the following -module attribute declaration in an existing Erlang project: -module(mod_name, [Name, Path, Version]). What does mean the second parameter (list [Name, Path, Version]) here? I haven't found any information in the Erlang reference on it. ...

When to use gen_server in Erlang/OTP applications

Having read Joe Armstrong's book and watched Kevin Smith screencasts I've built a simple OTP application comprised of a single gen_server and single supervisor, bundled together as an OTP application. Now I'm looking at mochiweb and have created a sample project [helloworld] using the new_mochiweb.erl script. Browsing the source code I ...

wxErlang - What is wrong with this code?

I am very new to erlang and am trying to get my head around wxerlang but have hit a wall. Can someone have a look at this code and tell me what is wrong. I think it is something very obvious, but I just can't work it out. -module(main). -include_lib("include/wx.hrl"). -behavoiur(wx_object). -export([start/0]). %% API -export([init...

State in Erlang Digraphs

The Erlang digraphs module surprised me by mutating state. When dealing with other data structure modules in Erlang, for instance the sets module, the instance of the data structure passed in, is unmodified. The function returns a new, altered version e.g. >S = sets:new(). >sets:size(S). 0 >T = sets:add_element(S, "element"). >sets:siz...

Change directory using os:cmd/1

I am trying to change the directory in the command line from a gen_server using os:cmd("cd d:\temp"). but nothing happense, the return is just an empty list and I remain in the same directory. any ideas? ...

Make a process end before timeout

It seems that an erlang process will stay alive until the 5 sec default timeout even if it has finished it's work. I have gen_server call that issues a command to the window CLI which can be completed in less than 1 sec but the process waits 5 sec before I see the result of the operation. What's going on? is it soemthing to do with the...

Records in Erl (Erlang question)

Is there a way to use records directly in erl? No matter what I try, it always says it canno find the record. I am trying to do mnesia transactions and I cannot go too far without my records. Any help is greatly appreciated - thank you! ...

How expensive is gluing binaries (list_to_binary)?

One process listen to server on async socket and on each message {tcp, Socket, Bin} takes it's buffer and: Data = list_to_binary([Buffer, Bin]), {next_state, 'READY', State#state{buffer = Data}}. On some events it flushes buffer: 'READY'({flush}, #state{buffer = Buffer} = State) -> {reply, {Buffer}, 'READY', State#state{buffer = <<>...

Mixing Erlang and Haskell

If you've bought into the functional programming paradigm, the chances are that you like both Erlang and Haskell. Both have purely functional cores and other goodness such as lightweight threads that make them a good fit for a multicore world. But there are some differences too. Erlang is a commercially proven fault-tolerant language ...

How can I determine if a list is a just a string or a list of strings?

I have a variable that can either contain a list of strings or a just a string. Is there a good way to tell what kind I'm dealing with? "192.168.1.18" vs. ["192.168.1.18", "192.168.1.19"] In either case I want to use the bits involved. ...

Erlang: how to disable "crash dump" & "core dump" generation?

Is there any way to disable the generation of "crash dump" & "core dump" files when running 'erl' ? PS: I know about the "+d" option of erl but I want to completely disable the generation of crash/core dumps. ...

Apple Push Notification in Erlang (or improved in Ruby?)

I currently have an Apple Push Notification running on my server in Ruby. I'd like to get one going in Erlang as I'd like to use a supervisor to keep watch over it. Does anyone have any code that they could help me with? Here's my Ruby code. One thing I do not like about this current implementation is that it does not seem to stay ...

Problem extracting xml text with Erlang xmerl_xpath

I'm trying to extract text from an xml node using Erlang's xmerl_xpath: [include "xmerl.hrl"] {Doc, _}=xmerl_scan:string("<node>Hello World</node>"). [#xmlText{value=Text}]=xmerl_xpath:string("//node/text()", Doc). Text. "Hello World" Works fine for this simple example. Problem occurs when the text in the node element is very larg...

Erlang: is version checking strict in release files?

After reading 10.2 Release Resource File, I get the impression that each application release is very much tied down to a specific release of Erlang OTP. Is this true? Can the version information in the .rel file be written along the following lines? {release, {"ch_rel", "A"}, {erts, "5.3"}, [{kernel, ">=2.9"}, ...

Erlang: daemon 'init.d' script fails to start

I have a python script which manages an Erlang daemon. Everything works fine when used through a shell once the system is initialized. Now, when I included the same script under "/etc/init.d" and with the symlinks properly set in "/etc/rcX.d", the python script still works but my Erlang daemon fails to start and leaves no discernible tr...

Erlang: is there an equivalent to the C preprocessor ## directive?

Is there an equivalent to the C preprocessor directive ## in Erlang? Let's say I want to concatenate two atom() using a -define preprocessor directive, how would I do this without having run-time side-effects? ...

Erlang erlIDE: what are the -compile options supported?

I've been trying to get erlIDE to work with -compile options e.g. -compile('S'). % Generate 'assembler' listing to no avail. What I am doing wrong? NOTE: I have also tried setting 'project specific' options for the compiler with no success. EDIT: could it be that 'erlc' is invoked and forced to generate a 'beam' and thus disreg...

Erlang: Are there any Atompub (Atom Publishing Protocol) libraries available?

Are there any Atompub (Atom Publishing Protocol) libraries available for Erlang? ...

Yaws crashes when I browse to my new erlyweb application

I am following the music application article on Yarivs blog. When I go to http://localhost:8002 I get the index page showing correctlty but if I try to browse to http://localhost:8002/music I get this error(see Pastie), When I browse http://localhost:8002/musician i get page not found, even though I have created the musician component. ...

ejabberd: Difference between "disco_local_identity" and "disco_sm_identity" ?

What is the difference between "disco_local_identity" and "disco_sm_identity" module API methods? ...