logo
首页技术栈工具库讨论
threepenny-gui-flexbox
threepenny-gui-flexbox
[Index] For package maintainers and hackage trustees Flexbox layouts for Threepenny-gui. This library was written following the wonderful A Complete Guide to Flexbox and using the equally wonderful Clay library as a CSS domain specific language. Ultimately we just want to set Flexbox properties on elements, both parent and child elements. In CSS these properties would look like flex-grow: 1;. We collect Flexbox properties that apply to the parent element, things like flex-direction, in a ParentProps data type. Flexbox properties that apply to child elements, things like flex-grow, are collected in a ChildProps data type. If you want ChildProps with flex-grow: 1; you can just do: You can define multiple properties using record syntax: Note that in the examples above we used flexGrow and order to return ChildProps with given values set but also with default values set for all other Flexbox properties, unless record syntax is used to override a property. Some properties like flexGrow simply take an Int but others take a value from the Clay library. Here's an example for ParentProps: If you just want ParentProps or ChildProps with default values: Once you have your properties defined you'll want to apply them to elements. For this you can use setFlex which can be used with Threepenny's reverse function application operator #: You can also convert ParentProps or ChildProps to a [(String, String)] which is how Threepenny expects CSS. This can be done using toStyle which is defined in the typeclass ToStyle: We provide a utility function flex (and a few variants thereof) which takes both parent and child elements and their respective ParentProps and ChildProps, applies the properties to the respective elements and then returns the parent element with children attached. Here is a full example, which produces the above image of three orange text boxes in ratio 1:2:1. First done without flex_p and then with flex_p. flex_p is a variant of flex which applies default Flexbox properties to the parent element.
zoom-cache
zoom-cache
zoom-cache is a fairly simple data file format for storing and summarizing streams of time-series data. The purpose of this format is to make it easy to quickly generate plots; zooming refers to being able to render a window of data, and being able to quickly change the bounds of the window: to move around and to zoom in and out. This library provides a monadic writing and an iteratee reading interface for zoom-cache files. To build GUI applications, see the scope package: http://hackage.haskell.org/package/scope What's neat about the zoom-cache format and library? Glad you asked! Data can be stored at variable or constant rates. For variable rate data, a timestamp is explicitly written into the file for every value, which is useful for recording events that occur at unpredictable times. Constant rate is useful for regularly sampled data, like most digital audio and video recordings. While writing a file, summary blocks (such as minimum, maximum, mean and RMS values) are written out every n samples. The summary blocks are hierarchical, such that after two have been written, a new one containing a merged summary of those is written. After two of those Level 1 summary blocks have been written, a new Level 2 summary block combining those is written, and so on. You can write your own zoom-cache codecs for custom data types, or to implement custom summary functions. In order to do so you provide a Summary data type, functions for encoding and decoding raw data values and summaries, and a function for merging Summary blocks. For details, see Data.ZoomCache.Codec. Writing of raw data blocks is optional, under control of the application. If you already have the raw data stored in an easily accessible format, your zoom-cache files may just contain the summary data. On the other hand, if your input data is the result of expensive calculations you may want to store it along with the summary data so that plots of any level of detail can be rendered from a single file. When developing applications that read or write zoom-cache files, it should be sufficient to import only the module Data.ZoomCache.
stackage2nix
stackage2nix
For package maintainers and hackage trustees stackage2nix converts a Stack file into a Nix Haskell packages set. Command creates file default.nix which overrides haskell.packages.stackage packages set. You should use typeable/nixpkgs-stackage overlay that adds LTS Stackage packages to Nixpkgs. Build package with overlay installed: If you don't want to use Stackage overlay, stackage2nix can generate required packages with --with-stackage-closure flag. To generate Stackage packages, you should supply additional --all-cabal-hashes and --lts-haskell flags that points to commercialhaskell/all-cabal-hashes checked out to hackage branch and fpco/lts-haskell respectively. You can use stackage2nix wrapper from nix directory that adds required flags: This command will produce packages.nix and configuration-packages.nix Stackage packages and its override in default.nix --with-stackage parameter generates full Stackage LTS in addition to the targets from stack.yaml You can also generate only Stackage packages set from the resolver: This command will produce Stackage packages packages.nix, packages config configuration-packages.nix and a Haskell packages set default.nix. Complex projects may require some extra customization. Snippet override.nix below shows a minimal example of how to apply additional overrides on top of Haskell packages set produced by stackage2nix. For more complex overrides and detailed information on how to work with Haskell packages in Nix, see Nixpkgs manual User’s Guide to the Haskell Infrastructure Integration tests that build stackage2nix form different yaml configs: