Skip to content

MonadFail First orphan #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
20 changes: 4 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,12 @@ If you want to use this with GHCi, make sure to pass in `-fobject-code`.

## Building

This currently depends on a GHC [feature][1] that will be available in GHC 8.6.
Until then, you'll have to [build GHC][0] yourself or get a binary. For the
latter, you can install one of GHC's nightly builds.
This depends ghc >= 8.6. An easy way to run the examples is to use environment files:

$ curl https://ghc-artifacts.s3.amazonaws.com/nightly/validate-x86_64-darwin/latest/bindist.tar.xz | tar xz
$ cd ghc-*
$ ./configure && make install

With that installed, something like the following should work

$ cabal new-build -w /usr/local/bin/ghc-8.5.20180423
$ cabal new-test -w /usr/local/bin/ghc-8.5.20180423

Running the examples is only a matter of threading through the right package
databases. With a new enough Cabal, `new-exec` does this for you.

$ cabal new-exec -w /usr/local/bin/ghc-8.5.20180423 ghc -- -threaded -package inline-rust examples/Hello.hs
$ cabal build --write-ghc-environment-files=always
$ ghc -threaded examples/Hello.hs
[1 of 1] Compiling Main ( examples/Hello.hs, examples/Hello.o )
...
Linking examples/Hello ...
$ ./examples/Hello
Haskell: Hello. Enter a number:
Expand Down
2 changes: 1 addition & 1 deletion inline-rust.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ library
, ForeignFunctionInterface
, ScopedTypeVariables

build-depends: base >=4.9 && <5.0
build-depends: base >=4.12 && <5.0
, language-rust >=0.2.0
, prettyprinter >=1.1
, process >=1.4
Expand Down
5 changes: 5 additions & 0 deletions src/Language/Rust/Inline/Context.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Maintainer : [email protected]
Stability : experimental
Portability : GHC
-}
{-# OPTIONS_GHC -Wno-orphans #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
Expand Down Expand Up @@ -35,10 +36,14 @@ import Data.Int ( Int8, Int16, Int32, Int64 )
import Data.Word ( Word8, Word16, Word32, Word64 )
import Foreign.Ptr ( Ptr, FunPtr )
import Foreign.C.Types -- pretty much every type here is used
import qualified Control.Monad.Fail as Fail

import GHC.Exts ( Char#, Int#, Word#, Float#, Double#,
ByteArray# )

instance Fail.MonadFail First where
fail _ = mempty

-- Easier on the eyes
type RType = Ty ()
type HType = Type
Expand Down