Skip to content

Commit

Permalink
Remove the dependency of cairo
Browse files Browse the repository at this point in the history
  • Loading branch information
junjihashimoto committed Sep 25, 2023
1 parent a37b3e4 commit 3019044
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 102 deletions.
19 changes: 16 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,26 @@ jobs:
- name: Install packages
run: |
if [ ${{ matrix.os }} == "ubuntu-latest" ] ; then
sudo apt-get update -qq && sudo apt-get install -y gobjc++ libgnustep-base-dev
sudo apt-get update -qq && sudo apt-get install -y gobjc++ libgnustep-base-dev libgsl-dev
else
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install gsl || true
fi
- uses: actions/cache@v3
with:
path: ~/.stack
key: stack-${{ matrix.os }}-${{ matrix.stackage }}-${{ hashFiles('stack.yaml') }}
- name: Build
run: stack build --stack-yaml stack-${{ matrix.stackage }}.yaml --flag inline-c-cpp:std-vector-example
run: |
if [ ${{ matrix.os }} == "ubuntu-latest" ] ; then
stack build --stack-yaml stack-${{ matrix.stackage }}.yaml --flag inline-c:gsl-example --flag inline-c-cpp:std-vector-example
else
stack build --stack-yaml stack-${{ matrix.stackage }}.yaml --flag inline-c-cpp:std-vector-example
fi
- name: Test
run: stack test --stack-yaml stack-${{ matrix.stackage }}.yaml --flag inline-c-cpp:std-vector-example
run: |
if [ ${{ matrix.os }} == "ubuntu-latest" ] ; then
stack test --stack-yaml stack-${{ matrix.stackage }}.yaml --flag inline-c:gsl-example --flag inline-c-cpp:std-vector-example
else
stack test --stack-yaml stack-${{ matrix.stackage }}.yaml --flag inline-c-cpp:std-vector-example
fi
78 changes: 0 additions & 78 deletions .travis.yml

This file was deleted.

14 changes: 7 additions & 7 deletions inline-c/examples/gsl-ode.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE MultiWayIf #-}
import Data.Coerce (coerce)
import Unsafe.Coerce (unsafeCoerce)
import Data.Monoid ((<>))
import qualified Data.Vector.Storable as V
import qualified Data.Vector.Storable.Mutable as VM
import Foreign.C.Types
import Foreign.ForeignPtr (newForeignPtr_)
import Foreign.Ptr (Ptr)
import Foreign.Storable (Storable)
import qualified Graphics.Rendering.Chart.Backend.Cairo as Chart
import qualified Graphics.Rendering.Chart.Easy as Chart
import qualified Language.C.Inline as C
import qualified Language.C.Inline.Unsafe as CU
import System.IO.Unsafe (unsafePerformIO)
import Control.Monad (forM_)
import System.IO (withFile, hPutStrLn, IOMode(..))

C.context (C.baseCtx <> C.vecCtx <> C.funCtx)

Expand Down Expand Up @@ -94,7 +94,7 @@ solveOde
-> Either String (V.Vector Double)
-- ^ Solution at end point, or error.
solveOde fun x0 f0 xend =
coerce $ solveOdeC (coerce fun) (coerce x0) (coerce f0) (coerce xend)
unsafeCoerce $ solveOdeC (unsafeCoerce fun) (unsafeCoerce x0) (unsafeCoerce f0) (unsafeCoerce xend)

lorenz
:: Double
Expand All @@ -121,9 +121,9 @@ lorenz x0 f0 xend = solveOde fun x0 f0 xend
]

main :: IO ()
main = Chart.toFile Chart.def "lorenz.png" $ do
Chart.layout_title Chart..= "Lorenz"
Chart.plot $ Chart.line "curve" [pts]
main = withFile "lorenz.csv" WriteMode $ \h ->
forM_ pts $ \(x,y) ->
hPutStrLn h $ show x ++ ", " ++ show y
where
pts = [(f V.! 0, f V.! 2) | (_x, f) <- go 0 (V.fromList [10.0 , 1.0 , 1.0])]

Expand Down
2 changes: 0 additions & 2 deletions inline-c/inline-c.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,5 @@ executable gsl-ode
build-depends: base >=4 && <5
, inline-c
, vector
, Chart >= 1.3
, Chart-cairo
else
buildable: False
4 changes: 0 additions & 4 deletions stack-lts-20.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,3 @@ packages:
- inline-c-cpp
- inline-c-objc
- sample-cabal-project
extra-deps:
- Chart-cairo-1.9.3@sha256:f484a7194ca08ed67f02aa626e2f8f4d1a9b50624e0d50e3ced62958f7481cca,925
- cairo-0.13.8.0@sha256:9b64a376ebaa4f153bba5866a32291fd4bed48147009cce9158ce6533928eba8,4075
- gtk2hs-buildtools-0.13.8.0@sha256:132f38155fc677430a47ea750918973161c876fb6f281d342ac2f07eb99229ce,5238
4 changes: 0 additions & 4 deletions stack-lts-21.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,3 @@ packages:
- inline-c-cpp
- inline-c-objc
- sample-cabal-project
extra-deps:
- Chart-cairo-1.9.3@sha256:f484a7194ca08ed67f02aa626e2f8f4d1a9b50624e0d50e3ced62958f7481cca,925
- cairo-0.13.8.0@sha256:9b64a376ebaa4f153bba5866a32291fd4bed48147009cce9158ce6533928eba8,4075
- gtk2hs-buildtools-0.13.8.0@sha256:132f38155fc677430a47ea750918973161c876fb6f281d342ac2f07eb99229ce,5238
4 changes: 0 additions & 4 deletions stack-nightly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,3 @@ packages:
- inline-c-cpp
- inline-c-objc
- sample-cabal-project
extra-deps:
- Chart-cairo-1.9.3@sha256:f484a7194ca08ed67f02aa626e2f8f4d1a9b50624e0d50e3ced62958f7481cca,925
- cairo-0.13.8.0@sha256:9b64a376ebaa4f153bba5866a32291fd4bed48147009cce9158ce6533928eba8,4075
- gtk2hs-buildtools-0.13.8.0@sha256:132f38155fc677430a47ea750918973161c876fb6f281d342ac2f07eb99229ce,5238

0 comments on commit 3019044

Please sign in to comment.