Questions tagged [pointfree]

The pointfree (also called pointless) style of defining a function is to express it directly in terms of existing functions, without mentioning the arguments of the function being defined. Function composition and partial application are often used.

The pointfree (also called pointless) style of defining a function is to express it directly in terms of existing functions (regarded as combinators), without mentioning the arguments of the function being defined. Function composition and partial application are often used.

See also .

292 questions
8
votes
5 answers

What is a general scheme for writing a function in pointfree style?

I am working through the 20 Intermediate Haskell Exercises at the moment, which is quite a fun exercise. It involves implementing various instances of the typeclasses Functor and Monad (and functions that takes Functors and Monads as arguments) but…
Chris Taylor
  • 46,912
  • 15
  • 110
  • 154
8
votes
3 answers

Function application: Why is $ used here?

A while ago, I asked a question about $, and got useful answers -- in fact, I thought I understood how to use it. It seems I was wrong :( This example shows up in a tutorial: instance Monad [] where xs >>= f = concat . map f $ xs I can't for the…
J Cooper
  • 16,891
  • 12
  • 65
  • 110
8
votes
3 answers

Add action without changing result to refactor do-notation

I want to sequentially compose two monad actions in Haskell, discarding any value produced by the second, and passing the argument to both actions. Currently I'm using a do-block like this: ask = do result <- getLine putStrLn result return…
amoebe
  • 4,857
  • 5
  • 37
  • 42
8
votes
2 answers

Is there a way to make h (f x) (g x) point-free in Haskell?

I want something like J's fork feature, I guess. Is there any way to do this?
8
votes
2 answers

is this a spot for functional lenses in javascript?

Playing around with point-free style javascript for fun. Say I am coding the video game Diablo, and I am modeling enemies using complex nested types like this but deeper and more complicated: { name: "badguy1", stats: { health: 10: strength: 42 },…
Dustin Getz
  • 21,282
  • 15
  • 82
  • 131
8
votes
2 answers

Haskell: Why is ((.).(.)) f g equal to f . g x?

Could you please explain the meaning of the expression ((.).(.))? As far as I know (.) has the type (b -> c) -> (a -> b) -> a -> c.
8
votes
3 answers

Pointfree (or library) function for applying two functions to single input

I keep reusing lambda expressions such as \x -> (f x, g x) where I apply the same input to two functions and encapsulate the result in a pair. I can write a function capturing this combine :: (a -> b) -> (a -> c) -> a -> (b,c) combine f g x = (f x,…
bshourd
  • 83
  • 3
8
votes
2 answers

Point free notation, recursion, and pattern matching

So I keep hearing a lot about point free programming and I decided to do a little experiment to test my grasp of it. This involved taking a pointed function to calculate the factorial of a number and converting it to a point-free form. I managed to…
Dwilson
  • 1,239
  • 9
  • 18
7
votes
2 answers

How to enforce type when using point free notation

Hello how can you enforce GHC type for functions such as Data.Text.read or the =~ operator from Text.Regex.Posix when composing methods? example: a=["1.22","3.33","5.55"] Without point free: b= map (\x-> read x ::Double) a How to enforce a type for…
Bercovici Adrian
  • 8,794
  • 17
  • 73
  • 152
7
votes
3 answers

How to use pointfree style in JavaScript without losing readability?

When I tried to write JavaScript in pointfree style, I found that if you forced every function in this style, you sometimes lost its readabilty. For example: import R from 'ramda' const ceil = Math.ceil const pagination = { total: 101, …
Jerry
  • 909
  • 7
  • 24
7
votes
2 answers

Point free debugging

So we're using the very nice ramda library at work, which is great because we're able to use a largely point-free style of code. The problem with this is that there are far fewer places to look when things go wrong that point to something in our…
jstaab
  • 3,449
  • 1
  • 27
  • 40
7
votes
4 answers

Haskell Function Composition - (a -> b) -> (a -> c) -> (b -> c -> d) -> (a -> d)

I would like to learn how the following would be done in point-free: withinBounds :: [Int] -> Bool withinBounds xs = (all (>= 0) xs) && (all (<= 8) xs) I understand that it is superior to write it this way for readability/sanity's sake, but I'd…
MIJOTHY
  • 73
  • 6
7
votes
2 answers

Fiddling with point-free code?

I have been learning the Factor and J languages to experiment with point-free programming. The basic mechanics of the languages seem clear, but getting a feeling for how to approach algorithm design is a challenge. A particular source of confusion…
7
votes
3 answers

What are the steps for deducing this pointfree code?

I was reviewing some code and came across the following gem, which I'd wager is a copy-paste of pointfree output: (I thought the following would more appropriate than the usual foo/bar for this particular question :P) import Control.Monad…
iceman
  • 2,020
  • 2
  • 17
  • 24
7
votes
1 answer

Can F# be refactored into a pointfree style?

In researching a topic related to programming I came across a pointfree refactoring tool for Haskell in the lambdabot and was wondering if F# can be refactored into a pointfree style? I am not advocating the use of pointfree style, but see it as a…
Guy Coder
  • 24,501
  • 8
  • 71
  • 136