Examples:
data SumType = Sum1 | Sum2 | Sum3
getShwifty ''SumTypeenum SumType {
case sum1
case sum2
case sum3
}data ProductType = ProductType { x :: Int, y :: Int }
getShwifty ''ProductTypestruct ProductType {
let x: Int
let y: Int
}data SumType a b = SumL a | SumR b
getShwifty ''SumTypeenum SumType<A, B> {
case sumL(A)
case sumR(B)
}data ProductType a b = ProductType
{ aField :: a
, bField :: b
}
getShwifty ''ProductTypestruct ProductType<A, B> {
let aField: A
let bField: B
}newtype Newtype a = Newtype { getNewtype :: a }
getShwifty ''Newtypestruct Newtype<A> {
let getNewtype: A
}newtype Endo a = Endo { appEndo :: a -> a }
getShwifty ''Endostruct Endo<A> {
let appEndo: ((A) -> A)
}A weird type with nested fields. Also note the Result's types being flipped from that of the Either.
data YouveGotProblems a b = YouveGotProblems
{ field1 :: Maybe (Maybe (Maybe a))
, field2 :: Either (Maybe a) (Maybe b)
}
getShwifty ''YouveGotProblemsstruct YouveGotProblems<A, B> {
let field1: A???
let field2: Result<B?, A?>
}data PolyKinded (a :: k) = PolyKinded
getShwifty ''PolyKindedstruct PolyKinded<A> { }data SumType a b (c :: k)
= Sum1 Int a (Maybe b)
| Sum2 b
| Sum3 { x :: Int, y :: Int }
getShwifty ''SumTypeenum SumType<A, B, C> {
case field1(Int, A, B?)
case field2(B)
case field3(_ x: Int, _ y: Int)
}newtype MyFirstType a = MyFirstType { getMyFirstType :: a }
getShwifty ''MyFirstType
data Contains a = Contains
{ x :: MyFirstType Int
, y :: MyFirstType a
}
getShwifty ''Containsstruct MyFirstType<A> {
let getMyFirstType: A
}
struct Contains<A> {
let x: MyFirstType<Int>
let y: MyFirstType<A>
}