Last active
June 8, 2020 16:00
-
-
Save zunction/c06c5effef7c9453d25ac544a3b269ed to your computer and use it in GitHub Desktop.
reflkg utils
This file contains hidden or 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
| import System.IO | |
| import Control.Monad | |
| type Node = Prelude.String | |
| -- singleton inductive, whose constructor was Node | |
| node_rect :: (Prelude.String -> a1) -> Node -> a1 | |
| node_rect f = | |
| f | |
| data Edge0 = | |
| Edge Node Node Node deriving Show | |
| e1 :: Edge0 -> Node | |
| e1 e = | |
| case e of { | |
| Edge e4 _ _ -> e4} | |
| e2 :: Edge0 -> Node | |
| e2 e = | |
| case e of { | |
| Edge _ e4 _ -> e4} | |
| e3 :: Edge0 -> Node | |
| e3 e = | |
| case e of { | |
| Edge _ _ e4 -> e4} | |
| prompt :: String -> IO String | |
| prompt text = do | |
| putStr text | |
| hFlush stdout | |
| getLine | |
| readData :: String -> IO String | |
| readData fn = do | |
| content <- readFile (fn ++ ".txt") | |
| return content | |
| processData :: String -> IO ([String]) | |
| processData c = do | |
| let out = lines c | |
| return out | |
| consE :: [String] -> Edge0 | |
| consE [x, y, z] = Edge x y z | |
| pT :: String -> IO ([Edge0]) | |
| pT str = do | |
| d <- readData str | |
| let out1 = lines d | |
| let out2 = map words out1 | |
| let out3 = map consE out2 | |
| --print out3 | |
| return out3 | |
| {-- | |
| parseTriples :: String -> IO ([String]) | |
| parseTriples str = do | |
| d <- readData str | |
| out <- processData d | |
| return out | |
| --} | |
| {-- | |
| map words out | |
| --} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment