[erlang-questions] records and types

Ward Bekker <>
Mon Oct 17 08:59:08 CEST 2011

I have the following (compiling) record and type definitions:

-record( field, {name :: unicode:unicode_binary()}).
-record( schema,{name :: unicode:unicode_binary(), fields :: [ #field{} ]}).
-type text_field() :: #field{}.
-type integer_field() :: #field{}.

The following function will give compile errors:

demo_schema() ->
    #schema{ name = u("stackoverflow_post"),
	     fields = [
		       #text_field{ name = u("title") },
		       #integer_field{ name = u("user_id") }		       

Is it possible to create a field record using the type definition name? Or do I need to define a record for every field type? 



More information about the erlang-questions mailing list