Skip to content

Instantly share code, notes, and snippets.

@JBetz
Last active January 19, 2019 17:17
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 JBetz/7b0b374bf022b94db2730b5f05b057fd to your computer and use it in GitHub Desktop.
Save JBetz/7b0b374bf022b94db2730b5f05b057fd to your computer and use it in GitHub Desktop.
type list iteration example
generate :: [e] -> [Structure e]
generate objs =
let (otStrs, objs2) = generateFrom @OT objs
(ttStrs, objs3) = generateFrom @TT objs2
(btStrs, objs4) = generateFrom @BT objs3
(lStrs, _) = generateFrom @L objs4
in otStrs ++ ttStrs ++ btStrs ++ lStrs
-- first element of the tuple is all the structures that could be generated from the given list of objects
-- second element is all the objects that remain, i.e., that weren't used to generate one of the structures
generateFrom :: forall f. Generatable f => [e] -> ([Structure e], [e])
generateFrom objs = ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment