Created
December 4, 2020 22:30
-
-
Save tim2CF/221616992d89d9ef458df8080bfa4a28 to your computer and use it in GitHub Desktop.
KindedTypeParameters.hs
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 KindSignatures #-} | |
module Lib where | |
data Owner = Merchant | Customer | |
newtype MoneyAmount (a :: Owner) | |
= MoneyAmount Rational | |
data BalanceCurrency | |
= BX | |
| BY | |
| BZ | |
data SettlmentCurrency | |
= SX | |
| SY | |
-- | |
-- How I can add constraint to type `b`? | |
-- I want it to be only `BalanceCurrency` or `SettlementCurrency`. | |
-- But not any other type. | |
-- | |
data Money (a :: Owner) b | |
= Money | |
{ amt :: MoneyAmount a, | |
cc :: b | |
} |
Author
tim2CF
commented
Dec 5, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment