hamler-lang / hamler

Haskell-style functional programming language running on Erlang VM.
https://www.hamler-lang.org/
BSD 3-Clause "New" or "Revised" License
1.03k stars 39 forks source link

How to import `sum`? ... `mod`? etc #430

Closed llaisdy closed 4 years ago

llaisdy commented 4 years ago

Is there something wrong with my set up?

$ hamler repl
Hamler REPL, version 0.2.2
Type :? for help

> xs = range 0 9
> xs
[0,1,2,3,4,5,6,7,8,9]
> sum xs
Error found:
in module $REPL
at :1:1 - 1:4 (line 1, column 1 - line 1, column 4)

  Unknown value sum

or to contribute content related to this error.

I get similar error with eg 9 mod 2.

Same error in the repl and in a module. Same error if I import {Prelude, Data.Foldable, ...}.

  1. Is something wrong with my set up (Hamler 0.2.2 from brew)?
  2. How do I find which module has a function?

Keen to start using Hamler properly, even if it is not complete.

llaisdy commented 4 years ago

nb I can defined sum, but I'd like to know how to find & import library functions.

> sum = foldl (+) 0
> sum xs
45
niltok commented 4 years ago

428 for sum

we will add mod soon

sdzx-1 commented 4 years ago

@laisdy We have added Project Layout in README.md. This might help you.

llaisdy commented 4 years ago

@EMQ-YangM Thanks - very helpful

@EMQ-YangM @emqplus @goldimax so, very much a work-in-progress? I've been using the release from homebrew, but it might be better if I cloned this repo and compiled from source?

llaisdy commented 4 years ago

Actually, mod (modulo) in erlang is rem, which you have:

> import Data.Ring
> rem 9 2
1
> 9 `rem` 2
1