clash-prelude-1.8.4: Clash: a functional hardware description language - Prelude library

Copyright | (C) 2019 Myrtle Software Ltd 2022 QBayLogic B.V.
License | BSD2 (see the file LICENSE)
Maintainer | QBayLogic B.V. <devops@qbaylogic.com>
Safe Haskell | None
Language | Haskell2010

Clash.Class.HasDomain.HasSingleDomain

Description

Internals for Clash.Class.HasDomain

Synopsis

- type MissingInstance = (((((("This might happen if an instance for TryDomain is missing. Try to determine" :$$$: "which of the types miss an instance, and add them. Example implementations:") :$$$: "") :$$$: " * type instance TryDomain t (MyVector n a) = TryDomain t a") :$$$: " * type instance TryDomain t (MyCircuit dom a) = Found dom") :$$$: " * type instance TryDomain t Terminal = NotFound") :$$$: "") :$$$: "Alternatively, use one of the withSpecific* functions."
- type Outro = ((((((((((((((("" :$$$: "------") :$$$: "") :$$$: "You tried to apply an explicitly routed clock, reset, or enable line") :$$$: "to a construct with, possibly, an implicitly routed one. Clash failed to") :$$$: "unambigously determine a single domain and could therefore not route it.") :$$$: "You possibly used one of these sets of functions:") :$$$: "") :$$$: " * with{ClockResetEnable,Clock,Reset,Enable}") :$$$: " * expose{ClockResetEnable,Clock,Reset,Enable}") :$$$: "") :$$$: "These functions are suitable for components defined over a single domain") :$$$: "only. If you want to use multiple domains, use the following instead:") :$$$: "") :$$$: " * withSpecific{ClockResetEnable,Clock,Reset,Enable}") :$$$: " * exposeSpecific{ClockResetEnable,Clock,Reset,Enable}") :$$$: ""
- type NotFoundError t = (((("Could not find a non-ambiguous domain in the following type:" :$$$: "") :$$$: (" " :<<>>: t)) :$$$: "") :$$$: MissingInstance) :$$$: Outro
- type AmbiguousError t (dom1 :: Domain) (dom2 :: Domain) = ((((((("Could not determine that the domain '" :<<>>: dom1) :<<>>: "'") :$$$: (("was equal to the domain '" :<<>>: dom2) :<<>>: "' in the type:")) :$$$: "") :$$$: (" " :<<>>: t)) :$$$: "") :$$$: "This is usually resolved by adding explicit type signatures.") :$$$: Outro
- type StuckErrorMsg orig n = (((((((((((("Could not determine whether the following type contained a non-ambiguous domain:" :$$$: "") :$$$: (" " :<<>>: n)) :$$$: "") :$$$: "In the full type:") :$$$: "") :$$$: (" " :<<>>: orig)) :$$$: "") :$$$: "Does it contain one?") :$$$: "") :$$$: "------") :$$$: "") :$$$: MissingInstance) :$$$: Outro
- type WithSingleDomain (dom :: Domain) r = (HasSingleDomain r, dom ~ GetDomain r)
- data TryDomainResult
  - = NotFound
  - | Ambiguous Domain Domain
  - | Found Domain
- type family Merge' (n :: TryDomainResult) (m :: TryDomainResult) :: TryDomainResult where ...
- type family Merge orig n m :: TryDomainResult where ...
- type family ErrOnConflict t (n :: TryDomainResult) :: Domain where ...
- type family TryDomain orig n :: TryDomainResult
- class HasSingleDomain r where
  - type GetDomain r :: Domain

# Documentation

type MissingInstance = (((((("This might happen if an instance for TryDomain is missing. Try to determine" :$$$: "which of the types miss an instance, and add them. Example implementations:") :$$$: "") :$$$: " * type instance TryDomain t (MyVector n a) = TryDomain t a") :$$$: " * type instance TryDomain t (MyCircuit dom a) = Found dom") :$$$: " * type instance TryDomain t Terminal = NotFound") :$$$: "") :$$$: "Alternatively, use one of the withSpecific* functions." Source #

