Skip to content

Commit

Permalink
Prepare 0.1.3.3 release.
Browse files Browse the repository at this point in the history
Reformatted.
Added workflows.
Updated package metadata.
  • Loading branch information
brianjosephmckeon committed Feb 6, 2024
1 parent 27289e7 commit 3f89cff
Show file tree
Hide file tree
Showing 9 changed files with 181 additions and 87 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@byteverse/l3c
12 changes: 12 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: build
on:
pull_request:
branches:
- "*"

jobs:
call-workflow:
uses: byteverse/.github/.github/workflows/build.yaml@main
secrets: inherit
with:
release: false
12 changes: 12 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: release
on:
push:
tags:
- "*"

jobs:
call-workflow:
uses: byteverse/.github/.github/workflows/build.yaml@main
secrets: inherit
with:
release: true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.vscode/
dist
dist-*
cabal-dev
Expand Down
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Revision history for run-st

## 0.1.3.2 -- 2024-06-28
## 0.1.3.3 -- 2024-02-06

* Update package metadata.

## 0.1.3.2 -- 2023-06-28

* Make type signature of `runUnliftedArrayST` more flexible.

Expand Down
2 changes: 0 additions & 2 deletions Setup.hs

This file was deleted.

51 changes: 51 additions & 0 deletions fourmolu.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Number of spaces per indentation step
indentation: 2

# Max line length for automatic line breaking
column-limit: 200

# Styling of arrows in type signatures (choices: trailing, leading, or leading-args)
function-arrows: trailing

# How to place commas in multi-line lists, records, etc. (choices: leading or trailing)
comma-style: leading

# Styling of import/export lists (choices: leading, trailing, or diff-friendly)
import-export-style: leading

# Whether to full-indent or half-indent 'where' bindings past the preceding body
indent-wheres: false

# Whether to leave a space before an opening record brace
record-brace-space: true

# Number of spaces between top-level declarations
newlines-between-decls: 1

# How to print Haddock comments (choices: single-line, multi-line, or multi-line-compact)
haddock-style: multi-line

# How to print module docstring
haddock-style-module: null

# Styling of let blocks (choices: auto, inline, newline, or mixed)
let-style: auto

# How to align the 'in' keyword with respect to the 'let' keyword (choices: left-align, right-align, or no-space)
in-style: right-align

# Whether to put parentheses around a single constraint (choices: auto, always, or never)
single-constraint-parens: always

# Output Unicode syntax (choices: detect, always, or never)
unicode: never

# Give the programmer more choice on where to insert blank lines
respectful: true

# Fixity information for operators
fixities: []

# Module reexports Fourmolu should know about
reexports: []

47 changes: 28 additions & 19 deletions run-st.cabal
Original file line number Diff line number Diff line change
@@ -1,29 +1,38 @@
cabal-version: 2.2
name: run-st
version: 0.1.3.2
synopsis: runST without boxing penalty
cabal-version: 2.2
name: run-st
version: 0.1.3.3
synopsis: runST without boxing penalty
description:
This package provides specializations of `runST` that avoid a needless
data-constructor allocation for the returned value.
If <https://gitlab.haskell.org/ghc/ghc/issues/15127 issue 15127> is
resolved, this package will no longer be necessary.

homepage: https://github.com/andrewthad/run-st
bug-reports: https://github.com/andrewthad/run-st/issues
license: BSD-3-Clause
license-file: LICENSE
author: Andrew Martin
maintainer: [email protected]
copyright: 2019 Andrew Martin
category: Data
extra-source-files: CHANGELOG.md
homepage: https://github.com/byteverse/run-st
bug-reports: https://github.com/byteverse/run-st/issues
license: BSD-3-Clause
license-file: LICENSE
author: Andrew Martin
maintainer: [email protected]
copyright: 2019 Andrew Martin
category: Data
extra-doc-files: CHANGELOG.md

common build-settings
default-language: Haskell2010
ghc-options: -Wall -Wunused-packages

library
import: build-settings
exposed-modules: Control.Monad.ST.Run
build-depends:
, base >=4.12 && <5
, primitive >=0.7 && <0.10
, primitive-unlifted >=2.1
hs-source-dirs: src
default-language: Haskell2010
ghc-options: -O2 -Wall
, base >=4.12 && <5
, primitive >=0.7 && <0.10
, primitive-unlifted >=2.1

hs-source-dirs: src
ghc-options: -O2

source-repository head
type: git
location: git://github.com/byteverse/run-st.git
136 changes: 71 additions & 65 deletions src/Control/Monad/ST/Run.hs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{-# language BangPatterns #-}
{-# language KindSignatures #-}
{-# language MagicHash #-}
{-# language RankNTypes #-}
{-# language UnboxedTuples #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE UnboxedTuples #-}

module Control.Monad.ST.Run
( -- * Arrays
Expand All @@ -11,6 +11,7 @@ module Control.Monad.ST.Run
, runByteArrayST
, runPrimArrayST
, runUnliftedArrayST

-- * Integral Types
, runIntST
, runInt8ST
Expand All @@ -20,142 +21,147 @@ module Control.Monad.ST.Run
, runWord8ST
, runWord16ST
, runWord32ST

-- * Char
, runCharST

-- * Floating Point Types
, runFloatST
, runDoubleST

-- * Tuples
, runIntArrayST
, runIntByteArrayST
, runIntLiftedTypeST
, runIntIntByteArrayST
, runWordArrayST
, runWordByteArrayST

-- * Maybes
, runMaybeByteArrayST
) where

import Data.Kind (Type)
import Data.Primitive.Array (Array(Array))
import Data.Primitive.ByteArray (ByteArray(ByteArray))
import Data.Primitive.PrimArray (PrimArray(PrimArray))
import Data.Primitive.SmallArray (SmallArray(SmallArray))
import Data.Primitive.Unlifted.Array (UnliftedArray_(UnliftedArray))
import GHC.Exts (Char(C#),Int(I#),Word(W#),runRW#)
import GHC.Exts (Double(D#),Float(F#))
import GHC.Int (Int8(I8#),Int16(I16#),Int32(I32#))
import GHC.ST (ST(ST))
import GHC.Word (Word8(W8#),Word16(W16#),Word32(W32#))
import Data.Primitive.Array (Array (Array))
import Data.Primitive.ByteArray (ByteArray (ByteArray))
import Data.Primitive.PrimArray (PrimArray (PrimArray))
import Data.Primitive.SmallArray (SmallArray (SmallArray))
import Data.Primitive.Unlifted.Array (UnliftedArray_ (UnliftedArray))
import GHC.Exts (Char (C#), Double (D#), Float (F#), Int (I#), Word (W#), runRW#)
import GHC.Int (Int16 (I16#), Int32 (I32#), Int8 (I8#))
import GHC.ST (ST (ST))
import GHC.Word (Word16 (W16#), Word32 (W32#), Word8 (W8#))

runArrayST :: (forall s. ST s (Array a)) -> Array a
{-# inline runArrayST #-}
runArrayST f = Array (runRW# (\s0 -> case f of { ST g -> case g s0 of { (# _, Array r #) -> r }}))
{-# INLINE runArrayST #-}
runArrayST f = Array (runRW# (\s0 -> case f of ST g -> case g s0 of (# _, Array r #) -> r))

runSmallArrayST :: (forall s. ST s (SmallArray a)) -> SmallArray a
{-# inline runSmallArrayST #-}
runSmallArrayST f = SmallArray (runRW# (\s0 -> case f of { ST g -> case g s0 of { (# _, SmallArray r #) -> r }}))
{-# INLINE runSmallArrayST #-}
runSmallArrayST f = SmallArray (runRW# (\s0 -> case f of ST g -> case g s0 of (# _, SmallArray r #) -> r))

runByteArrayST :: (forall s. ST s ByteArray) -> ByteArray
{-# inline runByteArrayST #-}
runByteArrayST f = ByteArray (runRW# (\s0 -> case f of { ST g -> case g s0 of { (# _, ByteArray r #) -> r }}))
{-# INLINE runByteArrayST #-}
runByteArrayST f = ByteArray (runRW# (\s0 -> case f of ST g -> case g s0 of (# _, ByteArray r #) -> r))

runPrimArrayST :: (forall s. ST s (PrimArray a)) -> PrimArray a
{-# inline runPrimArrayST #-}
runPrimArrayST f = PrimArray (runRW# (\s0 -> case f of { ST g -> case g s0 of { (# _, PrimArray r #) -> r }}))
{-# INLINE runPrimArrayST #-}
runPrimArrayST f = PrimArray (runRW# (\s0 -> case f of ST g -> case g s0 of (# _, PrimArray r #) -> r))

runUnliftedArrayST :: (forall s. ST s (UnliftedArray_ unlifted_a a)) -> UnliftedArray_ unlifted_a a
{-# inline runUnliftedArrayST #-}
runUnliftedArrayST f = UnliftedArray (runRW# (\s0 -> case f of { ST g -> case g s0 of { (# _, UnliftedArray r #) -> r }}))
{-# INLINE runUnliftedArrayST #-}
runUnliftedArrayST f = UnliftedArray (runRW# (\s0 -> case f of ST g -> case g s0 of (# _, UnliftedArray r #) -> r))

runCharST :: (forall s. ST s Char) -> Char
{-# inline runCharST #-}
runCharST f = C# (runRW# (\s0 -> case f of { ST g -> case g s0 of { (# _, C# r #) -> r }}))
{-# INLINE runCharST #-}
runCharST f = C# (runRW# (\s0 -> case f of ST g -> case g s0 of (# _, C# r #) -> r))

runFloatST :: (forall s. ST s Float) -> Float
{-# inline runFloatST #-}
runFloatST f = F# (runRW# (\s0 -> case f of { ST g -> case g s0 of { (# _, F# r #) -> r }}))
{-# INLINE runFloatST #-}
runFloatST f = F# (runRW# (\s0 -> case f of ST g -> case g s0 of (# _, F# r #) -> r))

runDoubleST :: (forall s. ST s Double) -> Double
{-# inline runDoubleST #-}
runDoubleST f = D# (runRW# (\s0 -> case f of { ST g -> case g s0 of { (# _, D# r #) -> r }}))
{-# INLINE runDoubleST #-}
runDoubleST f = D# (runRW# (\s0 -> case f of ST g -> case g s0 of (# _, D# r #) -> r))

runIntST :: (forall s. ST s Int) -> Int
{-# inline runIntST #-}
runIntST f = I# (runRW# (\s0 -> case f of { ST g -> case g s0 of { (# _, I# r #) -> r }}))
{-# INLINE runIntST #-}
runIntST f = I# (runRW# (\s0 -> case f of ST g -> case g s0 of (# _, I# r #) -> r))

runWordST :: (forall s. ST s Word) -> Word
{-# inline runWordST #-}
runWordST f = W# (runRW# (\s0 -> case f of { ST g -> case g s0 of { (# _, W# r #) -> r }}))
{-# INLINE runWordST #-}
runWordST f = W# (runRW# (\s0 -> case f of ST g -> case g s0 of (# _, W# r #) -> r))

runWord8ST :: (forall s. ST s Word8) -> Word8
{-# inline runWord8ST #-}
runWord8ST f = W8# (runRW# (\s0 -> case f of { ST g -> case g s0 of { (# _, W8# r #) -> r }}))
{-# INLINE runWord8ST #-}
runWord8ST f = W8# (runRW# (\s0 -> case f of ST g -> case g s0 of (# _, W8# r #) -> r))

runWord16ST :: (forall s. ST s Word16) -> Word16
{-# inline runWord16ST #-}
runWord16ST f = W16# (runRW# (\s0 -> case f of { ST g -> case g s0 of { (# _, W16# r #) -> r }}))
{-# INLINE runWord16ST #-}
runWord16ST f = W16# (runRW# (\s0 -> case f of ST g -> case g s0 of (# _, W16# r #) -> r))

runWord32ST :: (forall s. ST s Word32) -> Word32
{-# inline runWord32ST #-}
runWord32ST f = W32# (runRW# (\s0 -> case f of { ST g -> case g s0 of { (# _, W32# r #) -> r }}))
{-# INLINE runWord32ST #-}
runWord32ST f = W32# (runRW# (\s0 -> case f of ST g -> case g s0 of (# _, W32# r #) -> r))

runInt8ST :: (forall s. ST s Int8) -> Int8
{-# inline runInt8ST #-}
runInt8ST f = I8# (runRW# (\s0 -> case f of { ST g -> case g s0 of { (# _, I8# r #) -> r }}))
{-# INLINE runInt8ST #-}
runInt8ST f = I8# (runRW# (\s0 -> case f of ST g -> case g s0 of (# _, I8# r #) -> r))

runInt16ST :: (forall s. ST s Int16) -> Int16
{-# inline runInt16ST #-}
runInt16ST f = I16# (runRW# (\s0 -> case f of { ST g -> case g s0 of { (# _, I16# r #) -> r }}))
{-# INLINE runInt16ST #-}
runInt16ST f = I16# (runRW# (\s0 -> case f of ST g -> case g s0 of (# _, I16# r #) -> r))

runInt32ST :: (forall s. ST s Int32) -> Int32
{-# inline runInt32ST #-}
runInt32ST f = I32# (runRW# (\s0 -> case f of { ST g -> case g s0 of { (# _, I32# r #) -> r }}))
{-# INLINE runInt32ST #-}
runInt32ST f = I32# (runRW# (\s0 -> case f of ST g -> case g s0 of (# _, I32# r #) -> r))

runIntArrayST :: (forall s. ST s (Int, Array a)) -> (Int, Array a)
{-# inline runIntArrayST #-}
{-# INLINE runIntArrayST #-}
runIntArrayST f =
let !(# t0, t1 #) = runRW# (\s0 -> case f of { ST g -> case g s0 of { (# _, ( I# r0, Array r1 ) #) -> (# r0, r1 #) }})
let !(# t0, t1 #) = runRW# (\s0 -> case f of ST g -> case g s0 of (# _, (I# r0, Array r1) #) -> (# r0, r1 #))
in (I# t0, Array t1)

runWordArrayST :: (forall s. ST s (Word, Array a)) -> (Word, Array a)
{-# inline runWordArrayST #-}
{-# INLINE runWordArrayST #-}
runWordArrayST f =
let !(# t0, t1 #) = runRW# (\s0 -> case f of { ST g -> case g s0 of { (# _, ( W# r0, Array r1 ) #) -> (# r0, r1 #) }})
let !(# t0, t1 #) = runRW# (\s0 -> case f of ST g -> case g s0 of (# _, (W# r0, Array r1) #) -> (# r0, r1 #))
in (W# t0, Array t1)

runIntLiftedTypeST :: forall (a :: Type). (forall s. ST s (Int, a)) -> (Int, a)
{-# inline runIntLiftedTypeST #-}
{-# INLINE runIntLiftedTypeST #-}
runIntLiftedTypeST f =
let !(# t0, t1 #) = runRW# (\s0 -> case f of { ST g -> case g s0 of { (# _, ( I# r0, r1 ) #) -> (# r0, r1 #) }})
let !(# t0, t1 #) = runRW# (\s0 -> case f of ST g -> case g s0 of (# _, (I# r0, r1) #) -> (# r0, r1 #))
in (I# t0, t1)

runIntByteArrayST :: (forall s. ST s (Int, ByteArray)) -> (Int, ByteArray)
{-# inline runIntByteArrayST #-}
{-# INLINE runIntByteArrayST #-}
runIntByteArrayST f =
let !(# t0, t1 #) = runRW# (\s0 -> case f of { ST g -> case g s0 of { (# _, ( I# r0, ByteArray r1 ) #) -> (# r0, r1 #) }})
let !(# t0, t1 #) = runRW# (\s0 -> case f of ST g -> case g s0 of (# _, (I# r0, ByteArray r1) #) -> (# r0, r1 #))
in (I# t0, ByteArray t1)

runIntIntByteArrayST :: (forall s. ST s (Int, Int, ByteArray)) -> (Int, Int, ByteArray)
{-# inline runIntIntByteArrayST #-}
{-# INLINE runIntIntByteArrayST #-}
runIntIntByteArrayST f =
let !(# t0, t1, t2 #) = runRW# (\s0 -> case f of { ST g -> case g s0 of { (# _, ( I# r0, I# r1, ByteArray r2 ) #) -> (# r0, r1, r2 #) }})
let !(# t0, t1, t2 #) = runRW# (\s0 -> case f of ST g -> case g s0 of (# _, (I# r0, I# r1, ByteArray r2) #) -> (# r0, r1, r2 #))
in (I# t0, I# t1, ByteArray t2)

runWordByteArrayST :: (forall s. ST s (Word, ByteArray)) -> (Word, ByteArray)
{-# inline runWordByteArrayST #-}
{-# INLINE runWordByteArrayST #-}
runWordByteArrayST f =
let !(# t0, t1 #) = runRW# (\s0 -> case f of { ST g -> case g s0 of { (# _, ( W# r0, ByteArray r1 ) #) -> (# r0, r1 #) }})
let !(# t0, t1 #) = runRW# (\s0 -> case f of ST g -> case g s0 of (# _, (W# r0, ByteArray r1) #) -> (# r0, r1 #))
in (W# t0, ByteArray t1)

runMaybeByteArrayST :: (forall s. ST s (Maybe ByteArray)) -> Maybe ByteArray
{-# inline runMaybeByteArrayST #-}
{-# INLINE runMaybeByteArrayST #-}
runMaybeByteArrayST f =
let !x = runRW#
(\s0 -> case f of { ST g -> case g s0 of
{ (# _, Just (ByteArray r2 ) #) -> (# | r2 #)
; (# _, Nothing #) -> (# (# #) | #)
}})
let !x =
runRW#
( \s0 -> case f of
ST g -> case g s0 of
(# _, Just (ByteArray r2) #) -> (# | r2 #)
(# _, Nothing #) -> (# (# #) | #)
)
in case x of
(# (# #) | #) -> Nothing
(# | y #) -> Just (ByteArray y)

0 comments on commit 3f89cff

Please sign in to comment.