51

Re: Haskell: questions

mayton wrote:

why output did not work?

Copied your code. All works for me.

52

Re: Haskell: questions

ZyK_BotaN wrote:

it is passed...
Copied your code. All works for me.

53

Re: Haskell: questions

ZyK_BotaN wrote:

it is passed...
Well so while you also should not know these theories.

Thank God. I think the Bug that I  to them. But I look at Haskell with .  with a question
- "What can you give to me"? I like the true polymorphism. I mean ability of functions
To accept to (reduce) the arbitrary dial-up of arguments and also it is lazy them to calculate and calculate the infinite
Sequences.
It . It is a new level of freedom which it is inaccessible to another . But I am finite I do not want
As Don-Kihot to be at war with mills. I will spend on I/O some number of man-hours. Further
I will simply postpone it. There are another matters. Not less interesting.

54

Re: Haskell: questions

mayton;
main it is automatically launched, if  a source code in an executed file and it to launch.
Loading a source code in ghci, main it is necessary to launch explicitly.

55

Re: Haskell: questions

. And you too in the console sit as I? Or there are environments?

56

Re: Haskell: questions

mayton wrote:

I will spend on I/O some number of man-hours.

There is not present on what to waste time.
(not only ) a piece interesting.
Here it is not bad uncovered:
https://rsdn.org/article/funcprog/monad.xml
But what to work with input-vovodom in  (at the initial stages), the theory about monads the nobility not mandatory.

57

Re: Haskell: questions

mayton wrote:

Okej. And you too in the console sit as I? Or there are environments?

Can and is. I ++ write to a notepad.  from the console.

58

Re: Haskell: questions

. It as strange itself(himself) conducts that.

C:\Users\mayton\Documents\Haskell>tut02.exe
eee
Enter you name: Hello eee

At first I receive an input context. And then the first function of the press  fulfills. And the third with  .
me take!  take this Haskela together with Chorchem!!

59

Re: Haskell: questions

mayton wrote:

Skompilil. It as strange itself(himself) conducts that.

C:\Users\mayton\Documents\Haskell>tut02.exe
eee
Enter you name: Hello eee

At first I receive an input context. And then the first function of the press  fulfills. And the third with  .
me take!  take this Haskela together with Chorchem!!

main = do
putStrLn "Enter you name:"
name <- getLine
putStr ("Hello" ++ name)

60

Re: Haskell: questions

All is exact so dock.

61

Re: Haskell: questions

mayton wrote:

All is exact so dock.

What so, you noted a difference?

62

Re: Haskell: questions

putStrLn? And how it influences the order of arguments?

63

Re: Haskell: questions

mayton wrote:

putStrLn? And how it influences the order of arguments?

Here not in arguments, probably, and in an output buffer.
The buffer in the lines, probably, deduces.
-  the termination of a line, here you also see in  an output at once.
And , only in  exhausts characters, and you them see, only already when itself translated a line in .

64

Re: Haskell: questions

... Well now input works in the true order. But the cursor springs at the wrong time.

Enter you name:
sss
Hello sss

65

Re: Haskell: questions

Links which found. Are useful in a topic. I write for myself.
Learning Haskell http://learn.hfm.io/
School of Haskell https://www.schoolofhaskell.com/
GHC User Guide https://downloads.haskell.org/~ghc/late … ers_guide/
Books https://wiki.haskell.org/Books
Very specific format of the documentation does not allow me while to search API for itself.
For example. How to convert Double in String. I guess that it there should be a function
Type Double-> String. But give to me  take the qualifier or a road map on API.

66

Re: Haskell: questions

import System. IO
import Text. Printf
tostring:: Vector-> String
tostring (x, y, z) =
"("++ x ++","++ y ++","++ z")"
v1 = (3.0, 4.0, 5.0)
main = do
putStrLn ("v1 =" ++ (tostring v1))
.....
card.hs:43:33: error:
* Couldn't match expected type ` [Char]-> [Char]'
with actual type ` Double'
* The function ` z ' is applied to one argument;
but its type ` Double ' has none
In the second argument of ` (++) ', namely ` z ")"'
In the second argument of ` (++) ', namely ` "," ++ z ")"'
|
43 | "("++ x ++","++ y ++","++ z")"
| ^^^^^
Failed, no modules loaded.

