-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
253 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Changelog for compress | ||
|
||
## Unreleased changes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
Copyright Providence Salumu (c) 2021 | ||
|
||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
* Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
|
||
* Redistributions in binary form must reproduce the above | ||
copyright notice, this list of conditions and the following | ||
disclaimer in the documentation and/or other materials provided | ||
with the distribution. | ||
|
||
* Neither the name of Providence Salumu nor the names of other | ||
contributors may be used to endorse or promote products derived | ||
from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# compress |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import Distribution.Simple | ||
main = defaultMain |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module Main where | ||
|
||
import Lib | ||
|
||
main :: IO () | ||
main = someFunc |
50 changes: 50 additions & 0 deletions
50
playground/haskell/compress/cbits/include/issue-398/dawa79.H
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#pragma once | ||
|
||
#include <hobbes/db/file.H> | ||
#include <hobbes/db/series.H> | ||
#include <hobbes/hobbes.H> | ||
#include <hobbes/lang/tylift.H> | ||
#include <hobbes/storage.H> | ||
|
||
const int option = 100; | ||
|
||
struct TestEnum { | ||
enum Enum : uint32_t { Invalid = 0, Option = option }; | ||
Enum _value; | ||
using is_enum = void; | ||
}; | ||
|
||
namespace hobbes { | ||
template struct liftTestEnum { | ||
static MonoTypePtr type(typedb &) { | ||
Variant::Members vms; | ||
auto i = 0; | ||
vms.push_back(Variant::Member("Invalid", primty("unit"), 0)); | ||
vms.push_back(Variant::Member("Option", primty("unit"), option)); | ||
return MonoTypePtr(Variant::make(vms)); | ||
} | ||
}; | ||
template struct lift<T *, false, typename T::is_enum> : public liftTestEnum {}; | ||
template struct lift<T, true, typename T::is_enum> : public liftTestEnum {}; | ||
} // namespace hobbes | ||
|
||
DEFINE_STRUCT(FixarrayS, (TestEnum, value), (const hobbes::array *, body)); | ||
|
||
void run(const std::string &fname, bool compressed) { | ||
hobbes::cc c; | ||
FixarrayS v1; | ||
v1.body = hobbes::makeString("Hello world!"); | ||
v1.value._value = TestEnum::Option; | ||
|
||
hobbes::writer writer{fname}; | ||
hobbes::series ss1(&c, &writer, "udata", 10000, | ||
compressed ? hobbes::StoredSeries::Compressed | ||
: hobbes::StoredSeries::Raw); | ||
ss1(v1); | ||
std::cout << "------------testing -----------------" << std::endl; | ||
// c.define("f", "inputFile :: (LoadFile " | ||
// " + fname + " | ||
// " w) => w"); | ||
// c.compileFn<void()>( | ||
// "print([(x.value, (unsafeCast(x.value)::{t:int}).t) | x<-f.udata])")(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
cabal-version: 3.0 | ||
name: compress | ||
version: 0.1.0.0 | ||
description: Please see the README on GitHub at <https://github.com/smunix/compress#readme> | ||
homepage: https://github.com/smunix/compress#readme | ||
bug-reports: https://github.com/smunix/compress/issues | ||
author: Providence Salumu | ||
maintainer: [email protected] | ||
copyright: BSD3 | ||
license: BSD-3-Clause | ||
license-file: LICENSE | ||
build-type: Simple | ||
extra-source-files: | ||
README.md | ||
ChangeLog.md | ||
|
||
source-repository head | ||
type: git | ||
location: https://github.com/smunix/compress | ||
|
||
common common-stanzas | ||
default-extensions: BlockArguments | ||
BangPatterns | ||
GADTs | ||
MultiParamTypeClasses | ||
OverloadedStrings | ||
RankNTypes | ||
ScopedTypeVariables | ||
TupleSections | ||
TypeApplications | ||
ViewPatterns | ||
default-language: Haskell2010 | ||
cxx-options: -std=c++14 -g -O2 | ||
ghc-options: -pgmc=g++ -ddump-splices -ddump-simpl | ||
extra-libraries: hobbes-dyn | ||
include-dirs: cbits/include | ||
build-depends: base | ||
, bytestring | ||
, text | ||
, inline-c | ||
, inline-c-cpp | ||
, microlens-platform | ||
|
||
library | ||
import: common-stanzas | ||
exposed-modules: | ||
Lib | ||
other-modules: | ||
Paths_compress | ||
hs-source-dirs: | ||
src | ||
|
||
executable compress-exe | ||
import: common-stanzas | ||
main-is: Main.hs | ||
other-modules: | ||
Paths_compress | ||
hs-source-dirs: | ||
app | ||
ghc-options: -threaded -rtsopts -with-rtsopts=-N | ||
build-depends: | ||
compress | ||
default-language: Haskell2010 | ||
|
||
test-suite compress-test | ||
type: exitcode-stdio-1.0 | ||
main-is: Spec.hs | ||
other-modules: | ||
Paths_compress | ||
hs-source-dirs: | ||
test | ||
ghc-options: -threaded -rtsopts -with-rtsopts=-N | ||
build-depends: | ||
base >=4.7 | ||
, compress | ||
default-language: Haskell2010 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
{-# LANGUAGE QuasiQuotes #-} | ||
{-# LANGUAGE TemplateHaskell #-} | ||
|
||
module Lib | ||
( someFunc, | ||
) | ||
where | ||
|
||
import Foreign.Concurrent (newForeignPtr) | ||
import Foreign.ForeignPtr hiding (newForeignPtr) | ||
import Foreign.Ptr | ||
import qualified Language.C.Inline as C | ||
import qualified Language.C.Inline.Cpp as C | ||
import Lens.Micro.Platform | ||
|
||
newtype Cc where | ||
Cc :: {_compiler :: ForeignPtr Cc} -> Cc | ||
|
||
makeLenses ''Cc | ||
|
||
C.context $ | ||
C.baseCtx | ||
<> C.bsCtx | ||
<> C.cppCtx | ||
<> C.fptrCtx | ||
<> C.funCtx | ||
<> C.bsCtx | ||
<> C.cppTypePairs | ||
[ ("Cc", [t|Cc|]) | ||
] | ||
|
||
C.include "<hobbes/hobbes.H>" | ||
C.include "<issue-398/dawa79.H>" | ||
C.include "<iostream>" | ||
|
||
C.using "Cc = hobbes::cc" | ||
|
||
class New a where | ||
new :: IO a | ||
|
||
instance New Cc where | ||
new = | ||
[C.exp|Cc* {new Cc{}}|] | ||
>>= \cc -> | ||
newForeignPtr cc ([C.block|void { delete $(Cc* cc); }|]) | ||
>>= return . Cc | ||
|
||
withCc :: (Cc -> IO ()) -> IO () | ||
withCc fn = new >>= fn | ||
|
||
someFunc :: IO () | ||
someFunc = withCc \_ -> do | ||
putStrLn "Cc initialized" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
main :: IO () | ||
main = putStrLn "Test suite not yet implemented" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,16 @@ | ||
cradle: | ||
cabal: | ||
- path: "compress/src" | ||
component: "lib:compress" | ||
|
||
- path: "compress/app/Main.hs" | ||
component: "compress:exe:compress-exe" | ||
|
||
- path: "compress/app/Paths_compress.hs" | ||
component: "compress:exe:compress-exe" | ||
|
||
- path: "compress/test" | ||
component: "compress:test:compress-test" | ||
|
||
- path: "mcmove/src/Main.hs" | ||
component: "mcmove:exe:mcmove" |