Thu, 06 Apr 2000 22:23:10 +0200, Ralf Muschall <[EMAIL PROTECTED]> pisze:
> And if I call the label on the stones "integer_from_string"
> and "integer_from_intlist", unflipped (.) does as well.
In OCaml such functions are called int_of_string etc.
--
__("
Frank Atanassow writes:
> Using <- in type signatures has the advantage that the first thing you see in
> a signature is what is produced, rather than what is necessary to produce,
> which is sometimes what you want when you have a set of algebraic functions
> like John Hughes' pretty-printing
Yuichi Tsuchimoto writes:
> > Or look at o's and flippo's types:
> >
> > (.) :: ((a -> b) -> (c -> a)) -> (c -> b)
> > flip (.) :: ((a -> b) -> (b -> c)) -> (a -> c)
> >
> > Surely the second one is much cooler!
>
> Yes, indeed!
>
> Then, the question is why we write
Jon Fairbairn wrote:
>
> > Then, the question is why we write
> > result = function operand1 operand2
> > instead of
> > operand1 operand2 function = result
> >
> > I actually think the latter is cooler. :)
>
> I think there may be cultural influences about word order and/
> or writing dire
> Then, the question is why we write
> result = function operand1 operand2
> instead of
> operand1 operand2 function = result
>
> I actually think the latter is cooler. :)
I think there may be cultural influences about word order and/
or writing direction creeping in here :-)
--
Jón Fairba
> > And if I call the label on the stones "integer_from_string"
> > and "integer_from_intlist", unflipped (.) does as well.
>
> But then the question is which function name is more natural.
> Arjen's choice of names reflects Haskell's syntax for function
> types:
>
> intlist_to_intege
I wrote:
> (.) :: ((a -> b) -> (c -> a)) -> (c -> b)
> flip (.) :: ((a -> b) -> (b -> c)) -> (a -> c)
Hm, let me try that again:
(.) :: (a -> b) -> (c -> a) -> (c -> b)
flip (.) :: (a -> b) -> (b -> c) -> (a -> c)
Cheers,
Ronny Wichers Schreur
Ralf Muschall wrote:
> And if I call the label on the stones "integer_from_string"
> and "integer_from_intlist", unflipped (.) does as well.
But then the question is which function name is more natural.
Arjen's choice of names reflects Haskell's syntax for function
types:
intlist_to_
Ronny Wichers Schreur schrieb:
> If you think of the (types of) functions as domino stones,
> |. makes them fit.
And if I call the label on the stones "integer_from_string"
and "integer_from_intlist", unflipped (.) does as well.
The same applies to the other answers: On could write
f <.< g (whic
Ralf Muschall wrote:
> Where does the habit to use "flip (.)" in many FP people come
> from?
I think it may come partly from category
theorists
Arjan van IJzendoorn wrote the function:
> string_to_integer :: String -> Integer
> string_to_integer = string_to_int_list .| int_list_to_integer
Ralf Muschall answered:
> (|.) = flip (.)
> [..]
> Where does the habit to use "flip (.)" in many FP people
> come from?
If you think of the
> "Hamilton" == Hamilton Richards <[EMAIL PROTECTED]> writes,
about forwards (is it backwards?) composition:
> A composition using this operator, e.g.,
> f >.> g >.> h
> is easily understood as a pipeline in which data flows from left to right.
> Using ordinary composition
At 7:37 PM +0200 4/5/00, Ralf Muschall wrote:
>Where does the habit to use "flip (.)" in many FP people come
>from?
It's useful for composing several functions in pipeline fashion.
Simon Thompson (in his book _Haskell: the Craft of Functional Programming_)
defines a "forward composition" operat
> "Marcin" == Marcin 'Qrczak' Kowalczyk <[EMAIL PROTECTED]> writes:
> I don't know, I use non-flipped (.). But if we wrote function
> application in the "argument + function" order, composition would
> certainly be written backwards as well.
Actually, it makes good sense to thin
Wed, 05 Apr 2000 19:37:06 +0200, Ralf Muschall <[EMAIL PROTECTED]> pisze:
> and the type declaration you gave seems to be the most general
> possible anyway, i.e. it does not carry any information.
It does: documentation.
It happens that in this case "flip (.)" is more clear documentation
for m
Friedrich Dominicus wrote:
> infixl 9 .|
> (.|) :: (a -> b) -> (b -> c) -> a -> c
> g .| f = f . g
(|.) = flip (.)
might be more readable (depending on what one is used to read),
and the type declaration you gave seems to be the most general
possible anyway, i.e. it does not carry any informatio
> "AvI" == Arjan van IJzendoorn <[EMAIL PROTECTED]> writes:
AvI> Hello Friedrich,
AvI> Turning a string into an integer is easy with the Prelude function 'read':
AvI> n :: Integer
AvI> n = read "-34232"
Yes, other have told me. As I mailed back I was just too blind.
AvI> Your
Hello Friedrich,
Turning a string into an integer is easy with the Prelude function 'read':
n :: Integer
n = read "-34232"
Your own function can be made to work for negative numbers by a simple
wrapper:
stringToInteger :: String -> Integer
stringToInteger ('-':rest) = -string_to_integer rest
s
On 5 Apr 2000, Friedrich Dominicus wrote:
> So my question is: Exists such a function or do I have to write it on my own? And
>the other is what would you
> think would be a good Haskell soluton for turing a string to an Integer.
>
Yes of course!
it is called: read
Prelude> read "12334" + 4
I was again playing around with Haskell to learn it a bit better. I do not
found a function to turn a String into an Integer
This is what I come up with:
string_to_int_list :: String -> [Int]
-- filter out all Digits first and then turn it into a list
-- of integers
string_to_int_list = filter (
20 matches
Mail list logo