blarney-0.1.0.0
Copyright(c) Matthew Naylor 2021
LicenseMIT
Maintainermattfn@gmail.com
Stabilityexperimental
Safe HaskellSafe-Inferred
LanguageGHC2021

Blarney.TypeFamilies

Description

This module defines commonly used type families, not available in base.

Synopsis

Documentation

type family Min (x :: Nat) (y :: Nat) :: Nat where ... Source #

Type function for computing the min of two type-level nats

Equations

Min x y = If (CmpNat x y == LT) x y 

type family Max (a :: Nat) (b :: Nat) :: Nat where ... Source #

Type function for computing the max of two type-level nats

Equations

Max a b = If (CmpNat a b == GT) a b 

type family Length (ts :: [Type]) :: Nat where ... Source #

Type function to compute the length of a list

Equations

Length '[] = 0 
Length (u ': us) = 1 + Length us 

type family Log2Ceil (n :: Nat) :: Nat where ... Source #

Min number of bits needed to hold given nat

Equations

Log2Ceil n = If (n <=? 1) n (1 + Log2 (n - 1))