Related:
Lazy datatypes in Objective C
From a related question, I was able to figure out how to use block objects to simulate paused calculations, but I'm still trying to understand the concept. For a, horribleComputationthis will work, but how would you create an infinite flow model?
As is usually done in SML,
(* Have a datatype to wrap a computation *)
datatype 'a susp = Susp of (unit -> 'a)
(* Create a recursive datatype to handle an infinite stream *)
datatype 'a stream = Cons of 'a * ('a stream') susp
type 'a stream = ('a stream') susp
Objective-C now has a typedef that accepts predefined values.
enum suit {hearts, spades, diamonds, clubs};
I just can't figure out how to get the Cons parts
So far, if endless data modeling is impossible, there would be one model, for example, Hand cards. Again in SML,
datatype suit = Clubs | Spades | Hearts | Diamonds
datatype rank = Two | Four | Five (*... etc *)
(* Then a card *)
type card = rank*suit
(* And now we can have a Hand :) *)
datatype hand = Empty | Hand of card * hand;
, , , Objective C ... , . .