type-spec-0.1.0.0: Type Level Specification by Example

Safe HaskellNone
LanguageHaskell2010

Test.TypeSpec.Internal.Result

Description

Result type used in constraints inside TypeSpec to propagate type errors.

Synopsis

Documentation

type Result = Either ErrorMessage Source #

When a type level expectation is tested, it might be that compound expectations fail. In order to have a small, precise error message, the type level assertion results are made to have kind Result.

type family Try (e :: Result k) :: k where ... Source #

Equations

Try (OK (d :: k)) = d 
Try (FAILED m) = TypeError m 

type family DontTry (e :: Result r) :: Constraint where ... Source #

Equations

DontTry (FAILED e) = () 
DontTry (OK okIsNotOk) = TypeError ((Text "You specified this wasn't okay: " :$$: (Text " " :<>: ShowType okIsNotOk)) :$$: Text "... turns out it actually is!") 

type OK = Right Source #

A nice name than Left

type family PrependToError (message :: ErrorMessage) (result :: Result a) :: Result a where ... Source #

Equations

PrependToError message (OK x) = OK x 
PrependToError message (FAILED otherMessage) = FAILED (message :<>: otherMessage)