function-builder 0.1.0.0 → 0.1.0.1
raw patch · 4 files changed
+56/−53 lines, 4 filesdep +taggeddep ~base
Dependencies added: tagged
Dependency ranges changed: base
Files
- .travis.yml +29/−19
- README.md +20/−9
- function-builder.cabal +2/−2
- src/Data/FunctionBuilder.hs +5/−23
.travis.yml view
@@ -1,30 +1,40 @@-language: c+# This is the simple Travis configuration, which is intended for use+# on applications which do not require cross-platform and+# multiple-GHC-version support. For more information and other+# options, see:+#+# https://docs.haskellstack.org/en/stable/travis_ci/+#+# Copy these contents into the root directory of your Github project in a file+# named .travis.yml -sudo: false+# Choose a build environment+dist: xenial +# Do not choose a language; we provide our own build tools.+language: generic++# Caching so the next build will be fast too.+cache:+ directories:+ - $HOME/.stack++# Ensure necessary system libraries are present addons: apt:- sources:- - hvr-ghc packages:- - ghc-8.6.3+ - libgmp-dev before_install:- - mkdir -p ~/.local/bin- - travis_retry curl -L https://www.stackage.org/stack/linux-x86_64 | tar xz --wildcards --strip-components=1 -C ~/.local/bin '*/stack'- - export PATH=~/.local/bin:/opt/ghc/$GHCVER/bin:$PATH- - chmod a+x ~/.local/bin/stack+# Download and unpack the stack executable+- mkdir -p ~/.local/bin+- export PATH=$HOME/.local/bin:$PATH+- travis_retry curl -L https://get.haskellstack.org/stable/linux-x86_64.tar.gz | tar xz --wildcards --strip-components=1 -C ~/.local/bin '*/stack' install:- - stack --no-terminal --skip-ghc-check setup+# Build dependencies+- stack --no-terminal --install-ghc test --only-dependencies script:- - stack --no-terminal --skip-ghc-check build- - stack --no-terminal --skip-ghc-check haddock--cache:- directories:- - ~/.stack- - ~/.local- - ~/.stack-work-cache- apt: true+# Build the package, its tests, and its docs and run the tests+- stack --no-terminal test --haddock --no-haddock-deps
README.md view
@@ -10,10 +10,6 @@ with building blocks to create functions that compose a monoidal structure from their parameters in a type safe way. Think of `printf`. -Imagine a library that let`s user create nicely formatted strings, with the ability to-compose strings into larger strings and to allow the rendering of-all sorts of values, for example `Double`s, `Bool`s, or lists to strings.- **This library** allows the author of such a library to easily add the building blocks, allowing users to build **poly variadic functions**, i.e. with parameters depending on the order and composition of these building blocks.@@ -25,18 +21,33 @@ `FunctionBuilder`s can also be composed via standard type classes. -This module gives you ready-made like `Functor`, `Applicative`, `Semigroup`, `Monoid` or Category` instances;--The basic building blocks are `toFunction`, `immediate` and `addParameter`.+This module gives you ready-made `Functor`, `Applicative`, `Semigroup`, `Monoid` and Category` instances; -For example, you could use this library to build a string formatting+For example, this library could be used to build a string formatting library, that allows users to compose arbitrary, _printf-style_ render **functions** from reusable building blocks, such that they can be re-combined in order to make get functions, that can be applied to parameters that fill place holders, like e.g.: + module AStringFormatter where++ str :: String -> FunctionBuilder String next next+ str = immediate++ renderInt :: FunctionBuiler String next (Int -> next)+ renderInt = addParameter show++ renderFloat :: FunctionBuiler String next (Float -> next)+ renderFloat = ...++Then the user of YourStringFormatter can write:++ module CpuTempFormatter where++ import AStringFormatter+ renderCpuTemp :: Int -> Float -> String renderCpuTemp =- toFunction (render "CPU " . renderInt . render " Temperature: " . renderFloat)+ toFunction (str "CPU " . renderInt . str " Temperature: " . renderFloat) ## Similar Libraries
function-builder.cabal view
@@ -1,5 +1,5 @@ name: function-builder-version: 0.1.0.0+version: 0.1.0.1 synopsis: Create poly variadic functions for monoidal results description: Please see README.md homepage: https://github.com/sheyll/function-builder#readme@@ -19,7 +19,7 @@ library hs-source-dirs: src exposed-modules: Data.FunctionBuilder- build-depends: base >= 4.11 && < 5+ build-depends: base >= 4.11 && < 5, tagged default-language: Haskell2010 default-extensions: BangPatterns , ConstraintKinds
src/Data/FunctionBuilder.hs view
@@ -1,16 +1,5 @@ -- | This library allows you to build function builder libraries. ----- This library is made to be useful especially for library authors, who want to provide--- building blocks for users to build functions of varying parameters in a type safe way.------ Imagine a library that let's user create nicely formatted strings, with the ability to--- compose strings into larger strings and to allow the rendering of--- all sorts of values, for example 'Double's, 'Bool's, or lists to strings.------ __This library__ allows the author of such a library to easily add the--- building blocks, allowing users to build __poly variadic functions__, i.e. with parameters--- depending on the order and composition of these building blocks.--- -- Several 'FunctionBuilder' values sharing a common monoidal output type can be composed -- to a big 'FunctionBuilder' value, in order to build an __output function__ that -- has a flexible number and types of parameters depending, on the individual@@ -18,20 +7,13 @@ -- -- 'FunctionBuilder's can also be composed via standard type classes. ----- This module gives you ready-made like 'Functor', 'Applicative', 'Semigroup', 'Monoid' or 'Category' instances;------ The basic building blocks are 'toFunction', 'immediate' and 'addParameter'.+-- This module provides 'Functor', 'Applicative', 'Monad', 'Semigroup', 'Monoid' and+-- 'Category' instances; ----- For example, you could use this library to build a string formatting--- library, that allows users to compose arbitrary, /printf-style/ render __/functions/__--- from reusable building blocks, such that they can be re-combined in order to make--- get functions, that can be applied to parameters that fill place holders, like e.g.:+-- The basic building blocks when generating a poly variadic function+-- are 'immediate' and 'addParameter'. ----- @--- renderCpuTemp :: Int -> Float -> String--- renderCpuTemp =--- toFunction (render "CPU " . renderInt . render " Temperature: " . renderFloat)--- @+-- The output function is obtained from a 'FunctionBuilder' by __toFunction__. -- module Data.FunctionBuilder where