3 ms·
Please can you sure more about this? > We also make ample use of quotations to do some cool tricks (like predict the future states some type can take, based on
by dfgdghdf 6y ago
Please can you sure more about this?
> We also make ample use of quotations to do some cool tricks (like predict the future states some type can take, based on current state + available transitions).
- smt1 6y agoTake a look at F#'s type solver code especially wrt to Extension Typing: https://github.com/dotnet/fsharp/blob/main/src/fsharp/ExtensionTyping.fs https://github.com/dotnet/fsharp/blob/main/src/fsharp/Extens... You can do similar things with other Ocaml or Lispy Langs, depending on how you want to do it. All you need is a function that returns possibleTypeTransitions for givenType(type, enclosedLexeme, type.validTransitions). A gradually typed lang sitting in top of a prototype-based blob also makes this easy to do (see typescript) in-codo. See also MacKay (RIP)'s classic book: http://www.inference.org.uk/itprnn/book.pdf http://www.inference.org.uk/itprnn/book.pdf
- tejasv 6y agoHere's is a simplistic example of a state machine: let transition (state: State) (action: Action) : State option = match (state, action) with | (StateA, ActionA) -> Some StateB | (StateA, ActionB) -> Some StateC | (StateB, ActionA) -> Some StateB | _ -> None If you get the quoted representation of the transition function, it can be visualized as a tree data structure (like code-as-data in LISP). You can analyze that tree to understand that if current state is StateB, only ActionA can be applied on it. Couple this with another realization: "Any sufficiently complicated model class contains an ad hoc, informally specified, bug-ridden, slow implementation of half of a state machine." (not sure where I read this quote). This means all the entity framework/ORM crap work that we do can actually be neatly represented as transforms on a F# state machine, which suddenly makes the application more powerful if you give it this structure. We use this technique to auto-generate admin panels.
- xupybd 6y agoDo you blog any of this or do any sort of writing on the topic. I think I could learn a lot from the way you are doing things.
- tejasv 6y agoNot yet, it has been on my list for a long time. Meanwhile I recommend this blog that collates all good F# content from around the web weekly: https://sergeytihon.com/category/f-weekly/ https://sergeytihon.com/category/f-weekly/
- skue 6y ago> "Any sufficiently complicated model class contains an ad hoc, informally specified, bug-ridden, slow implementation of half of a state machine." (not sure where I read this quote). Can’t tell you where you read it, of course, but believe it originates from Braithwaite/raganwald: http://raganwald.com/2018/02/23/forde.html http://raganwald.com/2018/02/23/forde.html