Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: ci
on:
push:
branches:
- master
pull_request: {} # Validate all PRs

defaults:
run:
shell: bash

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest]
ghc: ['8.6', '8.8', '8.10', '9.0', '9.2', 'latest']
include:
- os: macOS-latest
ghc: 'latest'
steps:
- uses: actions/checkout@v2
- uses: haskell/actions/setup@v1
id: setup-haskell-cabal
with:
ghc-version: ${{ matrix.ghc }}
- name: Update cabal package database
run: cabal update
- uses: actions/cache@v2
name: Cache cabal stuff
with:
path: |
${{ steps.setup-haskell-cabal.outputs.cabal-store }}
dist-newstyle
key: ${{ runner.os }}-${{ matrix.ghc }}
- name: Test
run: |
cabal build primitive-unlifted:test --enable-tests
cabal test --enable-tests
- name: Haddock
run: |
cabal haddock
- name: Cabal check
run: |
cabal check
windows-build:
runs-on: windows-latest
needs: build
strategy:
fail-fast: true
matrix:
ghc: ['latest']
steps:
- uses: actions/checkout@v2
- uses: haskell/actions/setup@v1
id: setup-haskell-cabal
with:
ghc-version: ${{ matrix.ghc }}
- name: Update cabal package database
run: cabal update
- uses: actions/cache@v2
name: Cache cabal stuff
with:
path: |
${{ steps.setup-haskell-cabal.outputs.cabal-store }}
dist-newstyle
key: ${{ runner.os }}-${{ matrix.ghc }}
# We rebuild tests several times to avoid intermittent failures on Windows
# https://github.com/haskell/actions/issues/36
# We also use --enable-tests and --enable-benchmarks to avoid
# test and bench commands from reconfiguring and thus rebuilding.
- name: Build Test
run: |
bld() { cabal build primitive-unlifted:test --enable-tests; }
bld || bld || bld

- name: Run Test
run: |
cabal test --enable-tests
shell: pwsh
- name: Haddock
run: |
cabal haddock
- name: Cabal check
run: |
cabal check
123 changes: 0 additions & 123 deletions .travis.yml

This file was deleted.