67

Re: Haskell: questions

mayton wrote:

very specific format of the documentation does not allow me while to search API for itself.
For example. How to convert Double in String. I guess that it there should be a function
Type Double-> String. But give to me  take the qualifier or a road map on API.

Function show

68

Re: Haskell: questions

ZyK_BotaN wrote:

it is passed...
Function show

The type should implement typeclass Show (it something like the interface from , with that only a difference that binding early, instead of ).

69

Re: Haskell: questions

mayton wrote:

import System. IO
import Text. Printf
tostring:: Vector-> String
tostring (x, y, z) =
"("++ x ++","++ y ++","++ z")"
v1 = (3.0, 4.0, 5.0)
main = do
putStrLn ("v1 =" ++ (tostring v1))
.....
card.hs:43:33: error:
* Couldn't match expected type ` [Char]-> [Char]'
with actual type ` Double'
* The function ` z ' is applied to one argument;
but its type ` Double ' has none
In the second argument of ` (++) ', namely ` z ")"'
In the second argument of ` (++) ', namely ` "," ++ z ")"'
|
43 | "("++ x ++","++ y ++","++ z")"
| ^^^^^
Failed, no modules loaded.

It would be possible to write so:

tostring:: Vector-> String
tostring (x, y, z) =
"("++ (show x) ++","++ (show y) ++","++ (show z) ++")"

But it I do not rub twist.
In the first, for a vector and so function show is already implemented.
In the second if for your type it is not implemented, you should specify that your type is  class Show and to implement for it function show. By the way, for algebraic types, it can be implemented automatically, here I above to you resulted type for which types of show and  are automatically implemented:

ZyK_BotaN wrote:

it is passed...
Something of type such:

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

70

Re: Haskell: questions

ZyK_BotaN wrote:

in the first, for a vector and so function show is already implemented.

I.e. it is possible to write:

main = do
putStrLn ("v1 =" ++ (show v1))

71

Re: Haskell: questions

ZyK_BotaN wrote:

but it I do not rub twist.
In the first, for a vector and so function show is already implemented.
In the second if for your type it is not implemented, you should specify that your type is  class Show and to implement for it function show. By the way, for algebraic types, it can be implemented automatically, here I above to you resulted type for which types of show and  are automatically implemented:

How it is implemented? To me are necessary round . It will be important for testing.
In the standard documentation I sink. Thanks for show/eq. If you throw
Where is firm dock + usage example - I will be grateful. Many things
Are unusual. I brake not because I do not know as it to make. And is faster it is too much
Knowledge and it is too much variants as it to make brake me. And I owing to the
I can not select true way.  for this purpose I also lifted a topic.

72

Re: Haskell: questions

I will run forward.
The fragment From ++ th function which has very unsuitable for  a type. It it is necessary  in Haskell.

int tracer (Vector o, Vector d, double &t, Vector& n) {
.....
}

Parameters t and a vector n are out-parameters. Actually it is necessary to return them through return.
There is a thought simply to transfer them as result of function a tuple.

tracer:: Vector-> Vector-> (Int, Double, Vector)

73

Re: Haskell: questions

mayton wrote:

As it is implemented? To me are necessary round . It will be important for testing.

As an ordinary function.
It is possible both with  and without. Depending on a context.

74

Re: Haskell: questions

mayton wrote:

There is a thought simply to transfer them as result of function a tuple.

Quite logical decision.

75

Re: Haskell: questions

Tried to define new type with Show. It  any. How to understand error status code?
Really I should bypass over 9000 syntactic forms to select one is unique
The correct?

newtype Vector = Double Double Double deriving (Show, Eq)
Prelude>:l card.hs
[1 of 1] Compiling Main (card.hs, interpreted)
card.hs:27:18: error:
* The constructor of a newtype must have exactly one field
but ` Double ' has two
* In the definition of data constructor ` Double'
In the newtype declaration for ` Vector'
|
27 | newtype Vector = Double Double Double deriving (Show, Eq)
| ^^^^^^^^^^^^^^^^^^^^