Difference between revisions of "Partial signatures"

From HaskellWiki
Jump to navigation Jump to search
(Deleting page that hasn't been edited for over 10 years)
m (Reverted edits by Tomjaguarpaw (talk) to last revision by Lemming)
 
Line 1: Line 1:
  +
"The regular (full) [[type signature|signature]] of a function specifies the type of the
  +
function and -- if the type includes constrained type variables --
  +
enumerates all of the typeclass constraints. The list of the constraints
  +
may be quite large. Partial signatures help when:
  +
*we wish to add an extra constraint to the type of the function but we do not wish to explicitly write the type of the function and enumerate all of the typeclass constraints,
  +
*we wish to specify the type of the function and perhaps some of the constraints -- and let the typechecker figure out the rest of them.
  +
  +
Contrary to a popular belief, both of the above are easily possible, in Haskell98."
  +
  +
[http://okmij.org/ftp/Haskell/types.html#partial-sigs Partial signatures]
  +
  +
[[Category:Idioms]]

Latest revision as of 15:19, 6 February 2021

"The regular (full) signature of a function specifies the type of the function and -- if the type includes constrained type variables -- enumerates all of the typeclass constraints. The list of the constraints may be quite large. Partial signatures help when:

  • we wish to add an extra constraint to the type of the function but we do not wish to explicitly write the type of the function and enumerate all of the typeclass constraints,
  • we wish to specify the type of the function and perhaps some of the constraints -- and let the typechecker figure out the rest of them.

Contrary to a popular belief, both of the above are easily possible, in Haskell98."

Partial signatures