-
-
Save christhekeele/7e1f3d73d51e5fb871e51e438df95c47 to your computer and use it in GitHub Desktop.
Example compile-time dependency adapter and assertions
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
defmodule Ash.SAT.Solver.Behaviour do | |
@callback function(:input) :: :return | |
end | |
cond do | |
{:module, Picosat} = Code.ensure_loaded(Picosat) -> | |
defmodule Ash.SAT.Solver do | |
@behaviour Ash.SAT.Solver.Behaviour | |
def function(:input), do: :picsat_specific | |
end | |
{:module, Csp} = Code.ensure_loaded(Csp) -> | |
IO.warn( | |
"using in-effecient Csp fallback, | |
helpful instructions here" | |
) | |
defmodule Ash.SAT.Solver do | |
@behaviour Ash.SAT.Solver.Behaviour | |
def function(:input), do: :csp_specific | |
end | |
{:error, :nofile} -> | |
raise CompileError, | |
"no SAT solver dependency installed, | |
helpful instructions here" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment