Send Beginners mailing list submissions to
        beginners@haskell.org

To subscribe or unsubscribe via the World Wide Web, visit
        http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        beginners-requ...@haskell.org

You can reach the person managing the list at
        beginners-ow...@haskell.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1.  How to write console apps? Can't find any        library,
      tutorial... at all (Silent Leaf)
   2. Re:  How to write console apps? Can't find any library,
      tutorial... at all (Alex Belanger)
   3. Re:  Code golf (Tilmann)
   4. Re:  How to write console apps? Can't find any library,
      tutorial... at all (Francesco Ariis)
   5. Re:  Code golf (Silent Leaf)


----------------------------------------------------------------------

Message: 1
Date: Fri, 20 May 2016 18:36:20 +0200
From: Silent Leaf <silent.le...@gmail.com>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <beginners@haskell.org>
Subject: [Haskell-beginners] How to write console apps? Can't find any
        library, tutorial... at all
Message-ID:
        <CAGFccjM9RKiB8t16aT_BWiPt5HN+d-zc=BCCTVKMU8zQVL=1...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

All in the title!

I'm seeking a way to write a console app that isn't just asking questions
one line after another with putStr and getLine. More something like Vim or
Emacs when they're in the terminal (i don't wanna create a text ed, but
it's the kind of programs i'm seeking to write: which takes up all the
space on the screen, where you can write at many different places, and
keyboard-driven, up to why not mouse- too, if the terminal (and haskell
bindings) allow it.

So, does anyone know any library to do this? Any tutorial, maybe? I'm
seeking for hours, but every time i type stuff like "console application
haskell" in google, it just gives me irrelevant answers --as is the trend
it seems subjectively, of those last months, with our bestest G-friend. :(

thanks a lot in advance for anything!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20160520/23d43189/attachment-0001.html>

------------------------------

Message: 2
Date: Fri, 20 May 2016 12:40:48 -0400
From: Alex Belanger <i.caught....@gmail.com>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <beginners@haskell.org>
Subject: Re: [Haskell-beginners] How to write console apps? Can't find
        any library, tutorial... at all
Message-ID:
        <CADSky2xmAndPTF-GQk9tcrONGRq3tj89zYT3pX6c8Yv4=xf...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Look at the `vty` library which is similar in essence to (n)curses.

It looks you manipulate the terminal's cursor, with different color and
modes.

I think it even has minimal widgets.
On May 20, 2016 12:36 PM, "Silent Leaf" <silent.le...@gmail.com> wrote:

> All in the title!
>
> I'm seeking a way to write a console app that isn't just asking questions
> one line after another with putStr and getLine. More something like Vim or
> Emacs when they're in the terminal (i don't wanna create a text ed, but
> it's the kind of programs i'm seeking to write: which takes up all the
> space on the screen, where you can write at many different places, and
> keyboard-driven, up to why not mouse- too, if the terminal (and haskell
> bindings) allow it.
>
> So, does anyone know any library to do this? Any tutorial, maybe? I'm
> seeking for hours, but every time i type stuff like "console application
> haskell" in google, it just gives me irrelevant answers --as is the trend
> it seems subjectively, of those last months, with our bestest G-friend. :(
>
> thanks a lot in advance for anything!
> _______________________________________________
> Beginners mailing list
> Beginners@haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20160520/ae329306/attachment-0001.html>

------------------------------

Message: 3
Date: Fri, 20 May 2016 19:15:05 +0200
From: Tilmann <t_g...@gmx.de>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <beginners@haskell.org>
Subject: Re: [Haskell-beginners] Code golf
Message-ID: <fd946dcc-f358-0735-1527-3458f8aa9...@gmx.de>
Content-Type: text/plain; charset="utf-8"; Format="flowed"

Thank you for the references. I like the term 'bind2'. I had a look at 
Prelude.Generalized. Wow!

bind2  =  join  .::  liftM2; (.::) = (.) . (.) . (.)

Am 20.05.16 um 04:50 schrieb Silent Leaf:
> The interesting bit is, the following function > \? ma mb -> join 
> (pure ? <*> ma <*> mb) which i like to write as follows using ((&) = 
> flip ($)) [infixl 1] > \? ma mb -> pure ? <*> ma <*> mb & join (but 
> it's just personal taste) is very similar to (=<<), aka (flip (>>=)) 
> except the first argument (here ?) has type (a -> b -> m c) instead of 
> (a -> m b), and of course the lambda above takes an added argument too 
> (mb). Some could call it "bind2" (even if it's the flipped version of 
> (>>=) that is being generalized), and well, some do. For those 
> interested, there are several options are available to import it 
> (along possibly with some of its siblings), from several libraries. 
> (List possibly non exhaustive.) 
> http://hackage.haskell.org/package/prelude-generalize-0.4/docs/Prelude-Generalize.html#v:bind2
>  
> http://hackage.haskell.org/package/SimpleH-1.2/docs/Algebra-Monad.html#v:bind2
>  
> http://hackage.haskell.org/package/definitive-base-2.3/docs/Algebra-Monad-Base.html#v:bind2
>  
> your problem become btw then: > doIt = bind2 update a b
>
> _______________________________________________
> Beginners mailing list
> Beginners@haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20160520/b15ede49/attachment-0001.html>

------------------------------

Message: 4
Date: Fri, 20 May 2016 19:11:43 +0200
From: Francesco Ariis <fa...@ariis.it>
To: beginners@haskell.org
Subject: Re: [Haskell-beginners] How to write console apps? Can't find
        any library, tutorial... at all
Message-ID: <20160520171143.ga29...@casa.casa>
Content-Type: text/plain; charset=us-ascii

On Fri, May 20, 2016 at 06:36:20PM +0200, Silent Leaf wrote:
> All in the title!
> 
> I'm seeking a way to write a console app that isn't just asking questions
> one line after another with putStr and getLine. More something like Vim or
> Emacs when they're in the terminal (i don't wanna create a text ed, but
> it's the kind of programs i'm seeking to write: which takes up all the
> space on the screen, where you can write at many different places, and
> keyboard-driven, up to why not mouse- too, if the terminal (and haskell
> bindings) allow it.

I suppose ncurses [1] would do, or other curses packages!

[1] https://hackage.haskell.org/package/ncurses


------------------------------

Message: 5
Date: Fri, 20 May 2016 21:09:32 +0200
From: Silent Leaf <silent.le...@gmail.com>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <beginners@haskell.org>
Subject: Re: [Haskell-beginners] Code golf
Message-ID:
        <cagfccjnhk0jr4d9yv1hwbt-+sqdndukgyhf+jmpc4jbomzd...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

yes, this definition of bind2 looks kinda "frightening". if fact it's
simpler than it looks: (.::) merely takes two functions, then the three
next parameters applied to the result of this special composition, will be
applied to the second parameter, before the result be given as input for
the first parameter.

it must be compared with (.), which only allows the second function to get
one single parameter, before the result of this application becomes the
first parameter of the first function of the composition, after which any
supplementary parameter applied to the whole will go to the left function:
> (left . right) a b c d e = left (right a) b c d e
By comparison:
> (left .:: right) a b c d e = left (right a b c) d e

in the first equation above, defining (.), let's say `right` has type a ->
b -> c -> d. then `left` will get as first parameter, a partial function,
aka (right a :: b -> c -> d). but, in the second equation, `right` gets all
of its three parameters (a, b and c), returning a value of type `d`, before
`left` gets said result-value as its own first parameter, and then possibly
get other parameters of its own (here, d and e).

thus with bind2:
bind2 f ma mb = (join .:: liftM2) f ma mb = join (liftM2 f ma mb)

Now, in my opinion, the point-free style definition of (.::), aka
composition of (.) with itself, three time, is way overkill (better use a
lambda to clarify the purpose), but maybe is it better in terms of
performance or whatever. it's certainly shorter, and when you know what it
entails, it's simple, but it can easily frighten anyone else.

if one wants to understand this (subjectively overkill) point-free
definition,
(.::) = (.) . (.) .(.)
better do the opposite action that leads to point free style, aka, better
name and reveal variables. To make it more readable, i'll define first:
dot = (.)
f .:: g = (dot . dot . dot) f g
       = (dot . dot) (dot f) g
       = (dot . dot) (f .) g
       = dot (dot (f .)) g
       = dot ((f .).) g
       = ((f . ) .) . g
this expansion (or whatever you call it), solely uses the basic rule (a .
b) c = a (b c), or, with "pollution" around, (w . a . b) c d = (w . a) (b
c) d = w (a (b c)) d.
in the case of b = dot = (.), and c = f, you get (dot f) = (f .), aka,
partially applied composition of f with "something" (the implicit
parameter).

now, this weird
((f .) .) . g = f .:: g
is as we said, directly equivalent to
\f g a b c -> f (g a b c)
indeed:
>   f .:: g
> = (((f .) .) . g) a b c -- structure equivalent to (x.g) a b c
> = ((f .) .) (g a) b c   -- to (w .) (g a) b c   [with x = (w.) and w = (f
.)]
> = ((f .) . (g a)) b c   -- to (w . (g a)) b c = (w . v) a b
> = (f .) ((g a) b) c     -- to (f.) (v b) c = (f.) (g a b) c -- as v = g a
> = (f  . (g a b)) c      -- to (f . k) c   [with k = (g a b)]
> = f ((g a b) c) = f (g a b c)  -- to f (k c)
which is what we thought (.::) was.
simply put, every dot in
> (((f .) .)  .  g)  a  b  c
will allow, first, with the dot to the right, that g, as right side of a
function composition, take the first argument that follows (here a),
becoming a binary partial app (g a);
> ((f .) . (g a))  b  c -- first dot was used
then, this binary partial app (g a) being now the right side of another
composition (second, aka middle dot), will get a new argument of its own
(b), making it an unary partial app (g a b)
> (f . (g a b))  c -- second dot was used
and the last dot the the extreme left, at last, allows (g a b) to take its
last argument before finally the result be inputed to the function f:
> f (g a b c)

I hope it clarifies everything for anyone interested and that didn't know
it already, of course.



Le vendredi 20 mai 2016, Tilmann <t_g...@gmx.de> a ?crit :
> Thank you for the references. I like the term 'bind2'. I had a look at
Prelude.Generalized. Wow!
>
> bind2 = join .:: liftM2;
> (.::) = (.) . (.) . (.)
>
> Am 20.05.16 um 04:50 schrieb Silent Leaf:
>
> The interesting bit is, the following function > \? ma mb -> join (pure ?
<*> ma <*> mb) which i like to write as follows using ((&) = flip ($))
[infixl 1] > \? ma mb -> pure ? <*> ma <*> mb & join (but it's just
personal taste) is very similar to (=<<), aka (flip (>>=)) except the first
argument (here ?) has type (a -> b -> m c) instead of (a -> m b), and of
course the lambda above takes an added argument too (mb). Some could call
it "bind2" (even if it's the flipped version of (>>=) that is being
generalized), and well, some do. For those interested, there are several
options are available to import it (along possibly with some of its
siblings), from several libraries. (List possibly non exhaustive.)
http://hackage.haskell.org/package/prelude-generalize-0.4/docs/Prelude-Generalize.html#v:bind2
http://hackage.haskell.org/package/SimpleH-1.2/docs/Algebra-Monad.html#v:bind2
http://hackage.haskell.org/package/definitive-base-2.3/docs/Algebra-Monad-Base.html#v:bind2
your problem become btw then: > doIt = bind2 update a b
>
> _______________________________________________
> Beginners mailing list
> Beginners@haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20160520/8fc29cd9/attachment.html>

------------------------------

Subject: Digest Footer

_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners


------------------------------

End of Beginners Digest, Vol 95, Issue 26
*****************************************

Reply via email to