Questions tagged [transducer-machines]

Machines are a framework for describing I/O in a functional setting. Compared to pipes and conduits, they offer more flexible input.

Machines are a functional programming concept that is an alternative to pipe libraries such as "pipes" and "conduit". Some of its advantages includes more flexible input, allowing for example one component to read multiple inputs in various ways.

The machines package provides a Haskell implementation.

10 questions
48
votes
1 answer

Using Scalaz Stream for parsing task (replacing Scalaz Iteratees)

Introduction I use Scalaz 7's iteratees in a number of projects, primarily for processing large-ish files. I'd like to start switching to Scalaz streams, which are designed to replace the iteratee package (which frankly is missing a lot of pieces…
Travis Brown
  • 138,631
  • 12
  • 375
  • 680
29
votes
1 answer

What's the conceptual difference between Machines and Conduits (or other similar libraries)?

I'd like to learn the concept, so that I'd be able to understand and use libraries such as machines. I tried to follow Rúnar Bjarnason's talk on machines, but there is too little information, basically just a bunch of data types. I can't even…
Petr
  • 62,528
  • 13
  • 153
  • 317
9
votes
2 answers

What are the similarities and differences between Scala Transducers and Clojure Transducers?

Paul Chiusano and Rúnar Óli have written a fantastic book Functional programming in Scala. In it they mention a little-referenced concept in the Scala community - Transducers. In the Clojure Community - Transducers get a little more press. My…
hawkeye
  • 34,745
  • 30
  • 150
  • 304
4
votes
1 answer

Using Data.Machine, how can you compose two ProcessT together that modifies two different states?

Let's say I have a process that modifies an underlying state that is an Int: p1 :: ProcessT (State Int) Int Int p1 = repeatedly $ do a <- await lift . modify $ (+a) yield a And another that modifies an underlying state that is an [Int]: p2…
xiaolingxiao
  • 4,793
  • 5
  • 41
  • 88
3
votes
1 answer

Using Data.Machine, how would you describe a plan that branches with results of a non-deterministic function?

I think this question is best illustrated with an example. A type that wraps a non-deterministic function: data ND a b = N { runN :: a -> [(b, ND a b)] } instance Show (ND a b) where show n = show "" An example of ND: nd :: ND String…
xiaolingxiao
  • 4,793
  • 5
  • 41
  • 88
3
votes
1 answer

Could someone provide a machines implementation of the following plan?

I am playing around with the machines module by Edward Kmett, and I'm getting a little confused here and there. I thought the best way to ask a question is to provide a toy use case. Described below. Machines one and two sit at two prongs of a…
xiaolingxiao
  • 4,793
  • 5
  • 41
  • 88
2
votes
2 answers

Constructing a Moore Machine

I have a homework question: Construct a Moore machine that takes a string consisting of a's b's and c's as input and outputs a string containing 1 at the end of each substring abc and a 0 in all other positions. e.g. input, aabcb produces…
1
vote
1 answer

Generate output based on first character of a word

I am trying to set up a Finite State Transducer with Helsinki Finite State Technology (HFST) for Python. I want if the first character of a word is an 'o' the output is "Positive" and if there are characters following in the same word, output empty…
1
vote
0 answers

Issues with Foma fst when using python

I am trying to morph analyse a full folder containing txt files. using https://code.google.com/archive/p/foma/ This is the code which i have written.I am passing each word to the foma fst in python but after running for 143 files out of 1900 files…
gaurus
  • 426
  • 1
  • 4
  • 16
0
votes
0 answers

Is there a more efficient way to look for a equivalent state? (Finite state transducer)

I am trying to implement the minimal finite state transducer described by Mihov and Maurel (http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.24.3698) in Python3. My program is working but needs a lot of time, so I decided to use cProfile to…