A helper library for constraining types to be Elm port-safe and for providing helpers to codegen Elm types.
Named for a nice Korean snack Kancho that wraps a chocolate core with biscuit.
(Or for the Japanese prank of poking people in their butthole)
newtype Coords = Coords
{ x :: Int
, y :: Int
}
derive instance newtypeCoords :: Newtype Coords _
instance hasElmPortVersionCoords :: HasElmPortVersion Coords where
toElmTypeRep _ = "Coords"
type EtchSketch =
{ cursor :: Coords
, points :: Array Coords
}
outputs
type alias Coords =
{ x : Int
, y : Int
}
type alias EtchSketch =
{ cursor : Coords
, points : List Coords
}
The tests provide some examples to follow along with.
The major chunk of this library is from work done for my Elm-in-Halogen integration demo -- specifically on the row-to-list-ver branch. The demo repo generates Elm types to a file and runs the Elm compiler in the full build, and uses port-safe types.
An updated blog post abou thte RowToList version is available here.
A blog post about the old Generics-Rep version is available here.