type Outro = ((((((((((((((("" :$$$: "------") :$$$: "") :$$$: "You tried to apply an explicitly routed clock, reset, or enable line") :$$$: "to a construct with, possibly, an implicitly routed one. Clash failed to") :$$$: "unambigously determine a single domain and could therefore not route it.") :$$$: "You possibly used one of these sets of functions:") :$$$: "") :$$$: " * with{ClockResetEnable,Clock,Reset,Enable}") :$$$: " * expose{ClockResetEnable,Clock,Reset,Enable}") :$$$: "") :$$$: "These functions are suitable for components defined over a single domain") :$$$: "only. If you want to use multiple domains, use the following instead:") :$$$: "") :$$$: " * withSpecific{ClockResetEnable,Clock,Reset,Enable}") :$$$: " * exposeSpecific{ClockResetEnable,Clock,Reset,Enable}") :$$$: "" Source #

type NotFoundError t = (((("Could not find a non-ambiguous domain in the following type:" :$$$: "") :$$$: (" " :<<>>: t)) :$$$: "") :$$$: MissingInstance) :$$$: Outro Source #

type AmbiguousError t (dom1 :: Domain) (dom2 :: Domain) = ((((((("Could not determine that the domain '" :<<>>: dom1) :<<>>: "'") :$$$: (("was equal to the domain '" :<<>>: dom2) :<<>>: "' in the type:")) :$$$: "") :$$$: (" " :<<>>: t)) :$$$: "") :$$$: "This is usually resolved by adding explicit type signatures.") :$$$: Outro Source #

type StuckErrorMsg orig n = (((((((((((("Could not determine whether the following type contained a non-ambiguous domain:" :$$$: "") :$$$: (" " :<<>>: n)) :$$$: "") :$$$: "In the full type:") :$$$: "") :$$$: (" " :<<>>: orig)) :$$$: "") :$$$: "Does it contain one?") :$$$: "") :$$$: "------") :$$$: "") :$$$: MissingInstance) :$$$: Outro Source #

type WithSingleDomain (dom :: Domain) r = (HasSingleDomain r, dom ~ GetDomain r) Source #

Type that forces dom to be the same in all subtypes of r that might contain a domain. If given a polymorphic domain not tied to r, GHC will be allowed to infer that that domain is equal to the one in r on the condition that r contains just a single domain.

data TryDomainResult Source #

Constructors

NotFound |
Ambiguous Domain Domain |
Found Domain |

type family Merge' (n :: TryDomainResult) (m :: TryDomainResult) :: TryDomainResult where ... Source #

Type family to resolve type conflicts (if any)

Equations

