Skip to content

Instantly share code, notes, and snippets.

/*
#![feature(collections_range)]
#![feature(drain_filter)]
#![feature(slice_rsplit)]
#![feature(slice_get_slice)]
#![feature(vec_resize_default)]
#![feature(vec_remove_item)]
#![feature(collections_range)]
#![feature(slice_rotate)]
#![feature(swap_with_slice)]
square academic cap
table
chair
basket
wicker basket
wire basket
napkin
doily
flower
daisy
// is there a way to bound the 'TRAIT_OBJECT' type param to tell it *this is a trait object*?
// context..
// looking for ways of streamlining code dealing with boxed-trait-objects
impl Editor{
pub fn set_tool<'e,E:MTool<EdScene>+Clone>(&'e mut self,data:E) where E:'static{
self.mtool = new_object(data);
//Box::new(data) as Box<MTool<EdScene>> // <<<<<<< WAS THIS...
}
}
[1]ARE THERE UP-FRONT HINTS THAT CAN BE GIVEN TO HASKELL
FOR THE GARBAGE COLLECTION SYSTEM
[2] COULD I ASK HASKELL TO GIVE ERRORS IF ANY
DIRECT REFERENCES EXIST BETWEEN THE TWO ARENAS (update / render)
[3] DOES LAZINESS COMPLICATE OR HELP,
CAN THE UP-FRONT HINTS OVER-RIDE LAZINESS
callUpdateWith::UIEvent ->IO ()
callUpdateWith ev=do
mw <-readIORef gWorld
mu <-readIORef gUpdate
ma <-readIORef gAssets
-- is there a cleaner way to do this part:-
-- I think of 'if let' in Rust (if let Some(a),Some(w),Some(u)) ...
-- I also wonder if there's a way to 'pipe' the output of 'callUf u a ev w' into
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
-- Vec2, Vec3, Vec4 for x/y, x/y/z, x/y/z/w
instance Functor Vec3 where
fmap f (Vec3 x y z) = Vec3 (f x) (f y) (f z)
-- Docs tell me...
--class (Functor f)=> Applicative f where
-- pure :: a -> f a
-- (<*>) :: f (a -> b) -> f a -> f b
-- some operations should be supported by bigger 'objects' e.g.
-- vertices , valid to say 'whats the maximum of each component of 2 vertices', 'blend 2 vertices..'
-- but vertices are not necaserily vectors?.. the data within is in different spaces (position, color, normal..)
class VertexOps v where
vlerp::Num s=>v->s->v
vmin::v->v->v
vmax::v->v->v
-- TODO some of this might be monad malarky? (fmap? liftM2? )
/// means of throwing ints into the typesys
pub struct TN7{}
/// means of throwing ints into the typesys
pub struct TN15{}
/// means of throwing ints into the typesys
pub struct TN16{}
/// means of throwing ints into the typesys
pub struct TN12{}
/// means of throwing ints into the typesys
// This compiles, but didn't need lifetime annotations.
// what does this do differently compared to the version using operators?
pub trait MulRef<B> {
type Output;
fn mul_ref(&self,&B)->Self::Output;
}
pub trait AddRef<B> {
type Output;
fn add_ref(&self,&B)->Self::Output;