Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dobkeratops/2ddc3f1a6e8099668786ce32e674c922 to your computer and use it in GitHub Desktop.
Save dobkeratops/2ddc3f1a6e8099668786ce32e674c922 to your computer and use it in GitHub Desktop.
data Entity=Entity{name::String,pos::Vec3f}
data Trigger=Trigger{name::String,num::Int}
class HasName x where
nameOf :: x -> String
instance HasName Entity where
nameOf Entity{name=x}=x
instance HasName Trigger where
nameOf Trigger{name=x}=x
test_struct::String
test_struct =let
ent = Entity "foo" (Vec3 0.0 0.5 1.0)
trigger= Trigger"bar" 15
in
nameOf ent ++ nameOf trigger
-- result: "foobar"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment