PreviousUpNext

15.4.752  src/lib/global-controls/global-control-junk.pkg

## global-control-junk.pkg

# Compiled by:
#     src/lib/global-controls/global-controls.lib


stipulate
    package f8b =  eight_byte_float;                                    # eight_byte_float      is from   src/lib/std/eight-byte-float.pkg
herein

    package   global_control_junk
    : (weak)  Global_Control_Junk                                       # Global_Control_Junk   is from   src/lib/global-controls/global-control-junk.api
    {
        #
        #

        # For each control type, itemize how to convert an
        # input string to the appropriate control value type,
        # and also how to convert the control's value type
        # to a string for display purposes: 

        package cvt {                                                   # "cvt" == "convert"

            int   = { name_of_type   => "Int",
                      from_string =>  int::from_string,
                      to_string   =>  int::to_string
                    };

            bool  = { name_of_type   => "Bool",
                      from_string =>  bool::from_string,
                      to_string   =>  bool::to_string
                    };

            float = { name_of_type   => "Float",
                      from_string =>  f8b::from_string,
                      to_string   =>  f8b::to_string
                    };

            string_list
                   =
                   { name_of_type   => "List(String)",
                     from_string => THE o string::fields (\\ c =  c == ','),
                     to_string   => \\ []     =>  "";
                                       [x]    =>  x;
                                        x ! r =>  cat                   # Build a comma-separated string.
                                                      ( x
                                                        !
                                                        list::fold_backward
                                                            (\\ (y, l) =  ", " ! y ! l)
                                                            []
                                                            r
                                                      );
                                    end 

                     };

            my string:  global_control::Value_Converter( String )
                =
                { name_of_type   =>  "String",
                  from_string =>  THE,
                  to_string   =>  \\ x = x                              # Converting strings to strings is easy! :)
                };
        };

        package dn {                                                    # "dn" == "dictionary_name". (Is there any reason to have this fn in a separate package??)
            #
            fun to_upper  prefix  string
                =
                prefix                                                  # Prepend prefix.
                +                                                       # String concatenation.
                string::map
                    \\ '-' =>  '_';                                     # Dashes go to underlines.
                        c  =>  char::to_upper c;                        # Alphabetics go to uppercase.
                    end
                    string;
        };
    };
end;


## COPYRIGHT (c) 2002 Bell Labs, Lucent Technologies
## Subsequent changes by Jeff Prothero Copyright (c) 2010-2015,
## released per terms of SMLNJ-COPYRIGHT.


Comments and suggestions to: bugs@mythryl.org

PreviousUpNext