Skip to content

Instantly share code, notes, and snippets.

@justinwoo
Created August 26, 2017 13:43
Show Gist options
  • Save justinwoo/63e03ab30867ab974da186b694cc8451 to your computer and use it in GitHub Desktop.
Save justinwoo/63e03ab30867ab974da186b694cc8451 to your computer and use it in GitHub Desktop.
data kinds + kind signatures because yolo
{-# 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