Created
November 11, 2020 20:19
-
-
Save NCrashed/c500fa6eafaea2d794d9c0bf63d18a8c 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
import Data.ByteString | |
type family mode :- a :: * | |
infixl 0 :- | |
data OnlyPacketB | |
type instance OnlyPacketB :- PacketB OnlyPacketB = PacketB OnlyPacketB | |
type instance OnlyPacketB :- PacketA OnlyPacketB = ByteString | |
type instance OnlyPacketB :- Int = Int | |
type instance OnlyPacketB :- Bool = Bool | |
type instance OnlyPacketB :- Float = Float | |
type instance OnlyPacketB :- Word = Word | |
data OnlyPacketA | |
type instance OnlyPacketA :- PacketB OnlyPacketA = ByteString | |
type instance OnlyPacketA :- PacketA OnlyPacketA = PacketA OnlyPacketA | |
type instance OnlyPacketA :- Int = Int | |
type instance OnlyPacketA :- Bool = Bool | |
type instance OnlyPacketA :- Float = Float | |
type instance OnlyPacketA :- Word = Word | |
data Packet s = Packet { | |
packetA :: s :- PacketA s | |
, packetB :: s :- PacketB s | |
, packetC :: s :- Int | |
} | |
data PacketA s = PacketA { | |
packetA1 :: s :- Bool | |
, packetA2 :: s :- Float | |
} | |
data PacketB s = PacketB { | |
packetB1 :: s :- Word | |
, packetB2 :: s :- Word | |
} | |
example1 :: Packet OnlyPacketB | |
example1 = Packet mempty (PacketB 0 0) 10 | |
example2 :: Packet OnlyPacketA | |
example2 = Packet (PacketA True 0) mempty 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment