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.  does this function exist already? (a -> b -> c) -> (d -> b)
      -> (( a -> d -> c )) (Silent Leaf)
   2. Re:  does this function exist already? (a -> b -> c) -> (d ->
      b) -> (( a -> d -> c )) (Sumit Sahrawat, Maths & Computing, IIT (BHU))
   3. Re:  does this function exist already? (a -> b -> c) -> (d ->
      b) -> (( a -> d -> c )) (Silent Leaf)
   4. Re:  does this function exist already? (a -> b -> c) -> (d ->
      b) -> (( a -> d -> c )) (Silent Leaf)


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

Message: 1
Date: Fri, 8 Apr 2016 23:42:37 +0200
From: Silent Leaf <silent.le...@gmail.com>
To: beginners@haskell.org
Subject: [Haskell-beginners] does this function exist already? (a -> b
        -> c) -> (d -> b) -> (( a -> d -> c ))
Message-ID:
        <cagfccjnx9qkwksmkrx3dq8dqz5eswm30l+a-d6gtryne1wf...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

[Note, total newbie to mailing lists in general, and beginner in haskell as
one might have surmised ^^ hopefully I'm doing the right thing here with
this mail...]

All, or virtually all in the title, but I'll develop. I wrote some useful
function (which i rather awkwardly called "point2", for "(.) operator
applied at the level of the second argument of the first function"). Here
is its def:

point2 :: (a -> b -> c) -> (d -> b) -> (( a -> d -> c ))
-- the double parentheses, totally optional and syntactically pointless,
are just there to imply that the function is seen by we users as
'outputting' another function, even though said outputted function can be
applied right away, of course, outputting then possibly c, or (d -> c) if
partial application.
-- I named the variables in the pattern like their respective types, for
'clarity'
point2 f g a d = f a (g d)
-- i originally wrote it in point free style using flip, from Data.Function
(well, my own rebuilt wheel actually); so, alternate definition using flip
== (\f y x -> f x y)
point2 f g = flip (flip f . g)
-- proof by decomposition: (or is it "composition", as we don't actually
decompose?)
-- f :: a -> b -> c
-- flip f :: b -> a -> c
-- flip f . g :: d -> a -> c
-- flip (flip f . g) == f `point2` g :: a -> d -> c

anyways, it's pretty useful if you wanna combine f and g but g is meant to
output the *second* argument of f, not the first, that is:
(f a) . g == (f `point2` g) a
in the first expression, "a" must necessarily be known and given to combine
f and g in point-free style, whereas in the second one, "a" can be omitted,
hence then we could write "foo = f `point2` g", which is way closer to the
point-free style, way simpler to understand too in my opinion once you got
the picture.

If you got all I said above, my question is then to know if this point2
function already exists officially, coz I don't really wanna reinvent the
wheel, plus I wonder how they called it ^^ I'm not really satisfied of
"point2" as variable name. I'd love (.2) but it's not compatible with
Haskell. ^^

Also, same question for the following function (does it already exists?),
again a sibling of (.), here, the purpose being to write h(a, b) = f (g(a,
b))  in point-free style:
after2 :: (c -> d) -> (a -> b -> c) -> (( a -> b -> d ))
after2 f g a b = f (g a b)
-- its name implies an infix use, for example: h = f `after2` g
basically, if you know about Data.Function(on), it's a bit (one of) its
opposite: `on` applies g to both arguments of f independently, before
giving both results to the 2-ary function f, ie
(f `on` g) a b == f (g a) (g b)

I'm not entirely sure, but I think we could write:
f `after2` g == curry (f . (uncurry g))
-- since:
uncurry g :: (a,b) -> c
f . uncurry g :: (a,b) -> d
curry (f . uncurry g) :: a -> b -> d

un/curry functions' defs, if needed:
curry :: ((a,b) -> c) -> a -> b -> c
curry f a b = f (a,b)
-- curry f :: a -> b -> c when f :: (a,b) -> c
uncurry :: (a -> b -> c) -> (a,b) -> c
uncurry g (a,b) = g a b
-- uncurry g :: (a,b) -> c when g :: a -> b -> c
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20160408/5386cdca/attachment-0001.html>

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

Message: 2
Date: Sat, 9 Apr 2016 03:18:09 +0530
From: "Sumit Sahrawat, Maths & Computing, IIT (BHU)"
        <sumit.sahrawat.ap...@iitbhu.ac.in>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <beginners@haskell.org>
Subject: Re: [Haskell-beginners] does this function exist already? (a
        -> b -> c) -> (d -> b) -> (( a -> d -> c ))
Message-ID:
        <CAJbEW8Pcc=f9cskzhvnndmemddpozunfbw_52aqussgl4q-...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Hi, you might wanna take a look at Hoogle and Hayoo. They allow you to
search for functions using names or type signatures.

Hope this helps.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20160409/6a44d544/attachment-0001.html>

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

Message: 3
Date: Sat, 9 Apr 2016 00:04:52 +0200
From: Silent Leaf <silent.le...@gmail.com>
To: "sumit.sahrawat.ap...@iitbhu.ac.in"
        <sumit.sahrawat.ap...@iitbhu.ac.in>,  The Haskell-Beginners Mailing
        List - Discussion of primarily beginner-level topics related to
        Haskell <beginners@haskell.org>
Subject: Re: [Haskell-beginners] does this function exist already? (a
        -> b -> c) -> (d -> b) -> (( a -> d -> c ))
Message-ID:
        <cagfccjn55+8ety6cudluhwyyja7oodtf1ftt+hhp3tqrqpa...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Hoogle was my first stop, didn't find anything, but Hayoo is much more
complete, found all of it!

"My" after2 has no less than 4 different synonymous: (oo), (.:), (comp2),
(dot). and i checked my curry theory as correct.
I found "point2" too right beside (.:), dubbed (.^).
Those two inside a "pointlessfun" package (?) ^^

Hence, thanks, I found what I needed. :)
Do I need to close or mark the discussion as "solved" or something, somehow?

