Skip to content

Mapping of types

arata, mizuki edited this page Dec 6, 2019 · 1 revision

Primitive types:

  • s -> t (or Function s t) --> (_: s) => t
  • Array t --> Array<t>
  • { key1 :: Type1, key2 :: Type2 } (or Record (key1 :: Type1, key2 :: Type2)) --> { key1: Type1, key2: Type2 }
  • Number, Int --> number
  • String, Char --> string
  • Boolean --> boolean

Types with built-in support:

  • Data.Function.Uncurried
    • Fn0 r --> () => r
    • Fn2 a0 a1 r --> (_0: a0, _1: a2) => r
    • Fn3 a0 a1 a2 r --> (_0: a0, _1: a1, _2: a2) => r
    • ...
    • Fn10 a0 a1 ... a9 r --> (_0: a0, _1: a1, ..., _9: a9) => r
  • Effect (from purescript-effect)
    • Effect a --> () => a
  • Effect.Uncurried (from purescript-effect)
    • EffectFn1 a0 r --> (_0: a0) => r
    • EffectFn2 a0 a1 r --> (_0: a0, _1: a1) => r
    • EffectFn3 a0 a1 a2 r --> (_0: a0, _1: a1, _2: a2) => r
    • ...
    • EffectFn10 a0 a1 ... a9 r --> (_0: a0, _1: a1, ..., _9: a9) => r
  • Data.Variant (from purescript-variant)
    • Variant (tag1 :: Type1, tag2 :: Type2) --> {type: "tag1", value: Type1} | {type: "tag2", value: Type2}
  • Data.Nullable (from purescript-nullable)
    • Nullable a --> a | null
  • Foreign.Object (from purescript-foreign-object)
    • Object t --> {[_: string]: t}
  • Control.Monad.Eff (deprecated)
    • Eff e r --> () => r
  • Data.StrMap (deprecated)
    • StrMap t --> {[_: string]: t}

Candidates:

TODO:

  • Should Data.Void map to never?
  • Should Data.Unit map to void?

Ideas:

  • Support type-level boolean (Prim.Boolean)?
Clone this wiki locally