cplug-0.2.0.0: Recompile and run partially applied C functions in Haskell, during runtime

Safe HaskellNone
LanguageHaskell2010

HSGen.Recompiler.Class

Synopsis

Documentation

class Resolvable a r | a -> r where Source

This class is of functions with type a and final return type r. Additionally, r should be of the form: Wrapped a b

Methods

resolve :: a -> r Source

resolve resolves a "Resolvable a r" to r

Instances

Resolvable a r => Resolvable (t -> a) r Source 
Resolvable (Wrapped a b) (Wrapped a b) Source 

class Compilable a r b s | a -> r, b -> s, a s -> b, r b -> a where Source

Methods

($$$) :: (r -> s) -> a -> b infixr 2 Source

`($$$) f wrappedFunction` essentially applies f directly to the Wrapped part of wrappedFunction.

Instances

Compilable a r b s => Compilable (t -> a) r (t -> b) s Source 
Compilable (Wrapped a b) (Wrapped a b) (Wrapped c d) (Wrapped c d) Source 

($$) :: Compilable a1 (Wrapped (t -> a) b) t1 (Wrapped a b) => (t -> a1) -> t -> t1 infixl 1 Source

Given a simple Compilable function:

   plus :: Int -> Int -> Wrapped (Int -> Int -> Int) Int

You can use `($$)` to apply plus to both the outer (Int -> Int -> ..) and innner (Wrapped (Int -> ..)) functions of plus. For example:

>>> plus $$ 1 $$ 2
Wrap 3 3

class FixResolvable a r | a -> r where Source

Methods

fixResolve :: a -> r Source

Instances

class FixCompilable a r b s | a -> r, b -> s, a s -> b, r b -> a where Source

Methods

(###) :: (r -> s) -> a -> b infixr 2 Source

Instances

FixCompilable a r b s => FixCompilable (Fix t -> a) r (Fix t -> b) s Source 
FixCompilable (Wrapped a b) (Wrapped a b) (Wrapped c d) (Wrapped c d) Source 

(##) :: FixCompilable a (Wrapped (r -> a1) b) (r -> r1) (Wrapped a1 b) => a -> r -> r1 Source

See `($$)`

apInOut :: Compilable a b b c => (b -> c) -> a -> c Source

Apply a function to a Compilable from the outside (just regular application) and also inside (`($$$)`)

fixApInOut :: FixCompilable a b b c => (b -> c) -> a -> c Source

flipC :: Compilable a1 (a -> b -> c) c (b -> a -> c) => (a -> b -> a1) -> b -> a -> c Source

Flip a compilable function

fixFlipC :: FixCompilable a (a1 -> b -> c) (a1 -> b -> c) (b -> a1 -> c) => a -> b -> a1 -> c Source

See flipC

replaceFW :: a -> Wrapped a b -> Wrapped a b Source

compile :: (Compilable a1 (Wrapped a b) r (Wrapped a b), Resolvable a1 (Wrapped a b1)) => a1 -> r Source

Compile a compilable function, essentially by resolving to the wrapped function and return value, unwrapping the non-compilable function (i.e. getting the compiled version), and replacing the original non-compilable function.

fixCompile :: (Compilable a1 (Wrapped a b) r (Wrapped a b), Resolvable a1 (Wrapped a b1)) => a1 -> r Source