clash-lib-1.2.0: CAES Language for Synchronous Hardware - As a Library

Clash.Core.EqSolver

Synopsis

# Documentation

Data type that indicates what kind of solution (if any) was found

Constructors

 Solution (TyVar, Type) Solution was found. Variable equals some integer. AbsurdSolution A solution was found, but it involved negative naturals. NoSolution Given type wasn't an equation, or it was unsolvable.
Instances
 Source # Instance detailsDefined in Clash.Core.EqSolver Methods Source # Instance detailsDefined in Clash.Core.EqSolver MethodsshowList :: [TypeEqSolution] -> ShowS #

solveNonAbsurds :: TyConMap -> [(Type, Type)] -> [(TyVar, Type)] Source #

Solve given equations and return all non-absurd solutions

solveEq :: TyConMap -> (Type, Type) -> [TypeEqSolution] Source #

Solve simple equalities such as:

• a ~ 3
• 3 ~ a
• SomeType a b ~ SomeType 3 5
• SomeType 3 5 ~ SomeType a b
• SomeType a 5 ~ SomeType 3 b

Solve equations supported by normalizeAdd. See documentation of TypeEqSolution to understand the return value.

normalizeAdd :: (Type, Type) -> Maybe (Integer, Integer, Type) Source #

Given the left and right side of an equation, normalize it such that equations of the following forms:

• 5 ~ n + 2
• 5 ~ 2 + n
• n + 2 ~ 5
• 2 + n ~ 5

are returned as (5, 2, n)

Tests for unreachable alternative due to types being "absurd". See isAbsurdEq for more info.

isAbsurdEq :: TyConMap -> (Type, Type) -> Bool Source #

Determines if an "equation" obtained through altEqs or typeEq is absurd. That is, it tests if two types that are definitely not equal are asserted to be equal OR if the computation of the types yield some absurd (intermediate) result such as -1.

altEqs :: TyConMap -> Alt -> [(Type, Type)] Source #

Get constraint equations

If type is an equation, return LHS and RHS.