Created
August 26, 2017 13:43
-
-
Save justinwoo/63e03ab30867ab974da186b694cc8451 to your computer and use it in GitHub Desktop.
data kinds + kind signatures because yolo
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 Main where | |
import Data.Proxy | |
import Data.List | |
data Validity = Validated | NotValidated | |
class Crap (a :: Validity) where | |
whatever :: Proxy a -> String | |
instance Crap 'Validated where | |
whatever _ = "dsfdsf" | |
newtype MyThing (validity :: Validity) = MyThing String | |
myThing :: MyThing 'NotValidated | |
myThing = MyThing "sdfa" | |
validatePls :: | |
MyThing 'NotValidated | |
-> Either String (MyThing 'Validated) | |
validatePls (MyThing s) = | |
if "a" `isInfixOf` s | |
then Right (MyThing s) | |
else Left "sdfsdf" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment