pointfree.io | web site for converting haskell code | Functional Programming library
kandi X-RAY | pointfree.io Summary
kandi X-RAY | pointfree.io Summary
This is just a basic web service built in scotty that converts haskell code into pointfree haskell code. I built it as a way of learning more about building services in Haskell. It's really just a toy. Don't take it too seriously.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of pointfree.io
pointfree.io Key Features
pointfree.io Examples and Code Snippets
Community Discussions
Trending Discussions on pointfree.io
QUESTION
Is (sequence .) . flip fmap
the same as forM
? I ask here because pointfree.io seems not to say the same...
ANSWER
Answered 2021-Feb-14 at 17:25Yes, it is:
QUESTION
One related question is this, but some of the answer say that almost anything can be made point free, so what is wrong with this function?
...ANSWER
Answered 2020-Jul-09 at 20:09Well, a data type isn't a function. As long as your function isn't unwrapping any data values (i.e. it's just shuffling them between functions/constructors), you can write it point free, but there's simply no syntax for point free matching. However, you only ever need one non-point-free function per data type: the fold. In Haskell, data types are pretty much defined by their folds. Taking the folds of the relevant data types as primitives, you can rewrite any function point free. Note that there are actually several possible "folds". For [a]
, the recursive one (which comes from the Church/Böhm-Berarducci encoding) is foldr :: (a -> b -> b) -> b -> [a] -> b
. Another possible fold is the "case
-but-it's-a-function" one, (a -> [a] -> b) -> b -> [a] -> b
, which comes from the Scott encoding (recursion can then be recovered with fix
, which is another "pointful pointfree primitive"), but, as @SilvioMayolo notes, there isn't such a function in the standard library. Either would do, but we don't have the latter predefined so let's just use foldr
.
QUESTION
I was recently writing a solution for the ISBN Verifier exercise at Exercism, and when I ran this function through pointfree.io:
...ANSWER
Answered 2018-Mar-31 at 00:10The fact is that Control.Monad
is much older than Control.Applicative
.
Monads were already in Haskell 98, while the paper about applicative functors was introduced in 2007. The package in Hackage exists since 2005.
Due to historical accident, applicative functors were not implemented as a superclass of Monad, but as a separate type class. It turned out that, in practice, there was very little demand for such a separation, so in 2014, it was proposed to make Applicative retroactively a superclass of Monad.
So liftM{N}
are still valid.
QUESTION
Consider the following Haskell code.
...ANSWER
Answered 2017-Oct-03 at 23:47You can’t do it without a little bit of boilerplate, but lens
can generate that boilerplate for you, so that’s probably as close as you are going to get.
Using makePrisms
from Control.Lens.TH
will generate an Iso
, which is, essentially, a first-class pattern-match on a single-constructor datatype. Conveniently, Iso
s are bidirectional, so you can view
them (to get values out, like pattern-matching) and review
them (to put a value back in, like using the constructor normally).
Using makePrisms
and view
, it’s possible to write getSeq
in a pointfree way:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install pointfree.io
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page