1

Topic: Haskell: questions

The topic arose throughout
Here I will be  various questions on it .
a question 1. Here I try to create infix operator * + *.

Prelude> infixl 6 * + *
<interactive>:10:10: error:
The fixity signature for ` * + * ' lacks an accompanying binding

Comment on an error and as .

2

Re: Haskell: questions

mayton wrote:

the Topic arose throughout
Here I will be  various questions on it .
a question 1. Here I try to create infix operator * + *.

Prelude> infixl 6 * + *
<interactive>:10:10: error:
The fixity signature for ` * + * ' lacks an accompanying binding

Comment on an error and as .

to begin with it is necessary to create, i.e. to declare.
Let it will be the normal total, for example (but it is possible to appropriate also other function to this sign).
And to do it it is necessary not in the interpreter.
Create a file, there write the code, and then load in ghci (https://downloads.haskell.org/~ghc/7.6. … files.html)
The code as the such:

(* + *) = (+)
infixl 6 * + *

3

Re: Haskell: questions

Created a file tut02.hs

infixl 6 * + *
a * + * b = a^2 + b^2
-- 3 * + * 4
-- 3 (* + *) 4
(* + *) 3 4

:load in the interpreter

Prelude>:l tut02.hs
[1 of 1] Compiling Main (tut02.hs, interpreted)
tut02.hs:8:1: error:
Parse error: module header, import declaration
or top-level declaration expected.
|
8 | (* + *) 3 4
| ^^^^^^^^^
Failed, no modules loaded.

4

Re: Haskell: questions

Tried to define the list of constants. Something not so I do. Gaps and TAB play a role? Where? In what place?

let width = 512
height = 512
g = [
0x0003C712;
0x00044814,
0x00044818,
0x0003CF94,
0x00004892,
0x00004891,
0x00038710;
0x00000010;
0x00000010
]
Prelude>:l card.hs
[1 of 1] Compiling Main (card.hs, interpreted)
card.hs:18:5: error:
parse error (possibly incorrect indentation or mismatched brackets)
|
18 |]
| ^
Failed, no modules loaded.

5

Re: Haskell: questions

mayton wrote:

Created a file tut02.hs

infixl 6 * + *
a * + * b = a^2 + b^2
-- 3 * + * 4
-- 3 (* + *) 4
(* + *) 3 4

:load in the interpreter

Prelude>:l tut02.hs
[1 of 1] Compiling Main (tut02.hs, interpreted)
tut02.hs:8:1: error:
Parse error: module header, import declaration
or top-level declaration expected.
|
8 | (* + *) 3 4
| ^^^^^^^^^
Failed, no modules loaded.

So all is correct.
This expression:

(* + *) 3 4

No sense has, for is not determinations.
And   - only from determinations sostoit.\
Here if you wrote:

x = (* + *) 3 4

Or it is better:

x = 3 (* + *) 4

6

Re: Haskell: questions

mayton;
I.e. you at first load the unit with determinations of functions.
And in the interpreter you can already write

(* + *) 3 4

And to receive the answer

7

Re: Haskell: questions

mayton wrote:

Gaps and TAB play a role? Where? In what place?

Yes. Play.
Such operator as let in   is not present (not the interpreter), is "let... in.", but it already other history.
It is necessary so to define:

width = 512
height = 512
g = [
0x0003C712;
0x00044814,
0x00044818,
0x0003CF94,
0x00004892,
0x00004891,
0x00038710;
0x00000010;
0x00000010
]

8

Re: Haskell: questions

ZyK_BotaN wrote:

such operator as let in   is not present

it is, but within the limits of syntax for monads.
Working in the interpreter, you as  live in a monad, therefore and   sugar "let" for binding of values. With frames of the normal code, "let" it is not necessary.

9

Re: Haskell: questions

ZyK_BotaN wrote:

but within the limits of syntax for monads.

The do-notation:
https://en.wikibooks.org/wiki/Haskell/do_notation

10

Re: Haskell: questions

Give an overload of the operator . It is not necessary Yet.
Apropos let. Like helped. + included in notepad ++ illumination TAB and  some
Problems.  Haskell it is sensitive to invisible characters.

11

Re: Haskell: questions

mayton wrote:

Vobshchem Haskell is sensitive to invisible characters.

Yes. As a python.

12

Re: Haskell: questions

. Further. The primitive "a vector in 3 measured space" is necessary to me.  it is necessary to declare something
Like

struct Vector {
double x, y, z;
}

And to define for it API for the main vectorial operations. Thus we imply that the vector beginning
Always lies in a point (0,0,0).
I so understand that it can be Tuple. And can and Not-tapl. The horse-radish knows. But in the given setting I am finite
I will prefer that decision which more performance.
I hope that static typification and 100 % type help Haskelu to remove an output unnecessary
In the binary code and to collect the effective.

13

Re: Haskell: questions

mayton wrote:

I so understand that it can be Tuple. And can and Not-tapl.

It is possible and through .
And it is possible and through algebraic data type

14

Re: Haskell: questions

ZyK_BotaN wrote:

and it is possible and through algebraic data type

Something of type such:

data Vector = Vector Int Int Int
deriving (Show, Eq)

15

Re: Haskell: questions

Give through tuple while.

16

Re: Haskell: questions

mayton wrote:

Give through tuple while.

Well then so:

type Vector = (Int, Int, Int)

17

Re: Haskell: questions

And functions to write so:

summation:: Vector-> Vector-> Vector
summation (x1, y1, z1) (x2, y2, z2) = (x1 + x2, y1 + y2, z1 + z2)

18

Re: Haskell: questions

. Give me time till the evening. Here it is not difficult .  for  is.
Difficult  for example  multiplication of vectors. In Java/Junit was special
assert (...) with some sigma. It was possible to check approximate calculations.

type Vector = (Double, Double, Double)

19

Re: Haskell: questions

mayton wrote:

Here it is not difficult

In  you are waited by reefs. On it it is necessary to write not as on  everyones.

20

Re: Haskell: questions

mayton wrote:

it is difficult  for example  multiplication of vectors. In Java/Junit was special
assert (...) with some sigma. It was possible to check approximate calculations.

Well to write function of comparing with a sigma not difficult after all.

21

Re: Haskell: questions

Yes. I think I will make separate ... The unit... ? All right is shorter while integration did not reach.
Application which testitis itself is simple.

22

Re: Haskell: questions

ZyK_BotaN wrote:

it is passed...
Well to write function of comparing with a sigma not difficult after all.

Something like:

let eqs s a b = s> abs a - b

23

Re: Haskell: questions

Declared. Yet test silt. Something vector normalization looks somehow . It is verbose that-whether.
In  was more compact.

type Vector = (Double, Double, Double)
sum:: Vector-> Vector-> Vector
sum (x1, y1, z1) (x2, y2, z2) = (x1 + x2, y1 + y2, z1 + z2)
prod:: Vector-> Double-> Vector
prod (x, y, z) (r) = (r * x, r * y, r * z)
sprod:: Vector-> Vector-> Double
sprod (x1, y1, z1) (x2, y2, z2) = x1 * x2 + y1 * y2 + z1 * z2
norm:: Vector-> Vector
==> norm (x, y, z) = prod (x, y, z) (1.0 / sqrt (sprod ((x, y, z) (x, y, z))));

24

Re: Haskell: questions

mayton wrote:

In  was more compact.

Well the last line that was possible and so to write:

norm v = prod v $1.0 / sqrt $ sprod v v;

25

Re: Haskell: questions

mayton wrote:

(r)

What for in brackets took argument?