Skip to content

Instantly share code, notes, and snippets.

@FranklinChen
Created October 6, 2014 03:23
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save FranklinChen/e6ba90b0e3ec90eb121a to your computer and use it in GitHub Desktop.
Example of point-free style
import Control.Category ((>>>))
data Option = Option { name :: String }
-- Point-free style. Is this readable?
--
-- An Option matches a String if: we get the name of the Option and then prepend "--" to it, test whether that is equal
-- to the given String.
matches :: Option -> String -> Bool
matches = name >>> ("--" ++) >>> (==)
-- Example
helpOption :: Option
helpOption = Option "help"
-- Example usage
example :: Bool
example = helpOption `matches` "--help"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment