Popularity
7.2
Stable
Activity
0.0
Stable
23
4
4

Monthly Downloads: 10
Programming language: Haskell
License: MIT License
Tags: Text     TemplateHaskell     Codegen    
Latest version: v0.0.2.0

shwifty alternatives and similar packages

Based on the "Codegen" category.
Alternatively, view shwifty alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of shwifty or a related project?

Add another 'Codegen' Package

README

Shwifty

Generate Swift types from Haskell types

Examples:

A simple sum type
data SumType = Sum1 | Sum2 | Sum3
getShwifty ''SumType
enum SumType {
    case sum1
    case sum2
    case sum3
}
A simple product type
data ProductType = ProductType { x :: Int, y :: Int }
getShwifty ''ProductType
struct ProductType {
    let x: Int
    let y: Int
}
A sum type with type variables
data SumType a b = SumL a | SumR b
getShwifty ''SumType
enum SumType<A, B> {
    case sumL(A)
    case sumR(B)
}
A product type with type variables
data ProductType a b = ProductType 
  { aField :: a
  , bField :: b 
  }
getShwifty ''ProductType
struct ProductType<A, B> {
    let aField: A
    let bField: B
}
A newtype
newtype Newtype a = Newtype { getNewtype :: a }
getShwifty ''Newtype
struct Newtype<A> {
    let getNewtype: A
}
A type with a function field
newtype Endo a = Endo { appEndo :: a -> a }
getShwifty ''Endo
struct 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 ''YouveGotProblems
struct YouveGotProblems<A, B> {
    let field1: A???
    let field2: Result<B?, A?>
}
A type with polykinded type variables
data PolyKinded (a :: k) = PolyKinded
getShwifty ''PolyKinded
struct PolyKinded<A> { }
A sum type where constructors might be records
data SumType a b (c :: k) 
  = Sum1 Int a (Maybe b) 
  | Sum2 b 
  | Sum3 { x :: Int, y :: Int }
getShwifty ''SumType
enum SumType<A, B, C> {
  case field1(Int, A, B?)
  case field2(B)
  case field3(_ x: Int, _ y: Int)
}
A type containing another type with instance generated by 'getShwifty'
newtype MyFirstType a = MyFirstType { getMyFirstType :: a }
getShwifty ''MyFirstType

data Contains a = Contains 
  { x :: MyFirstType Int
  , y :: MyFirstType a 
  }
getShwifty ''Contains
struct MyFirstType<A> {
  let getMyFirstType: A
}

struct Contains<A> {
  let x: MyFirstType<Int>
  let y: MyFirstType<A>
}