How can linear types prevent such implementation of "duplicate"?

Viewed 136

I recently read the post on Tweag.IO about Linear Types being an useful tool for expressing arguments used only(exactly) once. They present the following example:

dup :: a ⊸ (a,a)
dup x = (x,x)

Now, maybe I'm misunderstanding the idea, but why couldn't this be circumvented with:

dup' :: a ⊸ (a,a)
dup' x = (y,y)
  where
    y = x

The article specifically mentions arguments. Does that extend to all bindings in the function as well?

1 Answers
Related