Merge' 'NotFound b = b |
Merge' ('Ambiguous dom1 dom2) b = 'Ambiguous dom1 dom2 |
Merge' a 'NotFound = a |
Merge' a ('Ambiguous dom1 dom2) = 'Ambiguous dom1 dom2 |
Merge' ('Found dom) ('Found dom) = 'Found dom |
Merge' ('Found dom1) ('Found dom2) = 'Ambiguous dom1 dom2 |

type family Merge orig n m :: TryDomainResult where ... Source #

Same as Merge', but will insert a type error if Merge' got stuck.

Equations

Merge orig n m = IfStuck (TryDomain orig n) (DelayError (StuckErrorMsg orig n) :: TryDomainResult) (Pure (IfStuck (TryDomain orig m) (DelayError (StuckErrorMsg orig m) :: TryDomainResult) (Pure (Merge' (TryDomain orig n) (TryDomain orig m))))) |

type family ErrOnConflict t (n :: TryDomainResult) :: Domain where ... Source #

Equations

ErrOnConflict t 'NotFound = TypeError (NotFoundError t) :: Domain |
ErrOnConflict t ('Ambiguous dom1 dom2) = TypeError (AmbiguousError t dom1 dom2) :: Domain |
ErrOnConflict t ('Found dom) = dom |

type family TryDomain orig n :: TryDomainResult Source #

#### Instances

Instances details

type TryDomain t Bit Source # |
Instance details Defined in Clash.Class.HasDomain.HasSingleDomain type TryDomain t Bit = 'NotFound
type TryDomain t Integer Source # |
Instance details Defined in Clash.Class.HasDomain.HasSingleDomain type TryDomain t Integer = 'NotFound
type TryDomain t Natural Source # |
Instance details Defined in Clash.Class.HasDomain.HasSingleDomain type TryDomain t Natural = 'NotFound
type TryDomain t () Source # |
Instance details Defined in Clash.Class.HasDomain.HasSingleDomain type TryDomain t () = 'NotFound
type TryDomain t Bool Source # |
Instance details Defined in Clash.Class.HasDomain.HasSingleDomain type TryDomain t Bool = 'NotFound
type TryDomain t Double Source # |
Instance details Defined in Clash.Class.HasDomain.HasSingleDomain type TryDomain t Double = 'NotFound
type TryDomain t Float Source # |
Instance details Defined in Clash.Class.HasDomain.HasSingleDomain type TryDomain t Float = 'NotFound
type TryDomain t Int Source # |
Instance details Defined in Clash.Class.HasDomain.HasSingleDomain type TryDomain t Int = 'NotFound
type TryDomain t (Clock dom) Source # |
Instance details Defined in Clash.Class.HasDomain.HasSingleDomain type TryDomain t (Clock dom) = 'Found dom
type TryDomain t (Enable dom) Source # |
Instance details Defined in Clash.Class.HasDomain.HasSingleDomain type TryDomain t (Enable dom) = 'Found dom
type TryDomain t (Reset dom) Source # |
Instance details Defined in Clash.Class.HasDomain.HasSingleDomain type TryDomain t (Reset dom) = 'Found dom
type TryDomain t (BitVector n) Source # |
Instance details Defined in Clash.Class.HasDomain.HasSingleDomain type TryDomain t (BitVector n) = 'NotFound
type TryDomain t (Index n) Source # |
Instance details Defined in Clash.Class.HasDomain.HasSingleDomain type TryDomain t (Index n) = 'NotFound
type TryDomain t (Signed n) Source # |
Instance details Defined in Clash.Class.HasDomain.HasSingleDomain type TryDomain t (Signed n) = 'NotFound
type TryDomain t (Unsigned n) Source # |
Instance details Defined in Clash.Class.HasDomain.HasSingleDomain type TryDomain t (Unsigned n) = 'NotFound
type TryDomain t (Maybe a) Source # |
Instance details Defined in Clash.Class.HasDomain.HasSingleDomain type TryDomain t (Maybe a) = TryDomain t a
type TryDomain t (Signal dom a) Source # |
Instance details Defined in Clash.Class.HasDomain.HasSingleDomain type TryDomain t (Signal dom a) = 'Found dom
type TryDomain t (RTree d a) Source # |
Instance details Defined in Clash.Class.HasDomain.HasSingleDomain type TryDomain t (RTree d a) = TryDomain t a
type TryDomain t (Vec n a) Source # |
Instance details Defined in Clash.Class.HasDomain.HasSingleDomain type TryDomain t (Vec n a) = TryDomain t a
type TryDomain t (Either a b) Source # |
Instance details Defined in Clash.Class.HasDomain.HasSingleDomain type TryDomain t (Either a b) = Merge t a b
type TryDomain t (Proxy dom) Source # |
Instance details Defined in Clash.Class.HasDomain.HasSingleDomain type TryDomain t (Proxy dom) = 'Found dom
type TryDomain t (a, b) Source # |
Instance details Defined in Clash.Class.HasDomain.HasSingleDomain type TryDomain t (a, b) = Merge t a b
type TryDomain t (a -> b) Source # |
Instance details Defined in Clash.Class.HasDomain.HasSingleDomain type TryDomain t (a -> b) = Merge t a b
type TryDomain t (BiSignalOut ds dom n) Source # |
Instance details Defined in Clash.Signal.BiSignal type TryDomain t (BiSignalOut ds dom n) = 'Found dom
type TryDomain t (DSignal dom delay a) Source # |
Instance details Defined in Clash.Class.HasDomain.HasSingleDomain type TryDomain t (DSignal dom delay a) = 'Found dom
type TryDomain t (Fixed a n m) Source # |
Instance details Defined in Clash.Class.HasDomain.HasSingleDomain type TryDomain t (Fixed a n m) = TryDomain t (a (n + m))
type TryDomain t (a0, a1, a2) Source # |
Instance details Defined in Clash.Class.HasDomain.HasSingleDomain type TryDomain t (a0, a1, a2) = Merge t a0 (a1, a2)
type TryDomain t (a0, a1, a2, a3) Source # |
Instance details Defined in Clash.Class.HasDomain.HasSingleDomain type TryDomain t (a0, a1, a2, a3) = Merge t a0 (a1, a2, a3)
type TryDomain t (a0, a1, a2, a3, a4) Source # |
Instance details Defined in Clash.Class.HasDomain.HasSingleDomain type TryDomain t (a0, a1, a2, a3, a4) = Merge t a0 (a1, a2, a3, a4)
type TryDomain t (a0, a1, a2, a3, a4, a5) Source # |
Instance details Defined in Clash.Class.HasDomain.HasSingleDomain type TryDomain t (a0, a1, a2, a3, a4, a5) = Merge t a0 (a1, a2, a3, a4, a5)
type TryDomain t (a0, a1, a2, a3, a4, a5, a6) Source # |
Instance details Defined in Clash.Class.HasDomain.HasSingleDomain type TryDomain t (a0, a1, a2, a3, a4, a5, a6) = Merge t a0 (a1, a2, a3, a4, a5, a6)
type TryDomain t (a0, a1, a2, a3, a4, a5, a6, a7) Source # |
Instance details Defined in Clash.Class.HasDomain.HasSingleDomain type TryDomain t (a0, a1, a2, a3, a4, a5, a6, a7) = Merge t a0 (a1, a2, a3, a4, a5, a6, a7)
type TryDomain t (a0, a1, a2, a3, a4, a5, a6, a7, a8) Source # |
Instance details Defined in Clash.Class.HasDomain.HasSingleDomain type TryDomain t (a0, a1, a2, a3, a4, a5, a6, a7, a8) = Merge t a0 (a1, a2, a3, a4, a5, a6, a7, a8)
type TryDomain t (a0, a1, a2, a3, a4, a5, a6, a7, a8, a9) Source # |
Instance details Defined in Clash.Class.HasDomain.HasSingleDomain type TryDomain t (a0, a1, a2, a3, a4, a5, a6, a7, a8, a9) = Merge t a0 (a1, a2, a3, a4, a5, a6, a7, a8, a9)
type TryDomain t (a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) Source # |
Instance details Defined in Clash.Class.HasDomain.HasSingleDomain type TryDomain t (a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) = Merge t a0 (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)
type TryDomain t (a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11) Source # |
Instance details Defined in Clash.Class.HasDomain.HasSingleDomain type TryDomain t (a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11) = Merge t a0 (a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11)

class HasSingleDomain r Source #

Type family that searches a type and checks whether all subtypes that can contain a domain (for example, Signal) contain the same domain. Its associated type, GetDomain, will yield a type error if that doesn't hold OR if it can't check it.

Associated Types

type GetDomain r :: Domain Source #

type GetDomain r = IfStuck (TryDomain r r) (DelayError (StuckErrorMsg r r) :: Domain) (Pure (ErrOnConflict r (TryDomain r r)))

#### Instances

Instances details

HasSingleDomain a Source # |

Instance details

Defined in Clash.Class.HasDomain.HasSingleDomain

Associated Types

type GetDomain a |
Instance details Defined in Clash.Class.HasDomain.HasSingleDomain type GetDomain a = IfStuck (TryDomain a a) (DelayError (StuckErrorMsg a a) :: Domain) (Pure (ErrOnConflict a (TryDomain a a)))