strict-identity: Strict Identity Monad, handy for writing fast code!

[ bsd3, control, library ] [ Propose Tags ] [ Report a vulnerability ]

strict Identity monad for writing strict performant code sanely


[Skip to Readme]

Modules

[Index]

Downloads

Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.1.0.0
Change log changelog.md
Dependencies base (>=4.3 && <5.0) [details]
License BSD-3-Clause
Author Carter Tazio Schonwald
Maintainer carter at wellposed.com
Revised Revision 1 made by CarterSchonwald at 2017-02-15T01:12:11Z
Category Control
Home page https://github.com/cartazio/strict-identity
Source repo head: git clone http://github.com/cartazio/strict-identity.git
Uploaded by CarterSchonwald at 2014-01-12T08:25:22Z
Distributions Arch:0.1.0.0, NixOS:0.1.0.0
Reverse Dependencies 2 direct, 1 indirect [details]
Downloads 1973 total (19 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Successful builds reported [all 1 reports]

Readme for strict-identity-0.1.0.0

[back to package description]

Build Status

#About

strict-identity package is meant to make writing nested strict let expression heavy code a bit more pleasant, for all those High Performance Haskell lib authors out there.

A simple example of the strict identity monad in action (and working wonderfully) is the following bit fiddling code, which generates C competitive assembly on both major GHC backends, -fasm and -fllvm

(>>) = unsafeShiftR
(<<) = unsafeShiftL
outerShuffle64A :: Word -> Word 
outerShuffle64A !x =
    runStrictIdentity $! do
        x <- return $! ((x .&. 0x00000000FFFF0000) << 16 )
            .|. ((x>>16) .&. 0x00000000FFFF0000) .|. (x .&. 0xFFFF00000000FFFF)
        x <-  return $! ((x .&. 0x0000FF000000FF00 ) <<  8 )
            .|. (x >> 8) .&. 0x0000FF000000FF00 .|. (x  .&. 0xFF0000FFFF0000FF)
        x<-  return $! (( x .&. 0x00F000F000F000F0 ) << 4 )
            .|. (x >> 4) .&. 0x00F000F000F000F0 .|. (x .&. 0xF00FF00FF00FF00F )
        x<-   return $!((x .&.  0x0C0C0C0C0C0C0C0C )<< 2 )
            .|. (x >> 2) .&. 0x0C0C0C0C0C0C0C0C .|.( x .&. 0xC3C3C3C3C3C3C3C3)
        x<-   return $! ( (x .&. 0x2222222222222222)  << 1 ) 
            .|. (x>> 1) .&. 0x2222222222222222 .|. (x .&. 0x9999999999999999)
        return x