-
-
Save sdiehl/d829024b77464cedf61a to your computer and use it in GitHub Desktop.
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
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE TypeOperators #-} | |
{-# LANGUAGE KindSignatures #-} | |
{-# LANGUAGE ConstraintKinds #-} | |
module Data.HdrHistogram.Config.Test where | |
import Data.Proxy | |
import GHC.TypeLits (Nat, type (<=)) | |
data Config (lowest :: Nat) (highest :: Nat) (sig :: Nat) | |
type SigBounds sig = (1 <= sig, sig <= 7) | |
type HighLow a b = (a <= b) | |
mkConfig :: (HighLow low high, SigBounds sig) => Proxy (Config low high sig) | |
mkConfig = Proxy | |
-- good | |
a :: Proxy (Config 1 1024 3) | |
a = mkConfig | |
-- fail (HighLow) | |
b :: Proxy (Config 3 2 3) | |
b = mkConfig | |
-- fail (SigBounds) | |
c :: Proxy (Config 1 1024 8) | |
c = mkConfig |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment