Author |
Message |
DougT
Junior
Joined: 02 Dec 2014 17:04 Posts: 5 Location: 50.97.94.54
|

I am enjoying hopeless quite a bit. My main documentation is from the book "Functional Programming" by Field and Harrison. I have ordered a used copy of "Functional Programming with Hope" by Bailey. I mainly use F# on Ubuntu and some Haskell. I like the small size of hopeless, the source code, and the quick compilation of hopeless.
Several things that I have noticed (Which I have communicated to Alexander):
1. The text uses named arguments (such as a name for a list pattern), which is not in hopeless. 2. I cannot enter a negative number such as -3, I have to use 0-3; 3. If numbers are set to longs, there is no abs function (not a big deal). 4. Some functions like map have a different syntax than the text. I will document this more fully at a later time. 5. It would be very nice to have the capability to retrieve the last command and edit it (a getline capability).
My biggest project (not very big) is a rational data type with associated functions. When I create a rational number (syntax r(n,d), n is the numerator, d the denominator, both numbers), I would like to be able to get it a "normal" form: remove the gcd from both n and d, and put the sign in the numerator. This does not seem possible on data creation, but a later function call is needed to perform this.
Regards, Doug
|
02 Dec 2014 17:32 |
|
 |
Shaos
Admin
Joined: 08 Jan 2003 23:22 Posts: 21044 Location: Silicon Valley
|
Thanks Doug! I'm also a little confused by new map definition and foldr instead of reduce, but it most likely will stay like this because I don't want to touch original Hope libraries. All other things I agree to fix sooner or later - especially last command functionality ( it's 1st item on my ToDo list on hopelog.com ).
P.S. What do you mean by setting numbers to longs? Removing REALS macrodefinition from num.h and recompiling?
|
02 Dec 2014 17:55 |
|
 |
DougT
Junior
Joined: 02 Dec 2014 17:04 Posts: 5 Location: 50.97.94.54
|
Yes, by "setting numbers to longs", I really mean removing the REAL definition and recompiling.
How difficult is it to fix the creation of negative number problem?
Regards,
Doug
|
03 Dec 2014 06:06 |
|
 |
Shaos
Admin
Joined: 08 Jan 2003 23:22 Posts: 21044 Location: Silicon Valley
|
Do you use version from GitHub? I can try to fix it there first (before actual releasing of next version of Hopeless).
P.S. In this implementation unary + and - can not be declared, because binary + and - have the same name, and in the same time based on parsing source code any number must start with digit, so I can try to fix negative numbers by checking for '-' as possible start of a number (and probably '+') during parsing...
|
03 Dec 2014 09:11 |
|
 |
DougT
Junior
Joined: 02 Dec 2014 17:04 Posts: 5 Location: 50.97.94.54
|
Yes, I used the version from GitHub. It is version Hopeless v0.6RC
-- Doug
|
03 Dec 2014 21:49 |
|
 |
Shaos
Admin
Joined: 08 Jan 2003 23:22 Posts: 21044 Location: Silicon Valley
|
Ok, I see, thanks
Also in order to implement last command (and probably syntax highlighting) I should switch to ncurses (I'll make it optional) - you need arrows up/down to work as history scroll, right?
|
03 Dec 2014 22:25 |
|
 |
DougT
Junior
Joined: 02 Dec 2014 17:04 Posts: 5 Location: 50.97.94.54
|
Hello,
In fsi, the interactive F#, the up/down arrow keys access the interactive command history. Once the desired command is located, it can be edited by using the left and right arrow keys to place the cursor at the desired position. If you type at the cursor, new text is inserted, and if you press the Delete key, the current character is deleted.
-- Doug
|
04 Dec 2014 19:48 |
|
 |
Shaos
Admin
Joined: 08 Jan 2003 23:22 Posts: 21044 Location: Silicon Valley
|
Ok, understood
|
04 Dec 2014 20:50 |
|
 |
DougT
Junior
Joined: 02 Dec 2014 17:04 Posts: 5 Location: 50.97.94.54
|
Concerning our discussion about hopeless being a lazy language:
It is lazy with respect to evaluating arguments to a function (evaluating by need), but it is not lazy with a function like
! infinite list
dec from : num -> list(num);
--- from n <= n :: from(n+1);
if you execute from(1), you need a CTRL-C to stop it. The book by Bailey discusses a lazy cons operator ::: in a version of Hope that would make the above lazy.
If you execute lcons(10,0,from(1)), you will get the list 0 thru 9.
! lazy cons
dec lcons: num # num # list(num) -> list(num);
--- lcons (0,num,(h::t)) <= [];
--- lcons (cnt, num,(h::t)) <= num :: lcons(cnt-1,h,t);
Hopeless behaves just like Haskell with respect to lazyness.
-- Doug
|
22 Dec 2014 15:46 |
|
 |
Shaos
Admin
Joined: 08 Jan 2003 23:22 Posts: 21044 Location: Silicon Valley
|
This particular implementation is fully lazy as I know
|
27 Dec 2014 19:33 |
|
|