Le vendredi 8 avril 2016, Sumit Sahrawat, Maths & Computing, IIT (BHU) <
sumit.sahrawat.ap...@iitbhu.ac.in> a ?crit :
> Hi, you might wanna take a look at Hoogle and Hayoo. They allow you to
search for functions using names or type signatures.
>
> Hope this helps.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20160409/99325814/attachment-0001.html>

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

Message: 4
Date: Sat, 9 Apr 2016 00:48:38 +0200
From: Silent Leaf <silent.le...@gmail.com>
To: "sumit.sahrawat.ap...@iitbhu.ac.in"
        <sumit.sahrawat.ap...@iitbhu.ac.in>,  The Haskell-Beginners Mailing
        List - Discussion of primarily beginner-level topics related to
        Haskell <beginners@haskell.org>
Subject: Re: [Haskell-beginners] does this function exist already? (a
        -> b -> c) -> (d -> b) -> (( a -> d -> c ))
Message-ID:
        <cagfccjnq7a4zqfjn0ltqxcjnqf2eqwuofi4sgkvmzxk_exs...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Ok thanks! By the way, I didn't know the formatting (especially,
code/noncode distinction) was erased in the process of archiving my mail,
sorry for the unfortunate, probable, unreadability of my first message.

Actually, I have another question that somewhat is in continuity, as
regards one definition I found for after2 (with another name of course,
though here it's irrelevant):
> after2 :: (c -> d) -> (a -> b -> c) -> a -> b -> d
> after2 f = ((f .) .)

I checked by recursion, mostly to actually understand why/how it works, and
it's pretty cool, if I may.
> f :: c -> d
> (f .) :: (b -> c) -> (b -> d)
> ((f .) .) :: (a -> (b -> c)) -> (a -> (b -> d)) == (a -> b -> c) -> (a ->
b -> d)

Or seen from another angle:
> f (g a b) :: d
> (f .) (g a) :: b -> d
> ((f .) .) g :: (a -> b -> d)

>From there, I had the idea and desire to check if we could build a
generalization of this operation, in this fashion:
> testOp :: Int -> (c -> d) -> ? --Here i'm stuck since it looks like it
should basically be a sort of recursive type of function, or something??
> testOp 0 f = f
> testOp n f = ((testOp (n-1) f) .)

hence with this definition, (testOp 2) == after2 and (testOp 1) == (.)
Is this "testOp" writable? If so, what would it need?
Thanks in advance! :)

2016-04-09 0:09 GMT+02:00 Sumit Sahrawat, Maths & Computing, IIT (BHU) <
sumit.sahrawat.ap...@iitbhu.ac.in>:

> No need to do anything. On the list you can only send and receive emails.
>

2016-04-09 0:04 GMT+02:00 Silent Leaf <silent.le...@gmail.com>:

> Hoogle was my first stop, didn't find anything, but Hayoo is much more
> complete, found all of it!
>
> "My" after2 has no less than 4 different synonymous: (oo), (.:), (comp2),
> (dot). and i checked my curry theory as correct.
> I found "point2" too right beside (.:), dubbed (.^).
> Those two inside a "pointlessfun" package (?) ^^
>
> Hence, thanks, I found what I needed. :)
> Do I need to close or mark the discussion as "solved" or something,
> somehow?
>
>
> Le vendredi 8 avril 2016, Sumit Sahrawat, Maths & Computing, IIT (BHU) <
> sumit.sahrawat.ap...@iitbhu.ac.in> a ?crit :
> > Hi, you might wanna take a look at Hoogle and Hayoo. They allow you to
> search for functions using names or type signatures.
> >
> > Hope this helps.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20160409/d0922b80/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 94, Issue 4
****************************************

Reply via email to