9 changes: 9 additions & 0 deletions src/Data/Primitive/Unlifted/MVar.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# language CPP #-}
{-# language UnboxedTuples #-}
{-# language UnboxedSums #-}
{-# language RoleAnnotations #-}
Expand All @@ -10,6 +11,12 @@
{-# language BangPatterns #-}
{- options_ghc -ddump-simpl #-}

#if MIN_VERSION_base(4,15,0)

module Data.Primitive.Unlifted.MVar () where

#else

-- | This module includes all the features of "Control.Concurrent.MVar", except
-- that the functions in "Data.Primitive.Unlifted.Weak" subsume the functionality
-- of @mkWeakMV@ and @addMVarFinalizer@, so we do not include analogues of those
Expand Down Expand Up @@ -135,3 +142,5 @@ modifyUnliftedMVarMasked_
=> UnliftedMVar RealWorld a -> (a -> m a) -> m ()
{-# INLINE modifyUnliftedMVarMasked_ #-}
modifyUnliftedMVarMasked_ m st = stToPrim $ MV.modifyUnliftedMVarMasked_ m (primToST . st)

#endif
9 changes: 9 additions & 0 deletions src/Data/Primitive/Unlifted/MVar/Primops.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# language CPP #-}
{-# language ScopedTypeVariables #-}
{-# language MagicHash #-}
{-# language KindSignatures #-}
Expand All @@ -7,6 +8,12 @@
{-# language RoleAnnotations #-}
{-# language DataKinds #-}

#if MIN_VERSION_base(4,15,0)

module Data.Primitive.Unlifted.MVar.Primops () where

#else

module Data.Primitive.Unlifted.MVar.Primops
( UnliftedMVar#
, newUnliftedMVar#
Expand Down Expand Up @@ -73,3 +80,5 @@ isEmptyUnliftedMVar# :: UnliftedMVar# s a -> State# s -> (# State# s, Int# #)
{-# INLINE isEmptyUnliftedMVar# #-}
isEmptyUnliftedMVar# (UnliftedMVar# mv) s
= isEmptyMVar# mv s

#endif
9 changes: 9 additions & 0 deletions src/Data/Primitive/Unlifted/MVar/ST.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# language CPP #-}
{-# language UnboxedTuples #-}
{-# language UnboxedSums #-}
{-# language RoleAnnotations #-}
Expand All @@ -10,6 +11,12 @@
{-# language BangPatterns #-}
{- options_ghc -ddump-simpl #-}

#if MIN_VERSION_base(4,15,0)

module Data.Primitive.Unlifted.MVar.ST () where

#else

-- | This module includes all the features of "Control.Concurrent.MVar", except
-- that the functions in "Data.Primitive.Unlifted.Weak" subsume the functionality
-- of @mkWeakMV@ and @addMVarFinalizer@, so we do not include analogues of those
Expand Down Expand Up @@ -273,3 +280,5 @@ modifyUnliftedMVarMasked_ m st =
a <- takeUnliftedMVarBox m
a' <- (toBox <$> st (fromBox a)) `onException` putUnliftedMVarBox m a
putUnliftedMVarBox m a'

#endif
9 changes: 9 additions & 0 deletions src/Data/Primitive/Unlifted/Weak.hs
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
{-# language CPP #-}
{-# language MagicHash #-}
{-# language UnboxedTuples #-}
{-# language TypeInType #-}
{-# language RoleAnnotations #-}
{-# language ScopedTypeVariables #-}
{-# language TypeFamilies #-}

#if MIN_VERSION_base(4,15,0)

module Data.Primitive.Unlifted.Weak () where

#else

-- | "System.Mem.Weak" provides weak references from lifted keys to lifted
-- values. "Data.IORef", "Control.Concurrent.MVar", and
-- @Control.Concurrent.STM.TVar@ provide operations for producing weak
Expand Down Expand Up @@ -142,3 +149,5 @@ touchUnlifted
:: (PrimUnlifted a, PrimMonad m, PrimState m ~ RealWorld)
=> a -> m ()
touchUnlifted a = ioToPrim $ W.touchUnlifted a

#endif
9 changes: 9 additions & 0 deletions src/Data/Primitive/Unlifted/Weak/IO.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# language CPP #-}
{-# language MagicHash #-}
{-# language UnboxedTuples #-}
{-# language TypeInType #-}
Expand All @@ -6,6 +7,12 @@
{-# language TypeFamilies #-}
{-# language DataKinds #-}

#if MIN_VERSION_base(4,15,0)

module Data.Primitive.Unlifted.Weak.IO () where

#else

-- | A version of "Data.Primitive.Unlifted.Weak" specialized to the 'IO' type.
module Data.Primitive.Unlifted.Weak.IO
( UnliftedWeak_ (..)
Expand Down Expand Up @@ -168,3 +175,5 @@ touchUnlifted
=> a -> IO ()
touchUnlifted a = IO $ \s ->
(# Exts.touch# (toUnlifted# a) s, () #)

#endif
9 changes: 9 additions & 0 deletions src/Data/Primitive/Unlifted/Weak/Primops.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# language CPP #-}
{-# language MagicHash #-}
{-# language UnboxedTuples #-}
{-# language UnboxedSums #-}
Expand All @@ -7,6 +8,12 @@
{-# language TypeFamilies #-}
{-# language UnliftedNewtypes #-}

#if MIN_VERSION_base(4,15,0)

module Data.Primitive.Unlifted.Weak.Primops () where

#else

-- See UnsafeCoercions.md for an explanation of why we coerce
-- things the way we do here, and why some operations are marked
-- NOINLINE.
Expand Down Expand Up @@ -137,3 +144,5 @@ finalizeUnliftedWeak# (UnliftedWeak# w) s =
case finalizeWeak# w s of
(# s', 0#, _ #) -> (# s', (# (##) | #) #) -- already dead, or no Haskell finalizer
(# s', _, f #) -> (# s', (# | f #) #)

#endif