Created
April 26, 2018 11:39
-
-
Save Lupino/9a35b7651064498170d2b9d356f2d9bb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
types = """ | |
Create For Json | |
GetList For Q | |
Get CID | |
Remove CID | |
RemoveList For | |
""" | |
types = [t for t in types.split('\n') if t] | |
def l(s): | |
s0 = s[0].lower() | |
return s0 + s[1:] | |
def genFetch(tp): | |
codes = tp.split(' ') | |
length = len(codes) | |
if length == 1: | |
print("""doFetch ({}) = importFn0 "{}" """.format(codes[0], l(codes[0]))) | |
if length == 2: | |
print("""doFetch ({} a) = importFn1 "{}" a""".format(codes[0], l(codes[0]))) | |
if length == 3: | |
print("""doFetch ({} a b) = importFn2 "{}" a b""".format(codes[0], l(codes[0]))) | |
if length == 4: | |
print("""doFetch ({} a b c) = importFn3 "{}" a b c""".format(codes[0], l(codes[0]))) | |
def genImp(tp): | |
codes = tp.split(' ') | |
length = len(codes) | |
if length == 1: | |
print('''{} | |
:: forall eff m. MonadAff eff m => MonadEff eff m => MonadThrow Error m | |
=> YuntanT m Json | |
{} = dataFetch {}'''.format(l(codes[0]), l(codes[0]), codes[0])) | |
if length == 2: | |
print('''{} | |
:: forall eff m. MonadAff eff m => MonadEff eff m => MonadThrow Error m | |
=> {} -> YuntanT m Json | |
{} = dataFetch <<< {}'''.format(l(codes[0]), codes[1], l(codes[0]), codes[0])) | |
if length == 3: | |
print('''{} | |
:: forall eff m. MonadAff eff m => MonadEff eff m => MonadThrow Error m | |
=> {} -> {} -> YuntanT m Json | |
{} a = dataFetch <<< {} a'''.format(l(codes[0]), codes[1], codes[2], l(codes[0]), codes[0])) | |
if length == 4: | |
print('''{} | |
:: forall eff m. MonadAff eff m => MonadEff eff m => MonadThrow Error m | |
=> {} -> {} -> {} -> YuntanT m Json | |
{} a b = dataFetch <<< {} a b'''.format(l(codes[0]), codes[1], codes[2], codes[3], l(codes[0]), codes[0])) | |
for tp in types: | |
genFetch(tp) | |
for tp in types: | |
genImp(tp) | |
for tp in types: | |
print(tp.split(' ')[0]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment